@webiny/sdk 6.3.0 → 6.4.0-beta.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/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/WebhooksSdk.d.ts +35 -0
- package/WebhooksSdk.js +49 -0
- package/WebhooksSdk.js.map +1 -0
- package/Webiny.d.ts +2 -0
- package/Webiny.js +29 -26
- package/Webiny.js.map +1 -1
- package/errors.js +31 -48
- package/errors.js.map +1 -1
- package/index.d.ts +11 -0
- package/index.js +2 -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/methods/webhooks/createWebhook.d.ts +12 -0
- package/methods/webhooks/createWebhook.js +41 -0
- package/methods/webhooks/createWebhook.js.map +1 -0
- package/methods/webhooks/deleteWebhook.d.ts +6 -0
- package/methods/webhooks/deleteWebhook.js +30 -0
- package/methods/webhooks/deleteWebhook.js.map +1 -0
- package/methods/webhooks/getWebhook.d.ts +7 -0
- package/methods/webhooks/getWebhook.js +41 -0
- package/methods/webhooks/getWebhook.js.map +1 -0
- package/methods/webhooks/getWebhookDelivery.d.ts +7 -0
- package/methods/webhooks/getWebhookDelivery.js +43 -0
- package/methods/webhooks/getWebhookDelivery.js.map +1 -0
- package/methods/webhooks/listAvailableWebhookEvents.d.ts +7 -0
- package/methods/webhooks/listAvailableWebhookEvents.js +31 -0
- package/methods/webhooks/listAvailableWebhookEvents.js.map +1 -0
- package/methods/webhooks/listWebhookDeliveries.d.ts +17 -0
- package/methods/webhooks/listWebhookDeliveries.js +53 -0
- package/methods/webhooks/listWebhookDeliveries.js.map +1 -0
- package/methods/webhooks/listWebhooks.d.ts +19 -0
- package/methods/webhooks/listWebhooks.js +51 -0
- package/methods/webhooks/listWebhooks.js.map +1 -0
- package/methods/webhooks/resendWebhookDelivery.d.ts +6 -0
- package/methods/webhooks/resendWebhookDelivery.js +30 -0
- package/methods/webhooks/resendWebhookDelivery.js.map +1 -0
- package/methods/webhooks/schemas.d.ts +46 -0
- package/methods/webhooks/schemas.js +50 -0
- package/methods/webhooks/schemas.js.map +1 -0
- package/methods/webhooks/triggerWebhook.d.ts +8 -0
- package/methods/webhooks/triggerWebhook.js +44 -0
- package/methods/webhooks/triggerWebhook.js.map +1 -0
- package/methods/webhooks/updateWebhook.d.ts +13 -0
- package/methods/webhooks/updateWebhook.js +42 -0
- package/methods/webhooks/updateWebhook.js.map +1 -0
- package/methods/webhooks/webhooksTypes.d.ts +32 -0
- package/methods/webhooks/webhooksTypes.js +0 -0
- 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,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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"methods/fileManager/listFiles.js","sources":["../../../src/methods/fileManager/listFiles.ts"],"sourcesContent":["import { Result } from \"../../Result.js\";\nimport type { HttpError, NetworkError } from \"../../errors.js\";\nimport type {\n FmFile,\n FmFileListWhereInput,\n FmFileListSorter,\n FmListMeta\n} from \"./fileManagerTypes.js\";\nimport { buildFieldsSelection } from \"./buildFieldsSelection.js\";\nimport { transformFieldErrors } from \"../../utils/transformFieldErrors.js\";\nimport { createMethod } from \"../../utils/createMethod.js\";\nimport { listFilesSchema } from \"./schemas.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.js\";\n\nexport interface ListFilesParams {\n search?: string;\n where?: FmFileListWhereInput;\n limit?: number;\n after?: string;\n sort?: FmFileListSorter[];\n fields: string[];\n}\n\nexport interface ListFilesResult {\n data: FmFile[];\n meta: FmListMeta;\n}\n\n/**\n * Lists files 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 listing files\n * @param params.search - Search query\n * @param params.where - Filter conditions\n * @param params.limit - Maximum number of items to return\n * @param params.after - Cursor for pagination\n * @param params.sort - Sort order\n * @returns Result containing the list of files or an error\n */\nexport const listFiles = createMethod(\n listFilesSchema,\n async (\n config,\n fetchFn,\n params\n ): Promise<Result<ListFilesResult, HttpError | ApiError | NetworkError>> => {\n const { search, where, limit, after, sort, fields } = params;\n\n const fieldsSelection = buildFieldsSelection(fields);\n\n const query = `\n query ListFiles($search: String, $where: FmFileListWhereInput, $limit: Int, $after: String, $sort: [FmFileListSorter!]) {\n fileManager {\n listFiles(search: $search, where: $where, limit: $limit, after: $after, sort: $sort) {\n data {\n${fieldsSelection}\n }\n meta {\n cursor\n hasMoreItems\n totalCount\n }\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, {\n search,\n where,\n limit,\n after,\n sort\n });\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.listFiles.error) {\n return Result.fail(\n new ApiError(\n responseData.fileManager.listFiles.error.message,\n responseData.fileManager.listFiles.error.code\n )\n );\n }\n\n return Result.ok({\n data: responseData.fileManager.listFiles.data as FmFile[],\n meta: responseData.fileManager.listFiles.meta as FmListMeta\n });\n }\n);\n"],"names":["listFiles","createMethod","listFilesSchema","config","fetchFn","params","search","where","limit","after","sort","fields","fieldsSelection","buildFieldsSelection","query","result","executeGraphQL","error","ApiError","Result","transformFieldErrors","responseData"],"mappings":";;;;;;;AA0CO,MAAMA,YAAYC,aACrBC,iBACA,OACIC,QACAC,SACAC;IAEA,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEC,KAAK,EAAEC,IAAI,EAAEC,MAAM,EAAE,GAAGN;IAEtD,MAAMO,kBAAkBC,qBAAqBF;IAE7C,MAAMG,QAAQ,CAAC;;;;;AAKvB,EAAEF,gBAAgB;;;;;;;;;;;;;;IAcd,CAAC;IAEG,MAAMG,SAAS,MAAMC,eAAeb,QAAQC,SAASU,OAAO;QACxDR;QACAC;QACAC;QACAC;QACAC;IACJ;IAEA,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,SAAS,CAAC,KAAK,EACxC,OAAOF,OAAO,IAAI,CACd,IAAID,SACAG,aAAa,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,EAChDA,aAAa,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI;IAKzD,OAAOF,OAAO,EAAE,CAAC;QACb,MAAME,aAAa,WAAW,CAAC,SAAS,CAAC,IAAI;QAC7C,MAAMA,aAAa,WAAW,CAAC,SAAS,CAAC,IAAI;IACjD;AACJ"}
|
|
@@ -1,20 +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 listing tags
|
|
10
|
-
* @param params.where - Filter conditions
|
|
11
|
-
* @returns Result containing the list of tags or an error
|
|
12
|
-
*/
|
|
13
|
-
export async function listTags(config, fetchFn, params = {}) {
|
|
14
|
-
const {
|
|
15
|
-
where
|
|
16
|
-
} = params;
|
|
17
|
-
const query = `
|
|
4
|
+
async function listTags(config, fetchFn, params = {}) {
|
|
5
|
+
const { where } = params;
|
|
6
|
+
const query = `
|
|
18
7
|
query ListTags($where: FmTagsListWhereInput) {
|
|
19
8
|
fileManager {
|
|
20
9
|
listTags(where: $where) {
|
|
@@ -30,17 +19,14 @@ export async function listTags(config, fetchFn, params = {}) {
|
|
|
30
19
|
}
|
|
31
20
|
}
|
|
32
21
|
`;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (responseData.fileManager.listTags.error) {
|
|
41
|
-
return Result.fail(new ApiError(responseData.fileManager.listTags.error.message, responseData.fileManager.listTags.error.code));
|
|
42
|
-
}
|
|
43
|
-
return Result.ok(responseData.fileManager.listTags.data);
|
|
22
|
+
const result = await executeGraphQL(config, fetchFn, query, {
|
|
23
|
+
where
|
|
24
|
+
});
|
|
25
|
+
if (result.isFail()) return Result.fail(result.error);
|
|
26
|
+
const responseData = result.value;
|
|
27
|
+
if (responseData.fileManager.listTags.error) return Result.fail(new ApiError(responseData.fileManager.listTags.error.message, responseData.fileManager.listTags.error.code));
|
|
28
|
+
return Result.ok(responseData.fileManager.listTags.data);
|
|
44
29
|
}
|
|
30
|
+
export { listTags };
|
|
45
31
|
|
|
46
32
|
//# sourceMappingURL=listTags.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"methods/fileManager/listTags.js","sources":["../../../src/methods/fileManager/listTags.ts"],"sourcesContent":["import type { WebinyConfig } from \"../../types.js\";\nimport { Result } from \"../../Result.js\";\nimport type { HttpError, NetworkError } from \"../../errors.js\";\nimport type { FmTag, FmTagsListWhereInput } from \"./fileManagerTypes.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.js\";\n\nexport interface ListTagsParams {\n where?: FmTagsListWhereInput;\n}\n\n/**\n * Lists tags 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 listing tags\n * @param params.where - Filter conditions\n * @returns Result containing the list of tags or an error\n */\nexport async function listTags(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: ListTagsParams = {}\n): Promise<Result<FmTag[], HttpError | ApiError | NetworkError>> {\n const { where } = params;\n\n const query = `\n query ListTags($where: FmTagsListWhereInput) {\n fileManager {\n listTags(where: $where) {\n data {\n tag\n count\n }\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, { where });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.fileManager.listTags.error) {\n return Result.fail(\n new ApiError(\n responseData.fileManager.listTags.error.message,\n responseData.fileManager.listTags.error.code\n )\n );\n }\n\n return Result.ok(responseData.fileManager.listTags.data);\n}\n"],"names":["listTags","config","fetchFn","params","where","query","result","executeGraphQL","Result","responseData","ApiError"],"mappings":";;;AAoBO,eAAeA,SAClBC,MAAoB,EACpBC,OAAqB,EACrBC,SAAyB,CAAC,CAAC;IAE3B,MAAM,EAAEC,KAAK,EAAE,GAAGD;IAElB,MAAME,QAAQ,CAAC;;;;;;;;;;;;;;;IAef,CAAC;IAED,MAAMC,SAAS,MAAMC,eAAeN,QAAQC,SAASG,OAAO;QAAED;IAAM;IAEpE,IAAIE,OAAO,MAAM,IACb,OAAOE,OAAO,IAAI,CAACF,OAAO,KAAK;IAGnC,MAAMG,eAAeH,OAAO,KAAK;IAEjC,IAAIG,aAAa,WAAW,CAAC,QAAQ,CAAC,KAAK,EACvC,OAAOD,OAAO,IAAI,CACd,IAAIE,SACAD,aAAa,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,EAC/CA,aAAa,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI;IAKxD,OAAOD,OAAO,EAAE,CAACC,aAAa,WAAW,CAAC,QAAQ,CAAC,IAAI;AAC3D"}
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
const fields = z.array(z.string().min(1)).min(1, "fields must contain at least one entry");
|
|
3
3
|
const where = z.record(z.string(), z.unknown()).optional();
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
const listFilesSchema = z.object({
|
|
5
|
+
search: z.string().optional(),
|
|
6
|
+
where: where,
|
|
7
|
+
limit: z.number().int().positive().optional(),
|
|
8
|
+
after: z.string().optional(),
|
|
9
|
+
sort: z.array(z.string()).optional(),
|
|
10
|
+
fields: fields
|
|
11
11
|
});
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const getFileSchema = z.object({
|
|
13
|
+
id: z.string().min(1, "id is required"),
|
|
14
|
+
fields: fields
|
|
15
15
|
});
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const updateFileSchema = z.object({
|
|
17
|
+
id: z.string().min(1, "id is required"),
|
|
18
|
+
data: z.record(z.string(), z.unknown()),
|
|
19
|
+
fields: fields
|
|
20
20
|
});
|
|
21
|
+
export { getFileSchema, listFilesSchema, updateFileSchema };
|
|
21
22
|
|
|
22
23
|
//# sourceMappingURL=schemas.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"methods/fileManager/schemas.js","sources":["../../../src/methods/fileManager/schemas.ts"],"sourcesContent":["import { z } from \"zod\";\n\nconst fields = z.array(z.string().min(1)).min(1, \"fields must contain at least one entry\");\nconst where = z.record(z.string(), z.unknown()).optional();\n\nexport const listFilesSchema = z.object({\n search: z.string().optional(),\n where,\n limit: z.number().int().positive().optional(),\n after: z.string().optional(),\n sort: z.array(z.string()).optional(),\n fields\n});\n\nexport const getFileSchema = z.object({\n id: z.string().min(1, \"id is required\"),\n fields\n});\n\nexport const updateFileSchema = z.object({\n id: z.string().min(1, \"id is required\"),\n data: z.record(z.string(), z.unknown()),\n fields\n});\n"],"names":["fields","z","where","listFilesSchema","getFileSchema","updateFileSchema"],"mappings":";AAEA,MAAMA,SAASC,EAAE,KAAK,CAACA,EAAE,MAAM,GAAG,GAAG,CAAC,IAAI,GAAG,CAAC,GAAG;AACjD,MAAMC,QAAQD,EAAE,MAAM,CAACA,EAAE,MAAM,IAAIA,EAAE,OAAO,IAAI,QAAQ;AAEjD,MAAME,kBAAkBF,EAAE,MAAM,CAAC;IACpC,QAAQA,EAAE,MAAM,GAAG,QAAQ;IAC3BC,OAAAA;IACA,OAAOD,EAAE,MAAM,GAAG,GAAG,GAAG,QAAQ,GAAG,QAAQ;IAC3C,OAAOA,EAAE,MAAM,GAAG,QAAQ;IAC1B,MAAMA,EAAE,KAAK,CAACA,EAAE,MAAM,IAAI,QAAQ;IAClCD,QAAAA;AACJ;AAEO,MAAMI,gBAAgBH,EAAE,MAAM,CAAC;IAClC,IAAIA,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG;IACtBD,QAAAA;AACJ;AAEO,MAAMK,mBAAmBJ,EAAE,MAAM,CAAC;IACrC,IAAIA,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG;IACtB,MAAMA,EAAE,MAAM,CAACA,EAAE,MAAM,IAAIA,EAAE,OAAO;IACpCD,QAAAA;AACJ"}
|
|
@@ -4,23 +4,9 @@ import { createMethod } from "../../utils/createMethod.js";
|
|
|
4
4
|
import { updateFileSchema } from "./schemas.js";
|
|
5
5
|
import { executeGraphQL } from "../executeGraphQL.js";
|
|
6
6
|
import { ApiError } from "../../errors.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* @param config - SDK configuration
|
|
11
|
-
* @param fetchFn - Fetch function to use for HTTP requests
|
|
12
|
-
* @param params - Parameters for updating the file
|
|
13
|
-
* @param params.id - ID of the file to update
|
|
14
|
-
* @param params.data - The file data to update
|
|
15
|
-
* @returns Result containing the updated file data or an error
|
|
16
|
-
*/
|
|
17
|
-
export const updateFile = createMethod(updateFileSchema, async (config, fetchFn, {
|
|
18
|
-
id,
|
|
19
|
-
data,
|
|
20
|
-
fields
|
|
21
|
-
}) => {
|
|
22
|
-
const fieldsSelection = buildFieldsSelection(fields);
|
|
23
|
-
const query = `
|
|
7
|
+
const updateFile = createMethod(updateFileSchema, async (config, fetchFn, { id, data, fields })=>{
|
|
8
|
+
const fieldsSelection = buildFieldsSelection(fields);
|
|
9
|
+
const query = `
|
|
24
10
|
mutation UpdateFile($id: ID!, $data: FmFileUpdateInput!) {
|
|
25
11
|
fileManager {
|
|
26
12
|
updateFile(id: $id, data: $data) {
|
|
@@ -35,18 +21,15 @@ ${fieldsSelection}
|
|
|
35
21
|
}
|
|
36
22
|
}
|
|
37
23
|
`;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (responseData.fileManager.updateFile.error) {
|
|
47
|
-
return Result.fail(new ApiError(responseData.fileManager.updateFile.error.message, responseData.fileManager.updateFile.error.code));
|
|
48
|
-
}
|
|
49
|
-
return Result.ok(responseData.fileManager.updateFile.data);
|
|
24
|
+
const result = await executeGraphQL(config, fetchFn, query, {
|
|
25
|
+
id,
|
|
26
|
+
data
|
|
27
|
+
});
|
|
28
|
+
if (result.isFail()) return Result.fail(result.error);
|
|
29
|
+
const responseData = result.value;
|
|
30
|
+
if (responseData.fileManager.updateFile.error) return Result.fail(new ApiError(responseData.fileManager.updateFile.error.message, responseData.fileManager.updateFile.error.code));
|
|
31
|
+
return Result.ok(responseData.fileManager.updateFile.data);
|
|
50
32
|
});
|
|
33
|
+
export { updateFile };
|
|
51
34
|
|
|
52
35
|
//# sourceMappingURL=updateFile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"methods/fileManager/updateFile.js","sources":["../../../src/methods/fileManager/updateFile.ts"],"sourcesContent":["import { Result } from \"../../Result.js\";\nimport type { FmFile, FmIdentity, FmLocationInput } from \"./fileManagerTypes.js\";\nimport { buildFieldsSelection } from \"./buildFieldsSelection.js\";\nimport { createMethod } from \"../../utils/createMethod.js\";\nimport { updateFileSchema } from \"./schemas.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.js\";\n\nexport interface UpdateFileData {\n createdOn?: Date | string;\n modifiedOn?: Date | string;\n savedOn?: Date | string;\n createdBy?: FmIdentity;\n modifiedBy?: FmIdentity;\n savedBy?: FmIdentity;\n location?: FmLocationInput;\n name?: string;\n key?: string;\n type?: string;\n size?: number;\n tags?: string[];\n [key: string]: any;\n}\n\nexport interface UpdateFileParams {\n id: string;\n data: UpdateFileData;\n fields: string[];\n}\n\n/**\n * Updates a file in the file manager.\n *\n * @param config - SDK configuration\n * @param fetchFn - Fetch function to use for HTTP requests\n * @param params - Parameters for updating the file\n * @param params.id - ID of the file to update\n * @param params.data - The file data to update\n * @returns Result containing the updated file data or an error\n */\nexport const updateFile = createMethod(\n updateFileSchema,\n async (config, fetchFn, { id, data, fields }) => {\n const fieldsSelection = buildFieldsSelection(fields);\n\n const query = `\n mutation UpdateFile($id: ID!, $data: FmFileUpdateInput!) {\n fileManager {\n updateFile(id: $id, data: $data) {\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, data });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.fileManager.updateFile.error) {\n return Result.fail(\n new ApiError(\n responseData.fileManager.updateFile.error.message,\n responseData.fileManager.updateFile.error.code\n )\n );\n }\n\n return Result.ok(responseData.fileManager.updateFile.data as FmFile);\n }\n);\n"],"names":["updateFile","createMethod","updateFileSchema","config","fetchFn","id","data","fields","fieldsSelection","buildFieldsSelection","query","result","executeGraphQL","Result","responseData","ApiError"],"mappings":";;;;;;AAwCO,MAAMA,aAAaC,aACtBC,kBACA,OAAOC,QAAQC,SAAS,EAAEC,EAAE,EAAEC,IAAI,EAAEC,MAAM,EAAE;IACxC,MAAMC,kBAAkBC,qBAAqBF;IAE7C,MAAMG,QAAQ,CAAC;;;;;AAKvB,EAAEF,gBAAgB;;;;;;;;;IASd,CAAC;IAEG,MAAMG,SAAS,MAAMC,eAAeT,QAAQC,SAASM,OAAO;QAAEL;QAAIC;IAAK;IAEvE,IAAIK,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,19 +1,17 @@
|
|
|
1
1
|
import { isBrowser } from "../../../utils/platform.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return typeof Buffer !== "undefined" && Buffer.isBuffer(file);
|
|
2
|
+
function isBuffer(file) {
|
|
3
|
+
return "u" > typeof Buffer && Buffer.isBuffer(file);
|
|
5
4
|
}
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
function isBlob(file) {
|
|
6
|
+
return "u" > typeof Blob && file instanceof Blob;
|
|
8
7
|
}
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
function isFile(file) {
|
|
9
|
+
return isBrowser && "u" > typeof File && file instanceof File;
|
|
11
10
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return file.
|
|
15
|
-
}
|
|
16
|
-
return file.size;
|
|
11
|
+
function getFileSize(file) {
|
|
12
|
+
if (isBuffer(file)) return file.length;
|
|
13
|
+
return file.size;
|
|
17
14
|
}
|
|
15
|
+
export { getFileSize, isBlob, isBuffer, isFile };
|
|
18
16
|
|
|
19
17
|
//# sourceMappingURL=fileTypeDetection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"methods/fileManager/utils/fileTypeDetection.js","sources":["../../../../src/methods/fileManager/utils/fileTypeDetection.ts"],"sourcesContent":["import { isBrowser } from \"../../../utils/platform.js\";\n\nexport function isBuffer(file: any): file is Buffer {\n // Check if Buffer exists (Node.js) before using it.\n return typeof Buffer !== \"undefined\" && Buffer.isBuffer(file);\n}\n\nexport function isBlob(file: any): file is Blob {\n return typeof Blob !== \"undefined\" && file instanceof Blob;\n}\n\nexport function isFile(file: any): file is File {\n return isBrowser && typeof File !== \"undefined\" && file instanceof File;\n}\n\nexport function getFileSize(file: Buffer | Blob | File): number {\n if (isBuffer(file)) {\n return file.length;\n }\n return file.size;\n}\n"],"names":["isBuffer","file","Buffer","isBlob","Blob","isFile","isBrowser","File","getFileSize"],"mappings":";AAEO,SAASA,SAASC,IAAS;IAE9B,OAAO,AAAkB,MAAlB,OAAOC,UAA0BA,OAAO,QAAQ,CAACD;AAC5D;AAEO,SAASE,OAAOF,IAAS;IAC5B,OAAO,AAAgB,MAAhB,OAAOG,QAAwBH,gBAAgBG;AAC1D;AAEO,SAASC,OAAOJ,IAAS;IAC5B,OAAOK,aAAa,AAAgB,MAAhB,OAAOC,QAAwBN,gBAAgBM;AACvE;AAEO,SAASC,YAAYP,IAA0B;IAClD,IAAID,SAASC,OACT,OAAOA,KAAK,MAAM;IAEtB,OAAOA,KAAK,IAAI;AACpB"}
|