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