@webiny/sdk 6.3.0-beta.4 → 6.4.0-beta.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/BaseError.js +8 -7
- package/BaseError.js.map +1 -1
- package/CmsSdk.js +34 -33
- package/CmsSdk.js.map +1 -1
- package/FileManagerSdk.js +50 -49
- package/FileManagerSdk.js.map +1 -1
- package/LanguagesSdk.js +10 -9
- package/LanguagesSdk.js.map +1 -1
- package/Result.js +40 -134
- package/Result.js.map +1 -1
- package/TasksSdk.js +26 -25
- package/TasksSdk.js.map +1 -1
- package/TenantManagerSdk.js +26 -25
- package/TenantManagerSdk.js.map +1 -1
- package/Webiny.js +24 -26
- package/Webiny.js.map +1 -1
- package/errors.js +31 -48
- package/errors.js.map +1 -1
- package/index.js +1 -21
- package/methods/cms/cmsTypes.js +0 -3
- package/methods/cms/createEntry.js +14 -39
- package/methods/cms/createEntry.js.map +1 -1
- package/methods/cms/deleteEntryRevision.js +12 -30
- package/methods/cms/deleteEntryRevision.js.map +1 -1
- package/methods/cms/getEntry.js +15 -36
- package/methods/cms/getEntry.js.map +1 -1
- package/methods/cms/listEntries.js +22 -51
- package/methods/cms/listEntries.js.map +1 -1
- package/methods/cms/publishEntryRevision.js +14 -33
- package/methods/cms/publishEntryRevision.js.map +1 -1
- package/methods/cms/schemas.js +39 -35
- package/methods/cms/schemas.js.map +1 -1
- package/methods/cms/unpublishEntryRevision.js +14 -33
- package/methods/cms/unpublishEntryRevision.js.map +1 -1
- package/methods/cms/updateEntryRevision.js +15 -42
- package/methods/cms/updateEntryRevision.js.map +1 -1
- package/methods/executeGraphQL.js +38 -41
- package/methods/executeGraphQL.js.map +1 -1
- package/methods/fileManager/buildFieldsSelection.js +25 -67
- package/methods/fileManager/buildFieldsSelection.js.map +1 -1
- package/methods/fileManager/completeMultiPartUpload.js +12 -29
- package/methods/fileManager/completeMultiPartUpload.js.map +1 -1
- package/methods/fileManager/createFile.js +61 -125
- package/methods/fileManager/createFile.js.map +1 -1
- package/methods/fileManager/createFiles.js +41 -76
- package/methods/fileManager/createFiles.js.map +1 -1
- package/methods/fileManager/createMultiPartUpload.js +12 -29
- package/methods/fileManager/createMultiPartUpload.js.map +1 -1
- package/methods/fileManager/deleteFile.js +11 -26
- package/methods/fileManager/deleteFile.js.map +1 -1
- package/methods/fileManager/fileManagerTypes.js +19 -18
- package/methods/fileManager/fileManagerTypes.js.map +1 -1
- package/methods/fileManager/getFile.js +15 -30
- package/methods/fileManager/getFile.js.map +1 -1
- package/methods/fileManager/getPresignedPostPayload.js +17 -40
- package/methods/fileManager/getPresignedPostPayload.js.map +1 -1
- package/methods/fileManager/getPresignedPostPayloads.js +17 -32
- package/methods/fileManager/getPresignedPostPayloads.js.map +1 -1
- package/methods/fileManager/listFiles.js +22 -45
- package/methods/fileManager/listFiles.js.map +1 -1
- package/methods/fileManager/listTags.js +11 -25
- package/methods/fileManager/listTags.js.map +1 -1
- package/methods/fileManager/schemas.js +15 -14
- package/methods/fileManager/schemas.js.map +1 -1
- package/methods/fileManager/updateFile.js +12 -29
- package/methods/fileManager/updateFile.js.map +1 -1
- package/methods/fileManager/utils/fileTypeDetection.js +10 -12
- package/methods/fileManager/utils/fileTypeDetection.js.map +1 -1
- package/methods/fileManager/utils/uploadLargeFile.js +86 -165
- package/methods/fileManager/utils/uploadLargeFile.js.map +1 -1
- package/methods/fileManager/utils/uploadToS3.js +41 -94
- package/methods/fileManager/utils/uploadToS3.js.map +1 -1
- package/methods/languages/listLanguages.js +8 -11
- package/methods/languages/listLanguages.js.map +1 -1
- package/methods/tasks/abortTask.js +11 -17
- package/methods/tasks/abortTask.js.map +1 -1
- package/methods/tasks/listDefinitions.js +8 -11
- package/methods/tasks/listDefinitions.js.map +1 -1
- package/methods/tasks/listLogs.js +10 -15
- package/methods/tasks/listLogs.js.map +1 -1
- package/methods/tasks/listTasks.js +8 -11
- package/methods/tasks/listTasks.js.map +1 -1
- package/methods/tasks/schemas.js +11 -10
- package/methods/tasks/schemas.js.map +1 -1
- package/methods/tasks/taskTypes.js +0 -3
- package/methods/tasks/triggerTask.js +11 -17
- package/methods/tasks/triggerTask.js.map +1 -1
- package/methods/tenantManager/createTenant.js +10 -24
- package/methods/tenantManager/createTenant.js.map +1 -1
- package/methods/tenantManager/disableTenant.js +10 -24
- package/methods/tenantManager/disableTenant.js.map +1 -1
- package/methods/tenantManager/enableTenant.js +10 -24
- package/methods/tenantManager/enableTenant.js.map +1 -1
- package/methods/tenantManager/getCurrentTenant.js +8 -18
- package/methods/tenantManager/getCurrentTenant.js.map +1 -1
- package/methods/tenantManager/installTenant.js +10 -24
- package/methods/tenantManager/installTenant.js.map +1 -1
- package/methods/tenantManager/schemas.js +13 -12
- package/methods/tenantManager/schemas.js.map +1 -1
- package/methods/tenantManager/tenantManagerTypes.js +0 -3
- package/package.json +5 -5
- package/types.js +0 -3
- package/utils/createMethod.js +6 -24
- package/utils/createMethod.js.map +1 -1
- package/utils/platform.js +3 -2
- package/utils/platform.js.map +1 -1
- package/utils/transformFieldErrors.js +14 -33
- package/utils/transformFieldErrors.js.map +1 -1
- package/utils/validateParams.js +13 -16
- package/utils/validateParams.js.map +1 -1
- package/index.js.map +0 -1
- package/methods/cms/cmsTypes.js.map +0 -1
- package/methods/tasks/taskTypes.js.map +0 -1
- package/methods/tenantManager/tenantManagerTypes.js.map +0 -1
- package/types.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"methods/fileManager/createFiles.js","sources":["../../../src/methods/fileManager/createFiles.ts"],"sourcesContent":["import type { WebinyConfig } from \"../../types.js\";\nimport { Result } from \"../../Result.js\";\nimport type { HttpError, ApiError, NetworkError } from \"../../errors.js\";\nimport type { FmFile, UploadProgress, BatchUploadStrategy } from \"./fileManagerTypes.js\";\nimport type { CreateFileData } from \"./createFile.js\";\nimport { createFile } from \"./createFile.js\";\nimport pMap from \"p-map\";\n\nexport interface CreateFilesParams {\n files: Array<{\n file?: Buffer | Blob | File;\n data: CreateFileData;\n fields: string[];\n onProgress?: (progress: UploadProgress) => void;\n }>;\n multiPartThreshold?: number;\n concurrency?: number;\n strategy?: BatchUploadStrategy;\n signal?: AbortSignal;\n}\n\nexport interface CreateFilesResult {\n successful: FmFile[];\n failed: Array<{\n data: CreateFileData;\n error: Error;\n }>;\n}\n\n/**\n * Creates multiple files in the file manager.\n * If files are provided, they will be uploaded to S3 first, then records are created.\n * If no files are provided, only metadata records are created.\n *\n * @param config - SDK configuration\n * @param fetchFn - Fetch function to use for HTTP requests\n * @param params - Parameters for creating the files\n * @param params.files - Array of files with their data\n * @param params.multiPartThreshold - Optional: Threshold in MB for multi-part upload (default: 100)\n * @param params.concurrency - Optional: Number of concurrent uploads (default: 5)\n * @param params.strategy - Optional: Batch upload strategy (default: FAIL_FAST)\n * @param params.signal - Optional: AbortSignal for cancellation\n * @returns Result containing the created files or an error\n */\n// Not using createMethod: params include File/Buffer/Blob entries and a BatchUploadStrategy callback.\nexport async function createFiles(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: CreateFilesParams\n): Promise<Result<CreateFilesResult, HttpError | ApiError | NetworkError>> {\n const {\n files,\n multiPartThreshold = 100,\n concurrency = 5,\n strategy = \"fail-fast\" as BatchUploadStrategy,\n signal\n } = params;\n\n const successful: FmFile[] = [];\n const failed: Array<{ data: CreateFileData; error: Error }> = [];\n\n // Use p-map for controlled concurrency.\n\n try {\n await pMap(\n files,\n async fileItem => {\n try {\n // Check abort signal.\n if (signal?.aborted) {\n throw new Error(\"Upload aborted\");\n }\n\n // Upload single file.\n const result = await createFile(config, fetchFn, {\n file: fileItem.file,\n data: fileItem.data,\n fields: fileItem.fields,\n onProgress: fileItem.onProgress,\n multiPartThreshold,\n signal\n });\n\n if (result.isOk()) {\n successful.push(result.value);\n } else {\n if (strategy === \"fail-fast\") {\n throw result.error;\n }\n failed.push({ data: fileItem.data, error: result.error as Error });\n }\n } catch (error) {\n if (strategy === \"fail-fast\") {\n throw error;\n }\n failed.push({ data: fileItem.data, error: error as Error });\n }\n },\n { concurrency }\n );\n\n return Result.ok({ successful, failed });\n } catch (error) {\n // Fail-fast: Return error immediately.\n return Result.fail(error as any);\n }\n}\n"],"names":["createFiles","config","fetchFn","params","files","multiPartThreshold","concurrency","strategy","signal","successful","failed","pMap","fileItem","Error","result","createFile","error","Result"],"mappings":";;;AA6CO,eAAeA,YAClBC,MAAoB,EACpBC,OAAqB,EACrBC,MAAyB;IAEzB,MAAM,EACFC,KAAK,EACLC,qBAAqB,GAAG,EACxBC,cAAc,CAAC,EACfC,WAAW,WAAkC,EAC7CC,MAAM,EACT,GAAGL;IAEJ,MAAMM,aAAuB,EAAE;IAC/B,MAAMC,SAAwD,EAAE;IAIhE,IAAI;QACA,MAAMC,MACFP,OACA,OAAMQ;YACF,IAAI;gBAEA,IAAIJ,QAAQ,SACR,MAAM,IAAIK,MAAM;gBAIpB,MAAMC,SAAS,MAAMC,WAAWd,QAAQC,SAAS;oBAC7C,MAAMU,SAAS,IAAI;oBACnB,MAAMA,SAAS,IAAI;oBACnB,QAAQA,SAAS,MAAM;oBACvB,YAAYA,SAAS,UAAU;oBAC/BP;oBACAG;gBACJ;gBAEA,IAAIM,OAAO,IAAI,IACXL,WAAW,IAAI,CAACK,OAAO,KAAK;qBACzB;oBACH,IAAIP,AAAa,gBAAbA,UACA,MAAMO,OAAO,KAAK;oBAEtBJ,OAAO,IAAI,CAAC;wBAAE,MAAME,SAAS,IAAI;wBAAE,OAAOE,OAAO,KAAK;oBAAU;gBACpE;YACJ,EAAE,OAAOE,OAAO;gBACZ,IAAIT,AAAa,gBAAbA,UACA,MAAMS;gBAEVN,OAAO,IAAI,CAAC;oBAAE,MAAME,SAAS,IAAI;oBAAE,OAAOI;gBAAe;YAC7D;QACJ,GACA;YAAEV;QAAY;QAGlB,OAAOW,OAAO,EAAE,CAAC;YAAER;YAAYC;QAAO;IAC1C,EAAE,OAAOM,OAAO;QAEZ,OAAOC,OAAO,IAAI,CAACD;IACvB;AACJ"}
|
|
@@ -1,23 +1,9 @@
|
|
|
1
1
|
import { Result } from "../../Result.js";
|
|
2
2
|
import { executeGraphQL } from "../executeGraphQL.js";
|
|
3
3
|
import { ApiError } from "../../errors.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* @param config - SDK configuration
|
|
8
|
-
* @param fetchFn - Fetch function to use for HTTP requests
|
|
9
|
-
* @param params - Parameters for creating the multi-part upload
|
|
10
|
-
* @param params.data - File metadata
|
|
11
|
-
* @param params.numberOfParts - Number of parts to split the file into
|
|
12
|
-
* @returns Result containing the multi-part upload data or an error
|
|
13
|
-
*/
|
|
14
|
-
// Not using createMethod: params include File/Buffer/Blob and an onProgress callback.
|
|
15
|
-
export async function createMultiPartUpload(config, fetchFn, params) {
|
|
16
|
-
const {
|
|
17
|
-
data,
|
|
18
|
-
numberOfParts
|
|
19
|
-
} = params;
|
|
20
|
-
const query = `
|
|
4
|
+
async function createMultiPartUpload(config, fetchFn, params) {
|
|
5
|
+
const { data, numberOfParts } = params;
|
|
6
|
+
const query = `
|
|
21
7
|
mutation CreateMultiPartUpload($data: PreSignedPostPayloadInput!, $numberOfParts: Number!) {
|
|
22
8
|
fileManager {
|
|
23
9
|
createMultiPartUpload(data: $data, numberOfParts: $numberOfParts) {
|
|
@@ -43,18 +29,15 @@ export async function createMultiPartUpload(config, fetchFn, params) {
|
|
|
43
29
|
}
|
|
44
30
|
}
|
|
45
31
|
`;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (responseData.fileManager.createMultiPartUpload.error) {
|
|
55
|
-
return Result.fail(new ApiError(responseData.fileManager.createMultiPartUpload.error.message, responseData.fileManager.createMultiPartUpload.error.code));
|
|
56
|
-
}
|
|
57
|
-
return Result.ok(responseData.fileManager.createMultiPartUpload.data);
|
|
32
|
+
const result = await executeGraphQL(config, fetchFn, query, {
|
|
33
|
+
data,
|
|
34
|
+
numberOfParts
|
|
35
|
+
});
|
|
36
|
+
if (result.isFail()) return Result.fail(result.error);
|
|
37
|
+
const responseData = result.value;
|
|
38
|
+
if (responseData.fileManager.createMultiPartUpload.error) return Result.fail(new ApiError(responseData.fileManager.createMultiPartUpload.error.message, responseData.fileManager.createMultiPartUpload.error.code));
|
|
39
|
+
return Result.ok(responseData.fileManager.createMultiPartUpload.data);
|
|
58
40
|
}
|
|
41
|
+
export { createMultiPartUpload };
|
|
59
42
|
|
|
60
43
|
//# sourceMappingURL=createMultiPartUpload.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"methods/fileManager/createMultiPartUpload.js","sources":["../../../src/methods/fileManager/createMultiPartUpload.ts"],"sourcesContent":["import type { WebinyConfig } from \"../../types.js\";\nimport { Result } from \"../../Result.js\";\nimport type { HttpError, NetworkError } from \"../../errors.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.js\";\n\nexport interface CreateMultiPartUploadParams {\n data: {\n name: string;\n type: string;\n size: number;\n key?: string;\n keyPrefix?: string;\n };\n numberOfParts: number;\n}\n\nexport interface MultiPartUploadResponse {\n uploadId: string;\n file: {\n id: string;\n name: string;\n type: string;\n size: number;\n key: string;\n };\n parts: Array<{\n partNumber: number;\n url: string;\n }>;\n}\n\n/**\n * Creates a multi-part upload for a large file.\n *\n * @param config - SDK configuration\n * @param fetchFn - Fetch function to use for HTTP requests\n * @param params - Parameters for creating the multi-part upload\n * @param params.data - File metadata\n * @param params.numberOfParts - Number of parts to split the file into\n * @returns Result containing the multi-part upload data or an error\n */\n// Not using createMethod: params include File/Buffer/Blob and an onProgress callback.\nexport async function createMultiPartUpload(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: CreateMultiPartUploadParams\n): Promise<Result<MultiPartUploadResponse, HttpError | ApiError | NetworkError>> {\n const { data, numberOfParts } = params;\n\n const query = `\n mutation CreateMultiPartUpload($data: PreSignedPostPayloadInput!, $numberOfParts: Number!) {\n fileManager {\n createMultiPartUpload(data: $data, numberOfParts: $numberOfParts) {\n data {\n uploadId\n file {\n id\n name\n type\n size\n key\n }\n parts {\n partNumber\n url\n }\n }\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, { data, numberOfParts });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.fileManager.createMultiPartUpload.error) {\n return Result.fail(\n new ApiError(\n responseData.fileManager.createMultiPartUpload.error.message,\n responseData.fileManager.createMultiPartUpload.error.code\n )\n );\n }\n\n return Result.ok(responseData.fileManager.createMultiPartUpload.data);\n}\n"],"names":["createMultiPartUpload","config","fetchFn","params","data","numberOfParts","query","result","executeGraphQL","Result","responseData","ApiError"],"mappings":";;;AA2CO,eAAeA,sBAClBC,MAAoB,EACpBC,OAAqB,EACrBC,MAAmC;IAEnC,MAAM,EAAEC,IAAI,EAAEC,aAAa,EAAE,GAAGF;IAEhC,MAAMG,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;IAyBf,CAAC;IAED,MAAMC,SAAS,MAAMC,eAAeP,QAAQC,SAASI,OAAO;QAAEF;QAAMC;IAAc;IAElF,IAAIE,OAAO,MAAM,IACb,OAAOE,OAAO,IAAI,CAACF,OAAO,KAAK;IAGnC,MAAMG,eAAeH,OAAO,KAAK;IAEjC,IAAIG,aAAa,WAAW,CAAC,qBAAqB,CAAC,KAAK,EACpD,OAAOD,OAAO,IAAI,CACd,IAAIE,SACAD,aAAa,WAAW,CAAC,qBAAqB,CAAC,KAAK,CAAC,OAAO,EAC5DA,aAAa,WAAW,CAAC,qBAAqB,CAAC,KAAK,CAAC,IAAI;IAKrE,OAAOD,OAAO,EAAE,CAACC,aAAa,WAAW,CAAC,qBAAqB,CAAC,IAAI;AACxE"}
|
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
import { Result } from "../../Result.js";
|
|
2
2
|
import { executeGraphQL } from "../executeGraphQL.js";
|
|
3
3
|
import { ApiError } from "../../errors.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* @param config - SDK configuration
|
|
8
|
-
* @param fetchFn - Fetch function to use for HTTP requests
|
|
9
|
-
* @param params - Parameters for deleting the file
|
|
10
|
-
* @param params.id - ID of the file to delete
|
|
11
|
-
* @returns Result containing true on success or an error
|
|
12
|
-
*/
|
|
13
|
-
// Not using createMethod: params are simple but no Zod schema exists; trivial to add if needed.
|
|
14
|
-
export async function deleteFile(config, fetchFn, params) {
|
|
15
|
-
const {
|
|
16
|
-
id
|
|
17
|
-
} = params;
|
|
18
|
-
const query = `
|
|
4
|
+
async function deleteFile(config, fetchFn, params) {
|
|
5
|
+
const { id } = params;
|
|
6
|
+
const query = `
|
|
19
7
|
mutation DeleteFile($id: ID!) {
|
|
20
8
|
fileManager {
|
|
21
9
|
deleteFile(id: $id) {
|
|
@@ -28,17 +16,14 @@ export async function deleteFile(config, fetchFn, params) {
|
|
|
28
16
|
}
|
|
29
17
|
}
|
|
30
18
|
`;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (responseData.fileManager.deleteFile.error) {
|
|
39
|
-
return Result.fail(new ApiError(responseData.fileManager.deleteFile.error.message, responseData.fileManager.deleteFile.error.code));
|
|
40
|
-
}
|
|
41
|
-
return Result.ok(responseData.fileManager.deleteFile.data);
|
|
19
|
+
const result = await executeGraphQL(config, fetchFn, query, {
|
|
20
|
+
id
|
|
21
|
+
});
|
|
22
|
+
if (result.isFail()) return Result.fail(result.error);
|
|
23
|
+
const responseData = result.value;
|
|
24
|
+
if (responseData.fileManager.deleteFile.error) return Result.fail(new ApiError(responseData.fileManager.deleteFile.error.message, responseData.fileManager.deleteFile.error.code));
|
|
25
|
+
return Result.ok(responseData.fileManager.deleteFile.data);
|
|
42
26
|
}
|
|
27
|
+
export { deleteFile };
|
|
43
28
|
|
|
44
29
|
//# sourceMappingURL=deleteFile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"methods/fileManager/deleteFile.js","sources":["../../../src/methods/fileManager/deleteFile.ts"],"sourcesContent":["import type { WebinyConfig } from \"../../types.js\";\nimport { Result } from \"../../Result.js\";\nimport type { HttpError, NetworkError } from \"../../errors.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.js\";\n\nexport interface DeleteFileParams {\n id: string;\n}\n\n/**\n * Deletes a file from the file manager.\n *\n * @param config - SDK configuration\n * @param fetchFn - Fetch function to use for HTTP requests\n * @param params - Parameters for deleting the file\n * @param params.id - ID of the file to delete\n * @returns Result containing true on success or an error\n */\n// Not using createMethod: params are simple but no Zod schema exists; trivial to add if needed.\nexport async function deleteFile(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: DeleteFileParams\n): Promise<Result<boolean, HttpError | ApiError | NetworkError>> {\n const { id } = params;\n\n const query = `\n mutation DeleteFile($id: ID!) {\n fileManager {\n deleteFile(id: $id) {\n data\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, { id });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.fileManager.deleteFile.error) {\n return Result.fail(\n new ApiError(\n responseData.fileManager.deleteFile.error.message,\n responseData.fileManager.deleteFile.error.code\n )\n );\n }\n\n return Result.ok(responseData.fileManager.deleteFile.data);\n}\n"],"names":["deleteFile","config","fetchFn","params","id","query","result","executeGraphQL","Result","responseData","ApiError"],"mappings":";;;AAoBO,eAAeA,WAClBC,MAAoB,EACpBC,OAAqB,EACrBC,MAAwB;IAExB,MAAM,EAAEC,EAAE,EAAE,GAAGD;IAEf,MAAME,QAAQ,CAAC;;;;;;;;;;;;IAYf,CAAC;IAED,MAAMC,SAAS,MAAMC,eAAeN,QAAQC,SAASG,OAAO;QAAED;IAAG;IAEjE,IAAIE,OAAO,MAAM,IACb,OAAOE,OAAO,IAAI,CAACF,OAAO,KAAK;IAGnC,MAAMG,eAAeH,OAAO,KAAK;IAEjC,IAAIG,aAAa,WAAW,CAAC,UAAU,CAAC,KAAK,EACzC,OAAOD,OAAO,IAAI,CACd,IAAIE,SACAD,aAAa,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,EACjDA,aAAa,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI;IAK1D,OAAOD,OAAO,EAAE,CAACC,aAAa,WAAW,CAAC,UAAU,CAAC,IAAI;AAC7D"}
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
var fileManagerTypes_FmFileListSorter = /*#__PURE__*/ function(FmFileListSorter) {
|
|
2
|
+
FmFileListSorter["SAVED_ON_ASC"] = "savedOn_ASC";
|
|
3
|
+
FmFileListSorter["SAVED_ON_DESC"] = "savedOn_DESC";
|
|
4
|
+
FmFileListSorter["CREATED_ON_ASC"] = "createdOn_ASC";
|
|
5
|
+
FmFileListSorter["CREATED_ON_DESC"] = "createdOn_DESC";
|
|
6
|
+
FmFileListSorter["NAME_ASC"] = "name_ASC";
|
|
7
|
+
FmFileListSorter["NAME_DESC"] = "name_DESC";
|
|
8
|
+
FmFileListSorter["KEY_ASC"] = "key_ASC";
|
|
9
|
+
FmFileListSorter["KEY_DESC"] = "key_DESC";
|
|
10
|
+
FmFileListSorter["TYPE_ASC"] = "type_ASC";
|
|
11
|
+
FmFileListSorter["TYPE_DESC"] = "type_DESC";
|
|
12
|
+
FmFileListSorter["SIZE_ASC"] = "size_ASC";
|
|
13
|
+
FmFileListSorter["SIZE_DESC"] = "size_DESC";
|
|
14
|
+
return FmFileListSorter;
|
|
15
15
|
}({});
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
var fileManagerTypes_BatchUploadStrategy = /*#__PURE__*/ function(BatchUploadStrategy) {
|
|
17
|
+
BatchUploadStrategy["FAIL_FAST"] = "fail-fast";
|
|
18
|
+
BatchUploadStrategy["CONTINUE"] = "continue";
|
|
19
|
+
return BatchUploadStrategy;
|
|
20
20
|
}({});
|
|
21
|
+
export { fileManagerTypes_BatchUploadStrategy as BatchUploadStrategy, fileManagerTypes_FmFileListSorter as FmFileListSorter };
|
|
21
22
|
|
|
22
23
|
//# sourceMappingURL=fileManagerTypes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"methods/fileManager/fileManagerTypes.js","sources":["../../../src/methods/fileManager/fileManagerTypes.ts"],"sourcesContent":["export interface FmIdentity {\n id: string;\n displayName: string;\n type: string;\n}\n\nexport interface FmLocation {\n folderId: string;\n}\n\nexport interface FmFile_Metadata {\n image?: {\n width?: number;\n height?: number;\n format?: string;\n orientation?: number;\n };\n exif?: Record<string, any>;\n iptc?: Record<string, any>;\n [key: string]: any;\n}\n\nexport type FmFile_AccessControl = {\n type: \"public\" | \"private-authenticated\";\n};\n\nexport interface FmFile {\n id: string;\n createdOn: Date | string;\n modifiedOn?: Date | string;\n savedOn: Date | string;\n createdBy: FmIdentity;\n modifiedBy?: FmIdentity;\n savedBy: FmIdentity;\n location: FmLocation;\n src: string;\n name: string;\n key: string;\n type: string;\n size: number;\n metadata: FmFile_Metadata;\n tags: string[];\n accessControl?: FmFile_AccessControl;\n [key: string]: any;\n}\n\nexport interface FmTag {\n tag: string;\n count: number;\n}\n\nexport interface FmListMeta {\n cursor: string | null;\n hasMoreItems: boolean;\n totalCount: number;\n}\n\nexport interface FmLocationInput {\n folderId: string;\n}\n\nexport interface FmLocationWhereInput {\n folderId?: string;\n folderId_in?: string[];\n folderId_not?: string;\n folderId_not_in?: string[];\n}\n\nexport interface FmFileListWhereInput {\n location?: FmLocationWhereInput;\n name?: string;\n name_contains?: string;\n name_not_contains?: string;\n type?: string;\n type_in?: string[];\n type_not?: string;\n type_not_in?: string[];\n tags?: string[];\n tags_in?: string[];\n tags_not?: string;\n tags_not_in?: string[];\n AND?: FmFileListWhereInput[];\n OR?: FmFileListWhereInput[];\n}\n\nexport enum FmFileListSorter {\n SAVED_ON_ASC = \"savedOn_ASC\",\n SAVED_ON_DESC = \"savedOn_DESC\",\n CREATED_ON_ASC = \"createdOn_ASC\",\n CREATED_ON_DESC = \"createdOn_DESC\",\n NAME_ASC = \"name_ASC\",\n NAME_DESC = \"name_DESC\",\n KEY_ASC = \"key_ASC\",\n KEY_DESC = \"key_DESC\",\n TYPE_ASC = \"type_ASC\",\n TYPE_DESC = \"type_DESC\",\n SIZE_ASC = \"size_ASC\",\n SIZE_DESC = \"size_DESC\"\n}\n\nexport interface FmTagsListWhereInput {\n createdBy?: string;\n tags_startsWith?: string;\n tags_not_startsWith?: string;\n}\n\nexport interface UploadProgress {\n sent: number;\n total: number;\n percentage: number;\n}\n\nexport interface PresignedPostPayload {\n url: string;\n fields: Record<string, string>;\n}\n\nexport interface PresignedPostPayloadResponse {\n data: PresignedPostPayload;\n file: {\n id: string;\n name: string;\n type: string;\n size: number;\n key: string;\n };\n}\n\nexport enum BatchUploadStrategy {\n FAIL_FAST = \"fail-fast\",\n CONTINUE = \"continue\"\n}\n"],"names":["FmFileListSorter","BatchUploadStrategy"],"mappings":"AAqFO,IAAKA,oCAAgBA,WAAAA,GAAAA,SAAhBA,gBAAgB;;;;;;;;;;;;;WAAhBA;;AA2CL,IAAKC,uCAAmBA,WAAAA,GAAAA,SAAnBA,mBAAmB;;;WAAnBA"}
|
|
@@ -5,22 +5,10 @@ import { createMethod } from "../../utils/createMethod.js";
|
|
|
5
5
|
import { getFileSchema } from "./schemas.js";
|
|
6
6
|
import { executeGraphQL } from "../executeGraphQL.js";
|
|
7
7
|
import { ApiError } from "../../errors.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* @param fetchFn - Fetch function to use for HTTP requests
|
|
13
|
-
* @param params - Parameters for getting the file
|
|
14
|
-
* @param params.id - ID of the file to get
|
|
15
|
-
* @returns Result containing the file data or an error
|
|
16
|
-
*/
|
|
17
|
-
export const getFile = createMethod(getFileSchema, async (config, fetchFn, params) => {
|
|
18
|
-
const {
|
|
19
|
-
id,
|
|
20
|
-
fields
|
|
21
|
-
} = params;
|
|
22
|
-
const fieldsSelection = buildFieldsSelection(fields);
|
|
23
|
-
const query = `
|
|
8
|
+
const getFile = createMethod(getFileSchema, async (config, fetchFn, params)=>{
|
|
9
|
+
const { id, fields } = params;
|
|
10
|
+
const fieldsSelection = buildFieldsSelection(fields);
|
|
11
|
+
const query = `
|
|
24
12
|
query GetFile($id: ID!) {
|
|
25
13
|
fileManager {
|
|
26
14
|
getFile(id: $id) {
|
|
@@ -35,21 +23,18 @@ ${fieldsSelection}
|
|
|
35
23
|
}
|
|
36
24
|
}
|
|
37
25
|
`;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
26
|
+
const result = await executeGraphQL(config, fetchFn, query, {
|
|
27
|
+
id
|
|
28
|
+
});
|
|
29
|
+
if (result.isFail()) {
|
|
30
|
+
const error = result.error;
|
|
31
|
+
if (error instanceof ApiError) return Result.fail(new ApiError(transformFieldErrors(error.message, fields), error.data?.code));
|
|
32
|
+
return Result.fail(error);
|
|
45
33
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (responseData.fileManager.getFile.error) {
|
|
50
|
-
return Result.fail(new ApiError(responseData.fileManager.getFile.error.message, responseData.fileManager.getFile.error.code));
|
|
51
|
-
}
|
|
52
|
-
return Result.ok(responseData.fileManager.getFile.data);
|
|
34
|
+
const responseData = result.value;
|
|
35
|
+
if (responseData.fileManager.getFile.error) return Result.fail(new ApiError(responseData.fileManager.getFile.error.message, responseData.fileManager.getFile.error.code));
|
|
36
|
+
return Result.ok(responseData.fileManager.getFile.data);
|
|
53
37
|
});
|
|
38
|
+
export { getFile };
|
|
54
39
|
|
|
55
40
|
//# sourceMappingURL=getFile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"methods/fileManager/getFile.js","sources":["../../../src/methods/fileManager/getFile.ts"],"sourcesContent":["import { Result } from \"../../Result.js\";\nimport type { HttpError, NetworkError } from \"../../errors.js\";\nimport type { FmFile } from \"./fileManagerTypes.js\";\nimport { buildFieldsSelection } from \"./buildFieldsSelection.js\";\nimport { transformFieldErrors } from \"../../utils/transformFieldErrors.js\";\nimport { createMethod } from \"../../utils/createMethod.js\";\nimport { getFileSchema } from \"./schemas.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.js\";\n\nexport interface GetFileParams {\n id: string;\n fields: string[];\n}\n\n/**\n * Gets a single file from the file manager.\n *\n * @param config - SDK configuration\n * @param fetchFn - Fetch function to use for HTTP requests\n * @param params - Parameters for getting the file\n * @param params.id - ID of the file to get\n * @returns Result containing the file data or an error\n */\nexport const getFile = createMethod(\n getFileSchema,\n async (\n config,\n fetchFn,\n params\n ): Promise<Result<FmFile, HttpError | ApiError | NetworkError>> => {\n const { id, fields } = params;\n\n const fieldsSelection = buildFieldsSelection(fields);\n\n const query = `\n query GetFile($id: ID!) {\n fileManager {\n getFile(id: $id) {\n data {\n${fieldsSelection}\n }\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, { id });\n\n if (result.isFail()) {\n const error = result.error;\n if (error instanceof ApiError) {\n return Result.fail(\n new ApiError(transformFieldErrors(error.message, fields), error.data?.code)\n );\n }\n return Result.fail(error);\n }\n\n const responseData = result.value;\n\n if (responseData.fileManager.getFile.error) {\n return Result.fail(\n new ApiError(\n responseData.fileManager.getFile.error.message,\n responseData.fileManager.getFile.error.code\n )\n );\n }\n\n return Result.ok(responseData.fileManager.getFile.data as FmFile);\n }\n);\n"],"names":["getFile","createMethod","getFileSchema","config","fetchFn","params","id","fields","fieldsSelection","buildFieldsSelection","query","result","executeGraphQL","error","ApiError","Result","transformFieldErrors","responseData"],"mappings":";;;;;;;AAwBO,MAAMA,UAAUC,aACnBC,eACA,OACIC,QACAC,SACAC;IAEA,MAAM,EAAEC,EAAE,EAAEC,MAAM,EAAE,GAAGF;IAEvB,MAAMG,kBAAkBC,qBAAqBF;IAE7C,MAAMG,QAAQ,CAAC;;;;;AAKvB,EAAEF,gBAAgB;;;;;;;;;IASd,CAAC;IAEG,MAAMG,SAAS,MAAMC,eAAeT,QAAQC,SAASM,OAAO;QAAEJ;IAAG;IAEjE,IAAIK,OAAO,MAAM,IAAI;QACjB,MAAME,QAAQF,OAAO,KAAK;QAC1B,IAAIE,iBAAiBC,UACjB,OAAOC,OAAO,IAAI,CACd,IAAID,SAASE,qBAAqBH,MAAM,OAAO,EAAEN,SAASM,MAAM,IAAI,EAAE;QAG9E,OAAOE,OAAO,IAAI,CAACF;IACvB;IAEA,MAAMI,eAAeN,OAAO,KAAK;IAEjC,IAAIM,aAAa,WAAW,CAAC,OAAO,CAAC,KAAK,EACtC,OAAOF,OAAO,IAAI,CACd,IAAID,SACAG,aAAa,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAC9CA,aAAa,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI;IAKvD,OAAOF,OAAO,EAAE,CAACE,aAAa,WAAW,CAAC,OAAO,CAAC,IAAI;AAC1D"}
|
|
@@ -1,29 +1,9 @@
|
|
|
1
1
|
import { Result } from "../../Result.js";
|
|
2
2
|
import { executeGraphQL } from "../executeGraphQL.js";
|
|
3
3
|
import { ApiError } from "../../errors.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* @param config - SDK configuration
|
|
8
|
-
* @param fetchFn - Fetch function to use for HTTP requests
|
|
9
|
-
* @param params - Parameters for getting the presigned POST payload
|
|
10
|
-
* @param params.name - File name
|
|
11
|
-
* @param params.type - File MIME type
|
|
12
|
-
* @param params.size - File size in bytes
|
|
13
|
-
* @param params.key - Optional custom S3 key
|
|
14
|
-
* @param params.keyPrefix - Optional custom key prefix
|
|
15
|
-
* @returns Result containing the presigned POST payload or an error
|
|
16
|
-
*/
|
|
17
|
-
// Not using createMethod: simple params, no Zod schema defined for this method.
|
|
18
|
-
export async function getPresignedPostPayload(config, fetchFn, params) {
|
|
19
|
-
const {
|
|
20
|
-
name,
|
|
21
|
-
type,
|
|
22
|
-
size,
|
|
23
|
-
key,
|
|
24
|
-
keyPrefix
|
|
25
|
-
} = params;
|
|
26
|
-
const query = `
|
|
4
|
+
async function getPresignedPostPayload(config, fetchFn, params) {
|
|
5
|
+
const { name, type, size, key, keyPrefix } = params;
|
|
6
|
+
const query = `
|
|
27
7
|
query GetPreSignedPostPayload($data: PreSignedPostPayloadInput!) {
|
|
28
8
|
fileManager {
|
|
29
9
|
getPreSignedPostPayload(data: $data) {
|
|
@@ -45,23 +25,20 @@ export async function getPresignedPostPayload(config, fetchFn, params) {
|
|
|
45
25
|
}
|
|
46
26
|
}
|
|
47
27
|
`;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (responseData.fileManager.getPreSignedPostPayload.error) {
|
|
62
|
-
return Result.fail(new ApiError(responseData.fileManager.getPreSignedPostPayload.error.message, responseData.fileManager.getPreSignedPostPayload.error.code));
|
|
63
|
-
}
|
|
64
|
-
return Result.ok(responseData.fileManager.getPreSignedPostPayload.data);
|
|
28
|
+
const result = await executeGraphQL(config, fetchFn, query, {
|
|
29
|
+
data: {
|
|
30
|
+
name,
|
|
31
|
+
type,
|
|
32
|
+
size,
|
|
33
|
+
key,
|
|
34
|
+
keyPrefix
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
if (result.isFail()) return Result.fail(result.error);
|
|
38
|
+
const responseData = result.value;
|
|
39
|
+
if (responseData.fileManager.getPreSignedPostPayload.error) return Result.fail(new ApiError(responseData.fileManager.getPreSignedPostPayload.error.message, responseData.fileManager.getPreSignedPostPayload.error.code));
|
|
40
|
+
return Result.ok(responseData.fileManager.getPreSignedPostPayload.data);
|
|
65
41
|
}
|
|
42
|
+
export { getPresignedPostPayload };
|
|
66
43
|
|
|
67
44
|
//# sourceMappingURL=getPresignedPostPayload.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"methods/fileManager/getPresignedPostPayload.js","sources":["../../../src/methods/fileManager/getPresignedPostPayload.ts"],"sourcesContent":["import type { WebinyConfig } from \"../../types.js\";\nimport { Result } from \"../../Result.js\";\nimport type { HttpError, NetworkError } from \"../../errors.js\";\nimport type { PresignedPostPayloadResponse } from \"./fileManagerTypes.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.js\";\n\nexport interface GetPresignedPostPayloadParams {\n name: string;\n type: string;\n size: number;\n key?: string;\n keyPrefix?: string;\n}\n\n/**\n * Gets a presigned POST payload for uploading a file to S3.\n *\n * @param config - SDK configuration\n * @param fetchFn - Fetch function to use for HTTP requests\n * @param params - Parameters for getting the presigned POST payload\n * @param params.name - File name\n * @param params.type - File MIME type\n * @param params.size - File size in bytes\n * @param params.key - Optional custom S3 key\n * @param params.keyPrefix - Optional custom key prefix\n * @returns Result containing the presigned POST payload or an error\n */\n// Not using createMethod: simple params, no Zod schema defined for this method.\nexport async function getPresignedPostPayload(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: GetPresignedPostPayloadParams\n): Promise<Result<PresignedPostPayloadResponse, HttpError | ApiError | NetworkError>> {\n const { name, type, size, key, keyPrefix } = params;\n\n const query = `\n query GetPreSignedPostPayload($data: PreSignedPostPayloadInput!) {\n fileManager {\n getPreSignedPostPayload(data: $data) {\n data {\n data\n file {\n id\n name\n type\n size\n key\n }\n }\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, {\n data: { name, type, size, key, keyPrefix }\n });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.fileManager.getPreSignedPostPayload.error) {\n return Result.fail(\n new ApiError(\n responseData.fileManager.getPreSignedPostPayload.error.message,\n responseData.fileManager.getPreSignedPostPayload.error.code\n )\n );\n }\n\n return Result.ok(responseData.fileManager.getPreSignedPostPayload.data);\n}\n"],"names":["getPresignedPostPayload","config","fetchFn","params","name","type","size","key","keyPrefix","query","result","executeGraphQL","Result","responseData","ApiError"],"mappings":";;;AA6BO,eAAeA,wBAClBC,MAAoB,EACpBC,OAAqB,EACrBC,MAAqC;IAErC,MAAM,EAAEC,IAAI,EAAEC,IAAI,EAAEC,IAAI,EAAEC,GAAG,EAAEC,SAAS,EAAE,GAAGL;IAE7C,MAAMM,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;IAqBf,CAAC;IAED,MAAMC,SAAS,MAAMC,eAAeV,QAAQC,SAASO,OAAO;QACxD,MAAM;YAAEL;YAAMC;YAAMC;YAAMC;YAAKC;QAAU;IAC7C;IAEA,IAAIE,OAAO,MAAM,IACb,OAAOE,OAAO,IAAI,CAACF,OAAO,KAAK;IAGnC,MAAMG,eAAeH,OAAO,KAAK;IAEjC,IAAIG,aAAa,WAAW,CAAC,uBAAuB,CAAC,KAAK,EACtD,OAAOD,OAAO,IAAI,CACd,IAAIE,SACAD,aAAa,WAAW,CAAC,uBAAuB,CAAC,KAAK,CAAC,OAAO,EAC9DA,aAAa,WAAW,CAAC,uBAAuB,CAAC,KAAK,CAAC,IAAI;IAKvE,OAAOD,OAAO,EAAE,CAACC,aAAa,WAAW,CAAC,uBAAuB,CAAC,IAAI;AAC1E"}
|
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
import { Result } from "../../Result.js";
|
|
2
2
|
import { executeGraphQL } from "../executeGraphQL.js";
|
|
3
3
|
import { ApiError } from "../../errors.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* @param config - SDK configuration
|
|
8
|
-
* @param fetchFn - Fetch function to use for HTTP requests
|
|
9
|
-
* @param params - Parameters for getting the presigned POST payloads
|
|
10
|
-
* @param params.files - Array of file metadata for which to get presigned POST payloads
|
|
11
|
-
* @returns Result containing the presigned POST payloads or an error
|
|
12
|
-
*/
|
|
13
|
-
// Not using createMethod: simple params, no Zod schema defined for this method.
|
|
14
|
-
export async function getPresignedPostPayloads(config, fetchFn, params) {
|
|
15
|
-
const {
|
|
16
|
-
files
|
|
17
|
-
} = params;
|
|
18
|
-
const query = `
|
|
4
|
+
async function getPresignedPostPayloads(config, fetchFn, params) {
|
|
5
|
+
const { files } = params;
|
|
6
|
+
const query = `
|
|
19
7
|
query GetPreSignedPostPayloads($data: [PreSignedPostPayloadInput]!) {
|
|
20
8
|
fileManager {
|
|
21
9
|
getPreSignedPostPayloads(data: $data) {
|
|
@@ -37,23 +25,20 @@ export async function getPresignedPostPayloads(config, fetchFn, params) {
|
|
|
37
25
|
}
|
|
38
26
|
}
|
|
39
27
|
`;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (responseData.fileManager.getPreSignedPostPayloads.error) {
|
|
54
|
-
return Result.fail(new ApiError(responseData.fileManager.getPreSignedPostPayloads.error.message, responseData.fileManager.getPreSignedPostPayloads.error.code));
|
|
55
|
-
}
|
|
56
|
-
return Result.ok(responseData.fileManager.getPreSignedPostPayloads.data);
|
|
28
|
+
const result = await executeGraphQL(config, fetchFn, query, {
|
|
29
|
+
data: files.map((f)=>({
|
|
30
|
+
name: f.name,
|
|
31
|
+
type: f.type,
|
|
32
|
+
size: f.size,
|
|
33
|
+
key: f.key,
|
|
34
|
+
keyPrefix: f.keyPrefix
|
|
35
|
+
}))
|
|
36
|
+
});
|
|
37
|
+
if (result.isFail()) return Result.fail(result.error);
|
|
38
|
+
const responseData = result.value;
|
|
39
|
+
if (responseData.fileManager.getPreSignedPostPayloads.error) return Result.fail(new ApiError(responseData.fileManager.getPreSignedPostPayloads.error.message, responseData.fileManager.getPreSignedPostPayloads.error.code));
|
|
40
|
+
return Result.ok(responseData.fileManager.getPreSignedPostPayloads.data);
|
|
57
41
|
}
|
|
42
|
+
export { getPresignedPostPayloads };
|
|
58
43
|
|
|
59
44
|
//# sourceMappingURL=getPresignedPostPayloads.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"methods/fileManager/getPresignedPostPayloads.js","sources":["../../../src/methods/fileManager/getPresignedPostPayloads.ts"],"sourcesContent":["import type { WebinyConfig } from \"../../types.js\";\nimport { Result } from \"../../Result.js\";\nimport type { HttpError, NetworkError } from \"../../errors.js\";\nimport type { PresignedPostPayloadResponse } from \"./fileManagerTypes.js\";\nimport type { GetPresignedPostPayloadParams } from \"./getPresignedPostPayload.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.js\";\n\nexport interface GetPresignedPostPayloadsParams {\n files: GetPresignedPostPayloadParams[];\n}\n\n/**\n * Gets presigned POST payloads for uploading multiple files to S3.\n *\n * @param config - SDK configuration\n * @param fetchFn - Fetch function to use for HTTP requests\n * @param params - Parameters for getting the presigned POST payloads\n * @param params.files - Array of file metadata for which to get presigned POST payloads\n * @returns Result containing the presigned POST payloads or an error\n */\n// Not using createMethod: simple params, no Zod schema defined for this method.\nexport async function getPresignedPostPayloads(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: GetPresignedPostPayloadsParams\n): Promise<Result<PresignedPostPayloadResponse[], HttpError | ApiError | NetworkError>> {\n const { files } = params;\n\n const query = `\n query GetPreSignedPostPayloads($data: [PreSignedPostPayloadInput]!) {\n fileManager {\n getPreSignedPostPayloads(data: $data) {\n data {\n data\n file {\n id\n name\n type\n size\n key\n }\n }\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, {\n data: files.map(f => ({\n name: f.name,\n type: f.type,\n size: f.size,\n key: f.key,\n keyPrefix: f.keyPrefix\n }))\n });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.fileManager.getPreSignedPostPayloads.error) {\n return Result.fail(\n new ApiError(\n responseData.fileManager.getPreSignedPostPayloads.error.message,\n responseData.fileManager.getPreSignedPostPayloads.error.code\n )\n );\n }\n\n return Result.ok(responseData.fileManager.getPreSignedPostPayloads.data);\n}\n"],"names":["getPresignedPostPayloads","config","fetchFn","params","files","query","result","executeGraphQL","f","Result","responseData","ApiError"],"mappings":";;;AAsBO,eAAeA,yBAClBC,MAAoB,EACpBC,OAAqB,EACrBC,MAAsC;IAEtC,MAAM,EAAEC,KAAK,EAAE,GAAGD;IAElB,MAAME,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;IAqBf,CAAC;IAED,MAAMC,SAAS,MAAMC,eAAeN,QAAQC,SAASG,OAAO;QACxD,MAAMD,MAAM,GAAG,CAACI,CAAAA,IAAM;gBAClB,MAAMA,EAAE,IAAI;gBACZ,MAAMA,EAAE,IAAI;gBACZ,MAAMA,EAAE,IAAI;gBACZ,KAAKA,EAAE,GAAG;gBACV,WAAWA,EAAE,SAAS;YAC1B;IACJ;IAEA,IAAIF,OAAO,MAAM,IACb,OAAOG,OAAO,IAAI,CAACH,OAAO,KAAK;IAGnC,MAAMI,eAAeJ,OAAO,KAAK;IAEjC,IAAII,aAAa,WAAW,CAAC,wBAAwB,CAAC,KAAK,EACvD,OAAOD,OAAO,IAAI,CACd,IAAIE,SACAD,aAAa,WAAW,CAAC,wBAAwB,CAAC,KAAK,CAAC,OAAO,EAC/DA,aAAa,WAAW,CAAC,wBAAwB,CAAC,KAAK,CAAC,IAAI;IAKxE,OAAOD,OAAO,EAAE,CAACC,aAAa,WAAW,CAAC,wBAAwB,CAAC,IAAI;AAC3E"}
|
|
@@ -5,30 +5,10 @@ import { createMethod } from "../../utils/createMethod.js";
|
|
|
5
5
|
import { listFilesSchema } from "./schemas.js";
|
|
6
6
|
import { executeGraphQL } from "../executeGraphQL.js";
|
|
7
7
|
import { ApiError } from "../../errors.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* @param fetchFn - Fetch function to use for HTTP requests
|
|
13
|
-
* @param params - Parameters for listing files
|
|
14
|
-
* @param params.search - Search query
|
|
15
|
-
* @param params.where - Filter conditions
|
|
16
|
-
* @param params.limit - Maximum number of items to return
|
|
17
|
-
* @param params.after - Cursor for pagination
|
|
18
|
-
* @param params.sort - Sort order
|
|
19
|
-
* @returns Result containing the list of files or an error
|
|
20
|
-
*/
|
|
21
|
-
export const listFiles = createMethod(listFilesSchema, async (config, fetchFn, params) => {
|
|
22
|
-
const {
|
|
23
|
-
search,
|
|
24
|
-
where,
|
|
25
|
-
limit,
|
|
26
|
-
after,
|
|
27
|
-
sort,
|
|
28
|
-
fields
|
|
29
|
-
} = params;
|
|
30
|
-
const fieldsSelection = buildFieldsSelection(fields);
|
|
31
|
-
const query = `
|
|
8
|
+
const listFiles = createMethod(listFilesSchema, async (config, fetchFn, params)=>{
|
|
9
|
+
const { search, where, limit, after, sort, fields } = params;
|
|
10
|
+
const fieldsSelection = buildFieldsSelection(fields);
|
|
11
|
+
const query = `
|
|
32
12
|
query ListFiles($search: String, $where: FmFileListWhereInput, $limit: Int, $after: String, $sort: [FmFileListSorter!]) {
|
|
33
13
|
fileManager {
|
|
34
14
|
listFiles(search: $search, where: $where, limit: $limit, after: $after, sort: $sort) {
|
|
@@ -48,28 +28,25 @@ ${fieldsSelection}
|
|
|
48
28
|
}
|
|
49
29
|
}
|
|
50
30
|
`;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
31
|
+
const result = await executeGraphQL(config, fetchFn, query, {
|
|
32
|
+
search,
|
|
33
|
+
where,
|
|
34
|
+
limit,
|
|
35
|
+
after,
|
|
36
|
+
sort
|
|
37
|
+
});
|
|
38
|
+
if (result.isFail()) {
|
|
39
|
+
const error = result.error;
|
|
40
|
+
if (error instanceof ApiError) return Result.fail(new ApiError(transformFieldErrors(error.message, fields), error.data?.code));
|
|
41
|
+
return Result.fail(error);
|
|
62
42
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return Result.ok({
|
|
70
|
-
data: responseData.fileManager.listFiles.data,
|
|
71
|
-
meta: responseData.fileManager.listFiles.meta
|
|
72
|
-
});
|
|
43
|
+
const responseData = result.value;
|
|
44
|
+
if (responseData.fileManager.listFiles.error) return Result.fail(new ApiError(responseData.fileManager.listFiles.error.message, responseData.fileManager.listFiles.error.code));
|
|
45
|
+
return Result.ok({
|
|
46
|
+
data: responseData.fileManager.listFiles.data,
|
|
47
|
+
meta: responseData.fileManager.listFiles.meta
|
|
48
|
+
});
|
|
73
49
|
});
|
|
50
|
+
export { listFiles };
|
|
74
51
|
|
|
75
52
|
//# sourceMappingURL=listFiles.js.map
|