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