@meistrari/vault-http-client 2.8.0 → 2.10.0

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/index.cjs CHANGED
@@ -9,6 +9,7 @@ const postFilesBulk_Body = zod.z.union([
9
9
  fileName: zod.z.string(),
10
10
  parentId: zod.z.string(),
11
11
  onMissingParent: zod.z.enum(["error", "create-as-root"]).default("error"),
12
+ onParentConflict: zod.z.enum(["error", "update-parent-id", "ignore"]).default("error"),
12
13
  sha256sum: zod.z.string(),
13
14
  size: zod.z.number(),
14
15
  mimeType: zod.z.string(),
@@ -22,6 +23,7 @@ const postFiles_Body = zod.z.object({
22
23
  fileName: zod.z.string(),
23
24
  parentId: zod.z.string(),
24
25
  onMissingParent: zod.z.enum(["error", "create-as-root"]).default("error"),
26
+ onParentConflict: zod.z.enum(["error", "update-parent-id", "ignore"]).default("error"),
25
27
  sha256sum: zod.z.string(),
26
28
  size: zod.z.number(),
27
29
  mimeType: zod.z.string(),
@@ -164,6 +166,11 @@ The returned `uploadUrl` is valid for 1 hour by default. You can chang
164
166
  type: "Query",
165
167
  schema: zod.z.string()
166
168
  },
169
+ {
170
+ name: "preserveFileName",
171
+ type: "Query",
172
+ schema: zod.z.enum(["true", "false"]).optional().default("false")
173
+ },
167
174
  {
168
175
  name: "fileId",
169
176
  type: "Path",
@@ -573,6 +580,11 @@ The returned `uploadUrl` is valid for 1 hour by default. You can chang
573
580
  description: `Get a pre-signed download URL for a file.`,
574
581
  requestFormat: "json",
575
582
  parameters: [
583
+ {
584
+ name: "preserveFileName",
585
+ type: "Query",
586
+ schema: zod.z.enum(["true", "false"]).optional().default("true")
587
+ },
576
588
  {
577
589
  name: "fileId",
578
590
  type: "Path",
@@ -968,344 +980,6 @@ Make sure to follow redirects to the actual file download URL.
968
980
  schema: zod.z.void()
969
981
  }
970
982
  ]
971
- },
972
- {
973
- method: "patch",
974
- path: "/v2/:id/uploaded-at",
975
- description: `Set the uploaded at timestamp for a file.`,
976
- requestFormat: "json",
977
- parameters: [
978
- {
979
- name: "id",
980
- type: "Path",
981
- schema: zod.z.string()
982
- }
983
- ],
984
- response: zod.z.void()
985
- },
986
- {
987
- method: "post",
988
- path: "/v2/files",
989
- description: `Create a file and get a pre-signed upload URL.
990
-
991
- The `sha256` body param is used as the file's primary key. If not provided, a random UUID will be generated.
992
-
993
- The returned `uploadUrl` is valid for 1 hour by default. You can change the expiration time by passing the `expiresIn` query parameter.
994
- `,
995
- requestFormat: "json",
996
- parameters: [
997
- {
998
- name: "body",
999
- type: "Body",
1000
- schema: postFiles_Body
1001
- },
1002
- {
1003
- name: "expiresIn",
1004
- type: "Query",
1005
- schema: zod.z.number().optional().default(3600)
1006
- }
1007
- ],
1008
- response: zod.z.object({
1009
- id: zod.z.string(),
1010
- uploadUrl: zod.z.string(),
1011
- expiresAt: zod.z.string().datetime({ offset: true }),
1012
- metadata: zod.z.object({
1013
- id: zod.z.string(),
1014
- path: zod.z.string(),
1015
- workspaceId: zod.z.string(),
1016
- parentId: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1017
- originalFileName: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1018
- mimeType: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1019
- size: zod.z.union([zod.z.number(), zod.z.null()]).optional(),
1020
- legacyKey: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1021
- bucketName: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1022
- encryptionKey: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1023
- createdBy: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1024
- createdAt: zod.z.string(),
1025
- deletedAt: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1026
- uploadedAt: zod.z.union([zod.z.string(), zod.z.null()]).optional()
1027
- }),
1028
- path: zod.z.string()
1029
- })
1030
- },
1031
- {
1032
- method: "get",
1033
- path: "/v2/files/:fileId",
1034
- description: `Get a pre-signed download URL for a file.`,
1035
- requestFormat: "json",
1036
- parameters: [
1037
- {
1038
- name: "fileId",
1039
- type: "Path",
1040
- schema: zod.z.string()
1041
- }
1042
- ],
1043
- response: zod.z.object({
1044
- url: zod.z.string(),
1045
- expiresAt: zod.z.string().datetime({ offset: true }),
1046
- metadata: zod.z.union([
1047
- zod.z.object({
1048
- id: zod.z.string(),
1049
- path: zod.z.string(),
1050
- workspaceId: zod.z.string(),
1051
- parentId: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1052
- originalFileName: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1053
- mimeType: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1054
- size: zod.z.union([zod.z.number(), zod.z.null()]).optional(),
1055
- legacyKey: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1056
- bucketName: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1057
- encryptionKey: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1058
- createdBy: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1059
- createdAt: zod.z.string(),
1060
- deletedAt: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1061
- uploadedAt: zod.z.union([zod.z.string(), zod.z.null()]).optional()
1062
- }),
1063
- zod.z.null()
1064
- ])
1065
- }),
1066
- errors: [
1067
- {
1068
- status: 404,
1069
- description: `File not found`,
1070
- schema: zod.z.void()
1071
- }
1072
- ]
1073
- },
1074
- {
1075
- method: "post",
1076
- path: "/v2/files/:filename",
1077
- description: `Create a file and get a pre-signed upload URL (legacy endpoint).
1078
-
1079
- This endpoint is deprecated. Use POST /files instead with `originalFileName` in the request body.
1080
-
1081
- The `sha256` body param is used as the file's primary key. If not provided, a random UUID will be generated.
1082
-
1083
- The returned `url` is valid for 1 hour by default. You can change the expiration time by passing the `expiresIn` query parameter.
1084
- `,
1085
- requestFormat: "json",
1086
- parameters: [
1087
- {
1088
- name: "body",
1089
- type: "Body",
1090
- schema: postFiles_Body
1091
- },
1092
- {
1093
- name: "expiresIn",
1094
- type: "Query",
1095
- schema: zod.z.number().optional().default(3600)
1096
- },
1097
- {
1098
- name: "filename",
1099
- type: "Path",
1100
- schema: zod.z.string()
1101
- }
1102
- ],
1103
- response: zod.z.object({
1104
- url: zod.z.string(),
1105
- expiresAt: zod.z.string().datetime({ offset: true })
1106
- })
1107
- },
1108
- {
1109
- method: "put",
1110
- path: "/v2/files/:id",
1111
- description: `Create a file and get a pre-signed upload URL.`,
1112
- requestFormat: "json",
1113
- parameters: [
1114
- {
1115
- name: "expiresIn",
1116
- type: "Query",
1117
- schema: zod.z.number().optional().default(3600)
1118
- },
1119
- {
1120
- name: "id",
1121
- type: "Path",
1122
- schema: zod.z.string()
1123
- }
1124
- ],
1125
- response: zod.z.union([
1126
- zod.z.object({
1127
- id: zod.z.string(),
1128
- uploadUrl: zod.z.string().url(),
1129
- expiresAt: zod.z.string().datetime({ offset: true }),
1130
- metadata: zod.z.object({
1131
- id: zod.z.string(),
1132
- path: zod.z.string(),
1133
- workspaceId: zod.z.string(),
1134
- parentId: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1135
- originalFileName: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1136
- mimeType: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1137
- size: zod.z.union([zod.z.number(), zod.z.null()]).optional(),
1138
- legacyKey: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1139
- bucketName: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1140
- encryptionKey: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1141
- createdBy: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1142
- createdAt: zod.z.string(),
1143
- deletedAt: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1144
- uploadedAt: zod.z.union([zod.z.string(), zod.z.null()]).optional()
1145
- })
1146
- }),
1147
- zod.z.object({
1148
- url: zod.z.string().url(),
1149
- expiresAt: zod.z.string().datetime({ offset: true })
1150
- })
1151
- ])
1152
- },
1153
- {
1154
- method: "delete",
1155
- path: "/v2/files/:id",
1156
- description: `Delete a file.`,
1157
- requestFormat: "json",
1158
- parameters: [
1159
- {
1160
- name: "id",
1161
- type: "Path",
1162
- schema: zod.z.string()
1163
- }
1164
- ],
1165
- response: zod.z.void()
1166
- },
1167
- {
1168
- method: "get",
1169
- path: "/v2/files/:id/metadata",
1170
- description: `Get the metadata for a file.`,
1171
- requestFormat: "json",
1172
- parameters: [
1173
- {
1174
- name: "id",
1175
- type: "Path",
1176
- schema: zod.z.string()
1177
- }
1178
- ],
1179
- response: zod.z.object({
1180
- id: zod.z.string(),
1181
- path: zod.z.string(),
1182
- workspaceId: zod.z.string(),
1183
- parentId: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1184
- originalFileName: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1185
- mimeType: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1186
- size: zod.z.union([zod.z.number(), zod.z.null()]).optional(),
1187
- legacyKey: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1188
- bucketName: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1189
- encryptionKey: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1190
- createdBy: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1191
- createdAt: zod.z.string(),
1192
- deletedAt: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1193
- uploadedAt: zod.z.union([zod.z.string(), zod.z.null()]).optional()
1194
- }),
1195
- errors: [
1196
- {
1197
- status: 404,
1198
- description: `File not found`,
1199
- schema: zod.z.void()
1200
- }
1201
- ]
1202
- },
1203
- {
1204
- method: "get",
1205
- path: "/v2/files/:parentId/children",
1206
- description: `Get the children of a file.`,
1207
- requestFormat: "json",
1208
- parameters: [
1209
- {
1210
- name: "mimeType",
1211
- type: "Query",
1212
- schema: zod.z.string().optional()
1213
- },
1214
- {
1215
- name: "includeDeleted",
1216
- type: "Query",
1217
- schema: zod.z.enum(["true", "false"]).optional().default("false")
1218
- },
1219
- {
1220
- name: "limit",
1221
- type: "Query",
1222
- schema: zod.z.number().optional().default(100)
1223
- },
1224
- {
1225
- name: "offset",
1226
- type: "Query",
1227
- schema: zod.z.number().optional().default(0)
1228
- },
1229
- {
1230
- name: "parentId",
1231
- type: "Path",
1232
- schema: zod.z.string()
1233
- }
1234
- ],
1235
- response: zod.z.object({
1236
- files: zod.z.array(
1237
- zod.z.object({
1238
- id: zod.z.string(),
1239
- path: zod.z.string(),
1240
- workspaceId: zod.z.string(),
1241
- parentId: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1242
- originalFileName: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1243
- mimeType: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1244
- size: zod.z.union([zod.z.number(), zod.z.null()]).optional(),
1245
- legacyKey: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1246
- bucketName: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1247
- encryptionKey: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1248
- createdBy: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1249
- createdAt: zod.z.string(),
1250
- deletedAt: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1251
- uploadedAt: zod.z.union([zod.z.string(), zod.z.null()]).optional()
1252
- })
1253
- ),
1254
- count: zod.z.number()
1255
- })
1256
- },
1257
- {
1258
- method: "post",
1259
- path: "/v2/files/bulk",
1260
- description: `Create multiple files in bulk and get pre-signed upload URLs.`,
1261
- requestFormat: "json",
1262
- parameters: [
1263
- {
1264
- name: "body",
1265
- type: "Body",
1266
- schema: postFilesBulk_Body
1267
- }
1268
- ],
1269
- response: zod.z.union([
1270
- zod.z.array(
1271
- zod.z.object({
1272
- id: zod.z.string(),
1273
- path: zod.z.string(),
1274
- workspaceId: zod.z.string(),
1275
- parentId: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1276
- originalFileName: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1277
- mimeType: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1278
- size: zod.z.union([zod.z.number(), zod.z.null()]).optional(),
1279
- legacyKey: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1280
- bucketName: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1281
- encryptionKey: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1282
- createdBy: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1283
- createdAt: zod.z.string(),
1284
- deletedAt: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1285
- uploadedAt: zod.z.union([zod.z.string(), zod.z.null()]).optional()
1286
- })
1287
- ),
1288
- zod.z.object({
1289
- files: zod.z.array(
1290
- zod.z.object({
1291
- id: zod.z.string(),
1292
- path: zod.z.string(),
1293
- workspaceId: zod.z.string(),
1294
- parentId: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1295
- originalFileName: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1296
- mimeType: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1297
- size: zod.z.union([zod.z.number(), zod.z.null()]).optional(),
1298
- legacyKey: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1299
- bucketName: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1300
- encryptionKey: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1301
- createdBy: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1302
- createdAt: zod.z.string(),
1303
- deletedAt: zod.z.union([zod.z.string(), zod.z.null()]).optional(),
1304
- uploadedAt: zod.z.union([zod.z.string(), zod.z.null()]).optional()
1305
- })
1306
- )
1307
- })
1308
- ])
1309
983
  }
1310
984
  ]);
1311
985
  new core.Zodios(endpoints);
@@ -1313,17 +987,18 @@ function createApiClient(baseUrl, options) {
1313
987
  return new core.Zodios(baseUrl, endpoints, options);
1314
988
  }
1315
989
 
990
+ const serviceName = process.env.SERVICE_NAME;
991
+ const userAgent = `vault-http-client:2.10.0${serviceName ? `@${serviceName}` : ""}`.trim();
1316
992
  function useVaultClient(vaultUrl, token) {
1317
993
  const api = createApiClient(vaultUrl, {
1318
994
  axiosConfig: {
1319
995
  headers: {
1320
996
  "Authorization": token,
1321
- "User-Agent": "vault-http-client:2.8.0"
997
+ "User-Agent": userAgent
1322
998
  }
1323
999
  }
1324
1000
  });
1325
1001
  return api;
1326
1002
  }
1327
1003
 
1328
- exports.createApiClient = createApiClient;
1329
1004
  exports.useVaultClient = useVaultClient;