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