@meistrari/vault-http-client 2.9.0 → 2.14.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/dist/index.mjs CHANGED
@@ -1,31 +1,30 @@
1
1
  import { makeApi, Zodios } from '@zodios/core';
2
2
  import { z } from 'zod';
3
3
 
4
- const postFilesBulk_Body = z.union([
5
- z.array(
6
- z.object({
7
- fileName: z.string(),
8
- parentId: z.string(),
9
- onMissingParent: z.enum(["error", "create-as-root"]).default("error"),
10
- sha256sum: z.string(),
11
- size: z.number(),
12
- mimeType: z.string(),
13
- createdBy: z.string(),
14
- path: z.string()
15
- }).partial()
16
- ),
17
- z.object({ files: z.array(z.string()) })
18
- ]);
19
4
  const postFiles_Body = z.object({
20
5
  fileName: z.string(),
21
6
  parentId: z.string(),
22
7
  onMissingParent: z.enum(["error", "create-as-root"]).default("error"),
8
+ onParentConflict: z.enum(["error", "update-parent-id", "ignore"]).default("error"),
23
9
  sha256sum: z.string(),
24
10
  size: z.number(),
25
11
  mimeType: z.string(),
26
12
  createdBy: z.string(),
27
13
  path: z.string()
28
14
  }).partial();
15
+ const postFilesBulk_Body = z.array(
16
+ z.object({
17
+ fileName: z.string(),
18
+ parentId: z.string(),
19
+ onMissingParent: z.enum(["error", "create-as-root"]).default("error"),
20
+ onParentConflict: z.enum(["error", "update-parent-id", "ignore"]).default("error"),
21
+ sha256sum: z.string(),
22
+ size: z.number(),
23
+ mimeType: z.string(),
24
+ createdBy: z.string(),
25
+ path: z.string()
26
+ }).partial()
27
+ );
29
28
  const put_WorkspacesByWorkspaceIdSettings_Body = z.object({
30
29
  bucketName: z.string().min(1),
31
30
  keyArns: z.array(z.string()).min(1),
@@ -404,7 +403,6 @@ The returned `uploadUrl` is valid for 1 hour by default. You can chang
404
403
  response: z.array(
405
404
  z.object({
406
405
  workspaceId: z.string(),
407
- files: z.number(),
408
406
  permalinks: z.number(),
409
407
  hasCustomSettings: z.boolean()
410
408
  })
@@ -570,6 +568,71 @@ The returned `uploadUrl` is valid for 1 hour by default. You can chang
570
568
  path: z.string()
571
569
  })
572
570
  },
571
+ {
572
+ method: "get",
573
+ path: "/files",
574
+ description: `Get a list of files.`,
575
+ requestFormat: "json",
576
+ parameters: [
577
+ {
578
+ name: "limit",
579
+ type: "Query",
580
+ schema: z.number().gte(1).lte(500).optional().default(10)
581
+ },
582
+ {
583
+ name: "offset",
584
+ type: "Query",
585
+ schema: z.number().gte(0).optional().default(0)
586
+ },
587
+ {
588
+ name: "orderByField",
589
+ type: "Query",
590
+ schema: z.enum(["id", "createdAt", "deletedAt"]).optional()
591
+ },
592
+ {
593
+ name: "orderByDirection",
594
+ type: "Query",
595
+ schema: z.enum(["asc", "desc"]).optional().default("asc")
596
+ },
597
+ {
598
+ name: "search",
599
+ type: "Query",
600
+ schema: z.string().optional()
601
+ },
602
+ {
603
+ name: "includeDeleted",
604
+ type: "Query",
605
+ schema: z.enum(["true", "false"]).optional().default("false")
606
+ },
607
+ {
608
+ name: "includeChildren",
609
+ type: "Query",
610
+ schema: z.enum(["true", "false"]).optional().default("false")
611
+ }
612
+ ],
613
+ response: z.object({
614
+ files: z.array(
615
+ z.object({
616
+ id: z.string(),
617
+ path: z.string(),
618
+ workspaceId: z.string(),
619
+ parentId: z.union([z.string(), z.null()]).optional(),
620
+ originalFileName: z.union([z.string(), z.null()]).optional(),
621
+ mimeType: z.union([z.string(), z.null()]).optional(),
622
+ size: z.union([z.number(), z.null()]).optional(),
623
+ legacyKey: z.union([z.string(), z.null()]).optional(),
624
+ bucketName: z.union([z.string(), z.null()]).optional(),
625
+ encryptionKey: z.union([z.string(), z.null()]).optional(),
626
+ createdBy: z.union([z.string(), z.null()]).optional(),
627
+ createdAt: z.string(),
628
+ deletedAt: z.union([z.string(), z.null()]).optional(),
629
+ uploadedAt: z.union([z.string(), z.null()]).optional()
630
+ })
631
+ ),
632
+ count: z.number(),
633
+ pages: z.number()
634
+ })
635
+ },
573
636
  {
574
637
  method: "get",
575
638
  path: "/files/:fileId",
@@ -618,6 +681,40 @@ The returned `uploadUrl` is valid for 1 hour by default. You can chang
618
681
  }
619
682
  ]
620
683
  },
684
+ {
685
+ method: "patch",
686
+ path: "/files/:fileId",
687
+ description: `Update file metadata. This only affects file metadata and has no effect on file conflicts or storage location.`,
688
+ requestFormat: "json",
689
+ parameters: [
690
+ {
691
+ name: "body",
692
+ type: "Body",
693
+ schema: z.object({ name: z.string().min(1) })
694
+ },
695
+ {
696
+ name: "fileId",
697
+ type: "Path",
698
+ schema: z.string()
699
+ }
700
+ ],
701
+ response: z.object({
702
+ id: z.string(),
703
+ path: z.string(),
704
+ workspaceId: z.string(),
705
+ parentId: z.union([z.string(), z.null()]).optional(),
706
+ originalFileName: z.union([z.string(), z.null()]).optional(),
707
+ mimeType: z.union([z.string(), z.null()]).optional(),
708
+ size: z.union([z.number(), z.null()]).optional(),
709
+ legacyKey: z.union([z.string(), z.null()]).optional(),
710
+ bucketName: z.union([z.string(), z.null()]).optional(),
711
+ encryptionKey: z.union([z.string(), z.null()]).optional(),
712
+ createdBy: z.union([z.string(), z.null()]).optional(),
713
+ createdAt: z.string(),
714
+ deletedAt: z.union([z.string(), z.null()]).optional(),
715
+ uploadedAt: z.union([z.string(), z.null()]).optional()
716
+ })
717
+ },
621
718
  {
622
719
  method: "post",
623
720
  path: "/files/:fileId/permalinks",
@@ -865,9 +962,12 @@ The returned `url` is valid for 1 hour by default. You can change the
865
962
  schema: postFilesBulk_Body
866
963
  }
867
964
  ],
868
- response: z.union([
869
- z.array(
870
- z.object({
965
+ response: z.array(
966
+ z.object({
967
+ id: z.string(),
968
+ uploadUrl: z.string(),
969
+ expiresAt: z.string().datetime({ offset: true }),
970
+ metadata: z.object({
871
971
  id: z.string(),
872
972
  path: z.string(),
873
973
  workspaceId: z.string(),
@@ -882,29 +982,10 @@ The returned `url` is valid for 1 hour by default. You can change the
882
982
  createdAt: z.string(),
883
983
  deletedAt: z.union([z.string(), z.null()]).optional(),
884
984
  uploadedAt: z.union([z.string(), z.null()]).optional()
885
- })
886
- ),
887
- z.object({
888
- files: z.array(
889
- z.object({
890
- id: z.string(),
891
- path: z.string(),
892
- workspaceId: z.string(),
893
- parentId: z.union([z.string(), z.null()]).optional(),
894
- originalFileName: z.union([z.string(), z.null()]).optional(),
895
- mimeType: z.union([z.string(), z.null()]).optional(),
896
- size: z.union([z.number(), z.null()]).optional(),
897
- legacyKey: z.union([z.string(), z.null()]).optional(),
898
- bucketName: z.union([z.string(), z.null()]).optional(),
899
- encryptionKey: z.union([z.string(), z.null()]).optional(),
900
- createdBy: z.union([z.string(), z.null()]).optional(),
901
- createdAt: z.string(),
902
- deletedAt: z.union([z.string(), z.null()]).optional(),
903
- uploadedAt: z.union([z.string(), z.null()]).optional()
904
- })
905
- )
985
+ }),
986
+ path: z.string()
906
987
  })
907
- ])
988
+ )
908
989
  },
909
990
  {
910
991
  method: "get",
@@ -976,349 +1057,6 @@ Make sure to follow redirects to the actual file download URL.
976
1057
  schema: z.void()
977
1058
  }
978
1059
  ]
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
1060
  }
1323
1061
  ]);
1324
1062
  new Zodios(endpoints);
@@ -1326,16 +1064,22 @@ function createApiClient(baseUrl, options) {
1326
1064
  return new Zodios(baseUrl, endpoints, options);
1327
1065
  }
1328
1066
 
1067
+ const version = "2.14.0";
1068
+ const packageInfo = {
1069
+ version: version};
1070
+
1071
+ const serviceName = process.env.SERVICE_NAME;
1072
+ const userAgent = `vault-http-client:${packageInfo.version}${serviceName ? `@${serviceName}` : ""}`.trim();
1329
1073
  function useVaultClient(vaultUrl, token) {
1330
1074
  const api = createApiClient(vaultUrl, {
1331
1075
  axiosConfig: {
1332
1076
  headers: {
1333
1077
  "Authorization": token,
1334
- "User-Agent": "vault-http-client:2.9.0"
1078
+ "User-Agent": userAgent
1335
1079
  }
1336
1080
  }
1337
1081
  });
1338
1082
  return api;
1339
1083
  }
1340
1084
 
1341
- export { createApiClient, useVaultClient };
1085
+ export { useVaultClient };
package/package.json CHANGED
@@ -1,20 +1,26 @@
1
1
  {
2
- "name": "@meistrari/vault-http-client",
3
- "version": "2.9.0",
4
- "types": "dist/index.d.ts",
5
- "exports": {
6
- ".": {
7
- "types": "./dist/index.d.ts",
8
- "default": "./dist/index.mjs",
9
- "import": "./dist/index.mjs",
10
- "require": "./dist/index.cjs"
2
+ "name": "@meistrari/vault-http-client",
3
+ "version": "2.14.1",
4
+ "scripts": {
5
+ "build": "unbuild"
6
+ },
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.mjs",
12
+ "import": "./dist/index.mjs",
13
+ "require": "./dist/index.cjs"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "dependencies": {
20
+ "@zodios/core": "10.9.6",
21
+ "zod": "3.25.76"
22
+ },
23
+ "devDependencies": {
24
+ "unbuild": "3.6.1"
11
25
  }
12
- },
13
- "files": [
14
- "dist"
15
- ],
16
- "dependencies": {
17
- "@zodios/core": "10.9.6",
18
- "zod": "3.25.76"
19
- }
20
26
  }