@webiny/sdk 6.3.0-beta.2 → 6.3.0-beta.4
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/CmsSdk.d.ts +8 -8
- package/CmsSdk.js.map +1 -1
- package/FileManagerSdk.d.ts +12 -12
- package/FileManagerSdk.js.map +1 -1
- package/LanguagesSdk.d.ts +2 -2
- package/LanguagesSdk.js.map +1 -1
- package/TasksSdk.d.ts +6 -6
- package/TasksSdk.js +1 -1
- package/TasksSdk.js.map +1 -1
- package/TenantManagerSdk.d.ts +6 -6
- package/TenantManagerSdk.js.map +1 -1
- package/errors.d.ts +10 -3
- package/errors.js +14 -2
- package/errors.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/methods/cms/cmsTypes.d.ts +16 -0
- package/methods/cms/cmsTypes.js.map +1 -1
- package/methods/cms/createEntry.d.ts +3 -14
- package/methods/cms/createEntry.js +15 -13
- package/methods/cms/createEntry.js.map +1 -1
- package/methods/cms/deleteEntryRevision.d.ts +2 -3
- package/methods/cms/deleteEntryRevision.js +11 -14
- package/methods/cms/deleteEntryRevision.js.map +1 -1
- package/methods/cms/getEntry.d.ts +3 -18
- package/methods/cms/getEntry.js +17 -19
- package/methods/cms/getEntry.js.map +1 -1
- package/methods/cms/listEntries.d.ts +3 -19
- package/methods/cms/listEntries.js +19 -18
- package/methods/cms/listEntries.js.map +1 -1
- package/methods/cms/publishEntryRevision.d.ts +3 -14
- package/methods/cms/publishEntryRevision.js +15 -14
- package/methods/cms/publishEntryRevision.js.map +1 -1
- package/methods/cms/schemas.d.ts +43 -0
- package/methods/cms/schemas.js +50 -0
- package/methods/cms/schemas.js.map +1 -0
- package/methods/cms/unpublishEntryRevision.d.ts +3 -14
- package/methods/cms/unpublishEntryRevision.js +15 -14
- package/methods/cms/unpublishEntryRevision.js.map +1 -1
- package/methods/cms/updateEntryRevision.d.ts +3 -15
- package/methods/cms/updateEntryRevision.js +16 -14
- package/methods/cms/updateEntryRevision.js.map +1 -1
- package/methods/executeGraphQL.d.ts +2 -2
- package/methods/executeGraphQL.js +2 -2
- package/methods/executeGraphQL.js.map +1 -1
- package/methods/fileManager/completeMultiPartUpload.d.ts +3 -2
- package/methods/fileManager/completeMultiPartUpload.js +4 -7
- package/methods/fileManager/completeMultiPartUpload.js.map +1 -1
- package/methods/fileManager/createFile.d.ts +3 -2
- package/methods/fileManager/createFile.js +7 -16
- package/methods/fileManager/createFile.js.map +1 -1
- package/methods/fileManager/createFiles.d.ts +2 -2
- package/methods/fileManager/createFiles.js +4 -4
- package/methods/fileManager/createFiles.js.map +1 -1
- package/methods/fileManager/createMultiPartUpload.d.ts +3 -2
- package/methods/fileManager/createMultiPartUpload.js +4 -7
- package/methods/fileManager/createMultiPartUpload.js.map +1 -1
- package/methods/fileManager/deleteFile.d.ts +3 -2
- package/methods/fileManager/deleteFile.js +4 -7
- package/methods/fileManager/deleteFile.js.map +1 -1
- package/methods/fileManager/getFile.d.ts +3 -3
- package/methods/fileManager/getFile.js +13 -10
- package/methods/fileManager/getFile.js.map +1 -1
- package/methods/fileManager/getPresignedPostPayload.d.ts +3 -2
- package/methods/fileManager/getPresignedPostPayload.js +4 -7
- package/methods/fileManager/getPresignedPostPayload.js.map +1 -1
- package/methods/fileManager/getPresignedPostPayloads.d.ts +3 -2
- package/methods/fileManager/getPresignedPostPayloads.js +4 -7
- package/methods/fileManager/getPresignedPostPayloads.js.map +1 -1
- package/methods/fileManager/listFiles.d.ts +3 -3
- package/methods/fileManager/listFiles.js +13 -10
- package/methods/fileManager/listFiles.js.map +1 -1
- package/methods/fileManager/listTags.d.ts +3 -2
- package/methods/fileManager/listTags.js +3 -7
- package/methods/fileManager/listTags.js.map +1 -1
- package/methods/fileManager/schemas.d.ts +18 -0
- package/methods/fileManager/schemas.js +22 -0
- package/methods/fileManager/schemas.js.map +1 -0
- package/methods/fileManager/updateFile.d.ts +2 -3
- package/methods/fileManager/updateFile.js +11 -14
- package/methods/fileManager/updateFile.js.map +1 -1
- package/methods/fileManager/utils/uploadLargeFile.js +4 -8
- package/methods/fileManager/utils/uploadLargeFile.js.map +1 -1
- package/methods/languages/listLanguages.d.ts +3 -2
- package/methods/languages/listLanguages.js +3 -7
- package/methods/languages/listLanguages.js.map +1 -1
- package/methods/tasks/abortTask.d.ts +2 -3
- package/methods/tasks/abortTask.js +10 -13
- package/methods/tasks/abortTask.js.map +1 -1
- package/methods/tasks/listDefinitions.d.ts +3 -2
- package/methods/tasks/listDefinitions.js +3 -7
- package/methods/tasks/listDefinitions.js.map +1 -1
- package/methods/tasks/listLogs.d.ts +2 -3
- package/methods/tasks/listLogs.js +10 -10
- package/methods/tasks/listLogs.js.map +1 -1
- package/methods/tasks/listTasks.d.ts +3 -2
- package/methods/tasks/listTasks.js +3 -7
- package/methods/tasks/listTasks.js.map +1 -1
- package/methods/tasks/schemas.d.ts +14 -0
- package/methods/tasks/schemas.js +16 -0
- package/methods/tasks/schemas.js.map +1 -0
- package/methods/tasks/triggerTask.d.ts +2 -3
- package/methods/tasks/triggerTask.js +10 -13
- package/methods/tasks/triggerTask.js.map +1 -1
- package/methods/tenantManager/createTenant.d.ts +2 -3
- package/methods/tenantManager/createTenant.js +9 -12
- package/methods/tenantManager/createTenant.js.map +1 -1
- package/methods/tenantManager/disableTenant.d.ts +2 -3
- package/methods/tenantManager/disableTenant.js +9 -12
- package/methods/tenantManager/disableTenant.js.map +1 -1
- package/methods/tenantManager/enableTenant.d.ts +2 -3
- package/methods/tenantManager/enableTenant.js +9 -12
- package/methods/tenantManager/enableTenant.js.map +1 -1
- package/methods/tenantManager/getCurrentTenant.d.ts +3 -2
- package/methods/tenantManager/getCurrentTenant.js +3 -7
- package/methods/tenantManager/getCurrentTenant.js.map +1 -1
- package/methods/tenantManager/installTenant.d.ts +2 -3
- package/methods/tenantManager/installTenant.js +9 -12
- package/methods/tenantManager/installTenant.js.map +1 -1
- package/methods/tenantManager/schemas.d.ts +17 -0
- package/methods/tenantManager/schemas.js +20 -0
- package/methods/tenantManager/schemas.js.map +1 -0
- package/package.json +5 -13
- package/utils/createMethod.d.ts +19 -0
- package/utils/createMethod.js +27 -0
- package/utils/createMethod.js.map +1 -0
- package/utils/transformFieldErrors.d.ts +15 -0
- package/utils/transformFieldErrors.js +36 -0
- package/utils/transformFieldErrors.js.map +1 -0
- package/utils/validateParams.d.ts +10 -0
- package/utils/validateParams.js +23 -0
- package/utils/validateParams.js.map +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Result","
|
|
1
|
+
{"version":3,"names":["Result","transformFieldErrors","createMethod","unpublishEntryRevisionSchema","executeGraphQL","ApiError","_impl","config","fetchFn","modelId","revisionId","fields","query","result","isFail","data","value","cms","unpublishEntryRevision","error","fail","message","code","ok","params"],"sources":["unpublishEntryRevision.ts"],"sourcesContent":["import type { WebinyConfig } from \"../../types.js\";\nimport { Result } from \"../../Result.js\";\nimport type { HttpError, NetworkError, ValidationError } from \"../../errors.js\";\nimport type { CmsEntryValues, CmsEntryData } from \"./cmsTypes.js\";\nimport { transformFieldErrors } from \"../../utils/transformFieldErrors.js\";\nimport { createMethod } from \"../../utils/createMethod.js\";\nimport { unpublishEntryRevisionSchema } from \"./schemas.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.js\";\n\nexport interface UnpublishEntryRevisionParams {\n modelId: string;\n revisionId: string;\n fields: string[];\n}\n\n/**\n * Unpublishes an entry revision in the CMS.\n *\n * @template TValues - Type of the entry values object\n * @param config - SDK configuration\n * @param fetchFn - Fetch function to use for HTTP requests\n * @param params - Parameters for unpublishing the entry revision\n * @param params.modelId - The model ID of the entry to unpublish\n * @param params.revisionId - The revision ID of the entry to unpublish (e.g., \"123#0001\")\n * @param params.fields - Fields to include in response\n * @returns Result containing the unpublished entry data or an error\n */\nconst _impl = createMethod(\n unpublishEntryRevisionSchema,\n async (config, fetchFn, { modelId, revisionId, fields }) => {\n const query = `\n mutation UnpublishEntryRevision($modelId: ID!, $revisionId: ID!, $fields: [String!]!) {\n cms {\n unpublishEntryRevision(modelId: $modelId, revisionId: $revisionId, fields: $fields) {\n data\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, {\n modelId,\n revisionId,\n fields\n });\n\n if (result.isFail()) {\n return result;\n }\n\n const data = result.value;\n\n if (data.cms.unpublishEntryRevision.error) {\n return Result.fail(\n new ApiError(\n transformFieldErrors(data.cms.unpublishEntryRevision.error.message, fields),\n data.cms.unpublishEntryRevision.error.code\n )\n );\n }\n\n return Result.ok(data.cms.unpublishEntryRevision.data);\n }\n);\n\nexport function unpublishEntryRevision<TValues extends CmsEntryValues = CmsEntryValues>(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: UnpublishEntryRevisionParams\n): Promise<Result<CmsEntryData<TValues>, HttpError | ApiError | NetworkError | ValidationError>> {\n return _impl(config, fetchFn, params) as Promise<\n Result<CmsEntryData<TValues>, HttpError | ApiError | NetworkError | ValidationError>\n >;\n}\n"],"mappings":"AACA,SAASA,MAAM;AAGf,SAASC,oBAAoB;AAC7B,SAASC,YAAY;AACrB,SAASC,4BAA4B;AACrC,SAASC,cAAc;AACvB,SAASC,QAAQ;AAQjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,KAAK,GAAGJ,YAAY,CACtBC,4BAA4B,EAC5B,OAAOI,MAAM,EAAEC,OAAO,EAAE;EAAEC,OAAO;EAAEC,UAAU;EAAEC;AAAO,CAAC,KAAK;EACxD,MAAMC,KAAK,GAAG;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;EAEG,MAAMC,MAAM,GAAG,MAAMT,cAAc,CAACG,MAAM,EAAEC,OAAO,EAAEI,KAAK,EAAE;IACxDH,OAAO;IACPC,UAAU;IACVC;EACJ,CAAC,CAAC;EAEF,IAAIE,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;IACjB,OAAOD,MAAM;EACjB;EAEA,MAAME,IAAI,GAAGF,MAAM,CAACG,KAAK;EAEzB,IAAID,IAAI,CAACE,GAAG,CAACC,sBAAsB,CAACC,KAAK,EAAE;IACvC,OAAOnB,MAAM,CAACoB,IAAI,CACd,IAAIf,QAAQ,CACRJ,oBAAoB,CAACc,IAAI,CAACE,GAAG,CAACC,sBAAsB,CAACC,KAAK,CAACE,OAAO,EAAEV,MAAM,CAAC,EAC3EI,IAAI,CAACE,GAAG,CAACC,sBAAsB,CAACC,KAAK,CAACG,IAC1C,CACJ,CAAC;EACL;EAEA,OAAOtB,MAAM,CAACuB,EAAE,CAACR,IAAI,CAACE,GAAG,CAACC,sBAAsB,CAACH,IAAI,CAAC;AAC1D,CACJ,CAAC;AAED,OAAO,SAASG,sBAAsBA,CAClCX,MAAoB,EACpBC,OAAqB,EACrBgB,MAAoC,EACyD;EAC7F,OAAOlB,KAAK,CAACC,MAAM,EAAEC,OAAO,EAAEgB,MAAM,CAAC;AAGzC","ignoreList":[]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { WebinyConfig } from "../../types.js";
|
|
2
2
|
import { Result } from "../../Result.js";
|
|
3
|
-
import type { HttpError,
|
|
3
|
+
import type { HttpError, NetworkError, ValidationError } from "../../errors.js";
|
|
4
4
|
import type { CmsEntryValues, CmsIdentity } from "./cmsTypes.js";
|
|
5
|
+
import { ApiError } from "../../errors.js";
|
|
5
6
|
/**
|
|
6
7
|
* Update entry revision data.
|
|
7
8
|
*/
|
|
@@ -51,17 +52,4 @@ export interface UpdateEntryRevisionParams<TValues extends CmsEntryValues = CmsE
|
|
|
51
52
|
data: UpdateCmsEntryData<TValues>;
|
|
52
53
|
fields: string[];
|
|
53
54
|
}
|
|
54
|
-
|
|
55
|
-
* Updates an existing entry revision in the CMS.
|
|
56
|
-
*
|
|
57
|
-
* @template TValues - Type of the entry data object returned (typically contains id and entryId, or additional fields if specified)
|
|
58
|
-
* @param config - SDK configuration
|
|
59
|
-
* @param fetchFn - Fetch function to use for HTTP requests
|
|
60
|
-
* @param params - Parameters for updating the entry revision
|
|
61
|
-
* @param params.modelId - The model ID for the entry
|
|
62
|
-
* @param params.revisionId - The revision ID of the entry to update (e.g., "123#0001")
|
|
63
|
-
* @param params.data - The updated entry data
|
|
64
|
-
* @param params.fields - Fields to include in the response. Use "values." prefix for entry values (e.g., "values.author.name") or specify top-level fields like "createdOn"
|
|
65
|
-
* @returns Result containing the updated entry data or an error
|
|
66
|
-
*/
|
|
67
|
-
export declare function updateEntryRevision<TValues extends CmsEntryValues = CmsEntryValues>(config: WebinyConfig, fetchFn: typeof fetch, params: UpdateEntryRevisionParams<TValues>): Promise<Result<UpdateCmsEntryData<TValues>, HttpError | GraphQLError | NetworkError>>;
|
|
55
|
+
export declare function updateEntryRevision<TValues extends CmsEntryValues = CmsEntryValues>(config: WebinyConfig, fetchFn: typeof fetch, params: UpdateEntryRevisionParams<TValues>): Promise<Result<UpdateCmsEntryData<TValues>, HttpError | ApiError | NetworkError | ValidationError>>;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { Result } from "../../Result.js";
|
|
2
|
+
import { transformFieldErrors } from "../../utils/transformFieldErrors.js";
|
|
3
|
+
import { createMethod } from "../../utils/createMethod.js";
|
|
4
|
+
import { updateEntryRevisionSchema } from "./schemas.js";
|
|
5
|
+
import { executeGraphQL } from "../executeGraphQL.js";
|
|
6
|
+
import { ApiError } from "../../errors.js";
|
|
2
7
|
|
|
3
8
|
/**
|
|
4
9
|
* Update entry revision data.
|
|
@@ -17,16 +22,13 @@ import { Result } from "../../Result.js";
|
|
|
17
22
|
* @param params.fields - Fields to include in the response. Use "values." prefix for entry values (e.g., "values.author.name") or specify top-level fields like "createdOn"
|
|
18
23
|
* @returns Result containing the updated entry data or an error
|
|
19
24
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const {
|
|
28
|
-
executeGraphQL
|
|
29
|
-
} = await import("../executeGraphQL.js");
|
|
25
|
+
|
|
26
|
+
const _impl = createMethod(updateEntryRevisionSchema, async (config, fetchFn, {
|
|
27
|
+
modelId,
|
|
28
|
+
revisionId,
|
|
29
|
+
data,
|
|
30
|
+
fields
|
|
31
|
+
}) => {
|
|
30
32
|
const query = `
|
|
31
33
|
mutation UpdateEntryRevision($modelId: ID!, $revisionId: ID!, $data: JSON!, $fields: [String!]!) {
|
|
32
34
|
cms {
|
|
@@ -51,12 +53,12 @@ export async function updateEntryRevision(config, fetchFn, params) {
|
|
|
51
53
|
}
|
|
52
54
|
const responseData = result.value;
|
|
53
55
|
if (responseData.cms.updateEntryRevision.error) {
|
|
54
|
-
|
|
55
|
-
GraphQLError
|
|
56
|
-
} = await import("../../errors.js");
|
|
57
|
-
return Result.fail(new GraphQLError(responseData.cms.updateEntryRevision.error.message, responseData.cms.updateEntryRevision.error.code));
|
|
56
|
+
return Result.fail(new ApiError(transformFieldErrors(responseData.cms.updateEntryRevision.error.message, fields), responseData.cms.updateEntryRevision.error.code));
|
|
58
57
|
}
|
|
59
58
|
return Result.ok(responseData.cms.updateEntryRevision.data);
|
|
59
|
+
});
|
|
60
|
+
export function updateEntryRevision(config, fetchFn, params) {
|
|
61
|
+
return _impl(config, fetchFn, params);
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
//# sourceMappingURL=updateEntryRevision.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Result","
|
|
1
|
+
{"version":3,"names":["Result","transformFieldErrors","createMethod","updateEntryRevisionSchema","executeGraphQL","ApiError","_impl","config","fetchFn","modelId","revisionId","data","fields","query","result","isFail","fail","error","responseData","value","cms","updateEntryRevision","message","code","ok","params"],"sources":["updateEntryRevision.ts"],"sourcesContent":["import type { WebinyConfig } from \"../../types.js\";\nimport { Result } from \"../../Result.js\";\nimport type { HttpError, NetworkError, ValidationError } from \"../../errors.js\";\nimport type { CmsEntryValues, CmsIdentity } from \"./cmsTypes.js\";\nimport { transformFieldErrors } from \"../../utils/transformFieldErrors.js\";\nimport { createMethod } from \"../../utils/createMethod.js\";\nimport { updateEntryRevisionSchema } from \"./schemas.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.js\";\n\n/**\n * Update entry revision data.\n */\nexport interface UpdateCmsEntryData<TValues extends CmsEntryValues = CmsEntryValues> {\n /**\n * Revision-level meta fields.\n */\n revisionCreatedOn?: Date | string | null;\n revisionModifiedOn?: Date | string | null;\n revisionSavedOn?: Date | string | null;\n revisionDeletedOn?: Date | string | null;\n revisionRestoredOn?: Date | string | null;\n revisionFirstPublishedOn?: Date | string | null;\n revisionLastPublishedOn?: Date | string | null;\n revisionModifiedBy?: CmsIdentity | null;\n revisionCreatedBy?: CmsIdentity | null;\n revisionSavedBy?: CmsIdentity | null;\n revisionDeletedBy?: CmsIdentity | null;\n revisionRestoredBy?: CmsIdentity | null;\n revisionFirstPublishedBy?: CmsIdentity | null;\n revisionLastPublishedBy?: CmsIdentity | null;\n\n /**\n * Entry-level meta fields.\n */\n createdOn?: Date | string | null;\n modifiedOn?: Date | string | null;\n savedOn?: Date | string | null;\n deletedOn?: Date | string | null;\n restoredOn?: Date | string | null;\n firstPublishedOn?: Date | string | null;\n lastPublishedOn?: Date | string | null;\n createdBy?: CmsIdentity | null;\n modifiedBy?: CmsIdentity | null;\n savedBy?: CmsIdentity | null;\n deletedBy?: CmsIdentity | null;\n restoredBy?: CmsIdentity | null;\n firstPublishedBy?: CmsIdentity | null;\n lastPublishedBy?: CmsIdentity | null;\n\n location?: {\n folderId?: string | null;\n };\n\n values?: Partial<TValues>;\n}\n\nexport interface UpdateEntryRevisionParams<TValues extends CmsEntryValues = CmsEntryValues> {\n modelId: string;\n revisionId: string;\n data: UpdateCmsEntryData<TValues>;\n fields: string[];\n}\n\n/**1`\n * Updates an existing entry revision in the CMS.\n *\n * @template TValues - Type of the entry data object returned (typically contains id and entryId, or additional fields if specified)\n * @param config - SDK configuration\n * @param fetchFn - Fetch function to use for HTTP requests\n * @param params - Parameters for updating the entry revision\n * @param params.modelId - The model ID for the entry\n * @param params.revisionId - The revision ID of the entry to update (e.g., \"123#0001\")\n * @param params.data - The updated entry data\n * @param params.fields - Fields to include in the response. Use \"values.\" prefix for entry values (e.g., \"values.author.name\") or specify top-level fields like \"createdOn\"\n * @returns Result containing the updated entry data or an error\n */\n\nconst _impl = createMethod(\n updateEntryRevisionSchema,\n async (config, fetchFn, { modelId, revisionId, data, fields }) => {\n const query = `\n mutation UpdateEntryRevision($modelId: ID!, $revisionId: ID!, $data: JSON!, $fields: [String!]!) {\n cms {\n updateEntryRevision(modelId: $modelId, revisionId: $revisionId, data: $data, fields: $fields) {\n data\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, {\n modelId,\n revisionId,\n data,\n fields\n });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.cms.updateEntryRevision.error) {\n return Result.fail(\n new ApiError(\n transformFieldErrors(\n responseData.cms.updateEntryRevision.error.message,\n fields\n ),\n responseData.cms.updateEntryRevision.error.code\n )\n );\n }\n\n return Result.ok(responseData.cms.updateEntryRevision.data);\n }\n);\n\nexport function updateEntryRevision<TValues extends CmsEntryValues = CmsEntryValues>(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: UpdateEntryRevisionParams<TValues>\n): Promise<\n Result<UpdateCmsEntryData<TValues>, HttpError | ApiError | NetworkError | ValidationError>\n> {\n return _impl(config, fetchFn, params) as Promise<\n Result<UpdateCmsEntryData<TValues>, HttpError | ApiError | NetworkError | ValidationError>\n >;\n}\n"],"mappings":"AACA,SAASA,MAAM;AAGf,SAASC,oBAAoB;AAC7B,SAASC,YAAY;AACrB,SAASC,yBAAyB;AAClC,SAASC,cAAc;AACvB,SAASC,QAAQ;;AAEjB;AACA;AACA;;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|
import type { WebinyConfig } from "../types.js";
|
|
2
2
|
import { Result } from "../Result.js";
|
|
3
|
-
import { HttpError,
|
|
4
|
-
export declare function executeGraphQL(config: WebinyConfig, fetchFn: typeof fetch, query: string, variables?: Record<string, unknown>): Promise<Result<any, HttpError |
|
|
3
|
+
import { HttpError, ApiError, NetworkError } from "../errors.js";
|
|
4
|
+
export declare function executeGraphQL(config: WebinyConfig, fetchFn: typeof fetch, query: string, variables?: Record<string, unknown>): Promise<Result<any, HttpError | ApiError | NetworkError>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Result } from "../Result.js";
|
|
2
|
-
import { HttpError,
|
|
2
|
+
import { HttpError, ApiError, NetworkError } from "../errors.js";
|
|
3
3
|
export async function executeGraphQL(config, fetchFn, query, variables = {}) {
|
|
4
4
|
const url = `${config.endpoint}/graphql`;
|
|
5
5
|
let response;
|
|
@@ -38,7 +38,7 @@ export async function executeGraphQL(config, fetchFn, query, variables = {}) {
|
|
|
38
38
|
}
|
|
39
39
|
if (result.errors) {
|
|
40
40
|
const error = result.errors[0];
|
|
41
|
-
return Result.fail(new
|
|
41
|
+
return Result.fail(new ApiError(error?.message || "GraphQL error", error?.code));
|
|
42
42
|
}
|
|
43
43
|
return Result.ok(result.data);
|
|
44
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Result","HttpError","
|
|
1
|
+
{"version":3,"names":["Result","HttpError","ApiError","NetworkError","executeGraphQL","config","fetchFn","query","variables","url","endpoint","response","body","JSON","stringify","headers","tenant","token","Authorization","method","error","fail","Error","message","ok","status","result","json","errors","code","data"],"sources":["executeGraphQL.ts"],"sourcesContent":["import type { WebinyConfig } from \"../types.js\";\nimport { Result } from \"../Result.js\";\nimport { HttpError, ApiError, NetworkError } from \"../errors.js\";\n\nexport async function executeGraphQL(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n query: string,\n variables: Record<string, unknown> = {}\n): Promise<Result<any, HttpError | ApiError | NetworkError>> {\n const url = `${config.endpoint}/graphql`;\n\n let response: Response;\n\n try {\n const body = JSON.stringify({ query, variables });\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n \"x-tenant\": config.tenant ?? \"root\",\n ...config.headers\n };\n\n // Only add Authorization header if token is provided and not already set in custom headers.\n if (config.token && !headers.Authorization) {\n const token = typeof config.token === \"function\" ? await config.token() : config.token;\n headers.Authorization = `Bearer ${token}`;\n }\n\n response = await fetchFn(url, {\n method: \"POST\",\n headers,\n body\n });\n } catch (error) {\n return Result.fail(\n new NetworkError(error instanceof Error ? error.message : \"Network request failed\")\n );\n }\n\n if (!response.ok) {\n return Result.fail(\n new HttpError(response.status, `HTTP error! status: ${response.status}`)\n );\n }\n\n let result: any;\n try {\n result = await response.json();\n } catch {\n return Result.fail(new NetworkError(\"Failed to parse response JSON\"));\n }\n\n if (result.errors) {\n const error = result.errors[0];\n return Result.fail(new ApiError(error?.message || \"GraphQL error\", error?.code));\n }\n\n return Result.ok(result.data);\n}\n"],"mappings":"AACA,SAASA,MAAM;AACf,SAASC,SAAS,EAAEC,QAAQ,EAAEC,YAAY;AAE1C,OAAO,eAAeC,cAAcA,CAChCC,MAAoB,EACpBC,OAAqB,EACrBC,KAAa,EACbC,SAAkC,GAAG,CAAC,CAAC,EACkB;EACzD,MAAMC,GAAG,GAAG,GAAGJ,MAAM,CAACK,QAAQ,UAAU;EAExC,IAAIC,QAAkB;EAEtB,IAAI;IACA,MAAMC,IAAI,GAAGC,IAAI,CAACC,SAAS,CAAC;MAAEP,KAAK;MAAEC;IAAU,CAAC,CAAC;IAEjD,MAAMO,OAA+B,GAAG;MACpC,cAAc,EAAE,kBAAkB;MAClC,UAAU,EAAEV,MAAM,CAACW,MAAM,IAAI,MAAM;MACnC,GAAGX,MAAM,CAACU;IACd,CAAC;;IAED;IACA,IAAIV,MAAM,CAACY,KAAK,IAAI,CAACF,OAAO,CAACG,aAAa,EAAE;MACxC,MAAMD,KAAK,GAAG,OAAOZ,MAAM,CA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
3
|
-
import type { HttpError,
|
|
3
|
+
import type { HttpError, NetworkError } from "../../errors.js";
|
|
4
|
+
import { ApiError } from "../../errors.js";
|
|
4
5
|
export interface CompleteMultiPartUploadParams {
|
|
5
6
|
fileKey: string;
|
|
6
7
|
uploadId: string;
|
|
@@ -15,4 +16,4 @@ export interface CompleteMultiPartUploadParams {
|
|
|
15
16
|
* @param params.uploadId - Upload ID from createMultiPartUpload
|
|
16
17
|
* @returns Result containing true on success or an error
|
|
17
18
|
*/
|
|
18
|
-
export declare function completeMultiPartUpload(config: WebinyConfig, fetchFn: typeof fetch, params: CompleteMultiPartUploadParams): Promise<Result<boolean, HttpError |
|
|
19
|
+
export declare function completeMultiPartUpload(config: WebinyConfig, fetchFn: typeof fetch, params: CompleteMultiPartUploadParams): Promise<Result<boolean, HttpError | ApiError | NetworkError>>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Result } from "../../Result.js";
|
|
2
|
+
import { executeGraphQL } from "../executeGraphQL.js";
|
|
3
|
+
import { ApiError } from "../../errors.js";
|
|
2
4
|
/**
|
|
3
5
|
* Completes a multi-part upload.
|
|
4
6
|
*
|
|
@@ -9,14 +11,12 @@ import { Result } from "../../Result.js";
|
|
|
9
11
|
* @param params.uploadId - Upload ID from createMultiPartUpload
|
|
10
12
|
* @returns Result containing true on success or an error
|
|
11
13
|
*/
|
|
14
|
+
// Not using createMethod: params include raw upload part data that Zod cannot validate.
|
|
12
15
|
export async function completeMultiPartUpload(config, fetchFn, params) {
|
|
13
16
|
const {
|
|
14
17
|
fileKey,
|
|
15
18
|
uploadId
|
|
16
19
|
} = params;
|
|
17
|
-
const {
|
|
18
|
-
executeGraphQL
|
|
19
|
-
} = await import("../executeGraphQL.js");
|
|
20
20
|
const query = `
|
|
21
21
|
mutation CompleteMultiPartUpload($fileKey: String!, $uploadId: String!) {
|
|
22
22
|
fileManager {
|
|
@@ -39,10 +39,7 @@ export async function completeMultiPartUpload(config, fetchFn, params) {
|
|
|
39
39
|
}
|
|
40
40
|
const responseData = result.value;
|
|
41
41
|
if (responseData.fileManager.completeMultiPartUpload.error) {
|
|
42
|
-
|
|
43
|
-
GraphQLError
|
|
44
|
-
} = await import("../../errors.js");
|
|
45
|
-
return Result.fail(new GraphQLError(responseData.fileManager.completeMultiPartUpload.error.message, responseData.fileManager.completeMultiPartUpload.error.code));
|
|
42
|
+
return Result.fail(new ApiError(responseData.fileManager.completeMultiPartUpload.error.message, responseData.fileManager.completeMultiPartUpload.error.code));
|
|
46
43
|
}
|
|
47
44
|
return Result.ok(responseData.fileManager.completeMultiPartUpload.data);
|
|
48
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Result","completeMultiPartUpload","config","fetchFn","params","fileKey","uploadId","
|
|
1
|
+
{"version":3,"names":["Result","executeGraphQL","ApiError","completeMultiPartUpload","config","fetchFn","params","fileKey","uploadId","query","result","isFail","fail","error","responseData","value","fileManager","message","code","ok","data"],"sources":["completeMultiPartUpload.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 CompleteMultiPartUploadParams {\n fileKey: string;\n uploadId: string;\n}\n\n/**\n * Completes a multi-part upload.\n *\n * @param config - SDK configuration\n * @param fetchFn - Fetch function to use for HTTP requests\n * @param params - Parameters for completing the multi-part upload\n * @param params.fileKey - S3 key of the uploaded file\n * @param params.uploadId - Upload ID from createMultiPartUpload\n * @returns Result containing true on success or an error\n */\n// Not using createMethod: params include raw upload part data that Zod cannot validate.\nexport async function completeMultiPartUpload(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: CompleteMultiPartUploadParams\n): Promise<Result<boolean, HttpError | ApiError | NetworkError>> {\n const { fileKey, uploadId } = params;\n\n const query = `\n mutation CompleteMultiPartUpload($fileKey: String!, $uploadId: String!) {\n fileManager {\n completeMultiPartUpload(fileKey: $fileKey, uploadId: $uploadId) {\n data\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, { fileKey, uploadId });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.fileManager.completeMultiPartUpload.error) {\n return Result.fail(\n new ApiError(\n responseData.fileManager.completeMultiPartUpload.error.message,\n responseData.fileManager.completeMultiPartUpload.error.code\n )\n );\n }\n\n return Result.ok(responseData.fileManager.completeMultiPartUpload.data);\n}\n"],"mappings":"AACA,SAASA,MAAM;AAEf,SAASC,cAAc;AACvB,SAASC,QAAQ;AAOjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,uBAAuBA,CACzCC,MAAoB,EACpBC,OAAqB,EACrBC,MAAqC,EACwB;EAC7D,MAAM;IAAEC,OAAO;IAAEC;EAAS,CAAC,GAAGF,MAAM;EAEpC,MAAMG,KAAK,GAAG;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;EAED,MAAMC,MAAM,GAAG,MAAMT,cAAc,CAACG,MAAM,EAAEC,OAAO,EAAEI,KAAK,EAAE;IAAEF,OAAO;IAAEC;EAAS,CAAC,CAAC;EAElF,IAAIE,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;IACjB,OAAOX,MAAM,CAACY,IAAI,CAACF,MAAM,CAACG,KAAK,CAAC;EACpC;EAEA,MAAMC,YAAY,GAAGJ,MAAM,CAACK,KAAK;EAEjC,IAAID,YAAY,CAACE,WAAW,CAACb,uBAAuB,CAACU,KAAK,EAAE;IACxD,OAAOb,MAAM,CAACY,IAAI,CACd,IAAIV,QAAQ,CACRY,YAAY,CAACE,WAAW,CAACb,uBAAuB,CAACU,KAAK,CAACI,OAAO,EAC9DH,YAAY,CAACE,WAAW,CAACb,uBAAuB,CAACU,KAAK,CAACK,IAC3D,CACJ,CAAC;EACL;EAEA,OAAOlB,MAAM,CAACmB,EAAE,CAACL,YAAY,CAACE,WAAW,CAACb,uBAAuB,CAACiB,IAAI,CAAC;AAC3E","ignoreList":[]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { WebinyConfig } from "../../types.js";
|
|
2
2
|
import { Result } from "../../Result.js";
|
|
3
|
-
import type { HttpError,
|
|
3
|
+
import type { HttpError, NetworkError } from "../../errors.js";
|
|
4
4
|
import type { FmFile, FmIdentity, FmLocationInput, UploadProgress } from "./fileManagerTypes.js";
|
|
5
|
+
import { ApiError } from "../../errors.js";
|
|
5
6
|
export interface CreateFileData {
|
|
6
7
|
id?: string;
|
|
7
8
|
createdOn?: Date | string;
|
|
@@ -42,4 +43,4 @@ export interface CreateFileParams {
|
|
|
42
43
|
* @param params.signal - Optional: AbortSignal for cancellation
|
|
43
44
|
* @returns Result containing the created file data or an error
|
|
44
45
|
*/
|
|
45
|
-
export declare function createFile(config: WebinyConfig, fetchFn: typeof fetch, params: CreateFileParams): Promise<Result<FmFile, HttpError |
|
|
46
|
+
export declare function createFile(config: WebinyConfig, fetchFn: typeof fetch, params: CreateFileParams): Promise<Result<FmFile, HttpError | ApiError | NetworkError>>;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { Result } from "../../Result.js";
|
|
2
2
|
import { getFileSize } from "./utils/fileTypeDetection.js";
|
|
3
3
|
import { buildFieldsSelection } from "./buildFieldsSelection.js";
|
|
4
|
+
import { executeGraphQL } from "../executeGraphQL.js";
|
|
5
|
+
import { ApiError } from "../../errors.js";
|
|
6
|
+
import { getPresignedPostPayload } from "./getPresignedPostPayload.js";
|
|
7
|
+
import { uploadToS3 } from "./utils/uploadToS3.js";
|
|
8
|
+
import { uploadLargeFile } from "./utils/uploadLargeFile.js";
|
|
4
9
|
/**
|
|
5
10
|
* Creates a new file in the file manager.
|
|
6
11
|
* If a file is provided, it will be uploaded to S3 first, then the record is created.
|
|
@@ -16,6 +21,7 @@ import { buildFieldsSelection } from "./buildFieldsSelection.js";
|
|
|
16
21
|
* @param params.signal - Optional: AbortSignal for cancellation
|
|
17
22
|
* @returns Result containing the created file data or an error
|
|
18
23
|
*/
|
|
24
|
+
// Not using createMethod: params include File/Buffer/Blob, onProgress callback, and AbortSignal — types Zod cannot validate.
|
|
19
25
|
export async function createFile(config, fetchFn, params) {
|
|
20
26
|
const {
|
|
21
27
|
file,
|
|
@@ -59,9 +65,6 @@ export async function createFile(config, fetchFn, params) {
|
|
|
59
65
|
*/
|
|
60
66
|
async function uploadSmallFile(config, fetchFn, file, data, fields, onProgress, signal) {
|
|
61
67
|
// 1. Get presigned POST payload.
|
|
62
|
-
const {
|
|
63
|
-
getPresignedPostPayload
|
|
64
|
-
} = await import("./getPresignedPostPayload.js");
|
|
65
68
|
const presignedResult = await getPresignedPostPayload(config, fetchFn, {
|
|
66
69
|
name: data.name,
|
|
67
70
|
type: data.type,
|
|
@@ -74,9 +77,6 @@ async function uploadSmallFile(config, fetchFn, file, data, fields, onProgress,
|
|
|
74
77
|
}
|
|
75
78
|
|
|
76
79
|
// 2. Upload to S3.
|
|
77
|
-
const {
|
|
78
|
-
uploadToS3
|
|
79
|
-
} = await import("./utils/uploadToS3.js");
|
|
80
80
|
await uploadToS3(file, presignedResult.value.data, {
|
|
81
81
|
onProgress,
|
|
82
82
|
signal
|
|
@@ -97,9 +97,6 @@ async function uploadSmallFile(config, fetchFn, file, data, fields, onProgress,
|
|
|
97
97
|
*/
|
|
98
98
|
async function uploadLargeFileWrapper(config, fetchFn, file, data, fields, onProgress, signal) {
|
|
99
99
|
try {
|
|
100
|
-
const {
|
|
101
|
-
uploadLargeFile
|
|
102
|
-
} = await import("./utils/uploadLargeFile.js");
|
|
103
100
|
const uploadedFile = await uploadLargeFile(file, {
|
|
104
101
|
name: data.name,
|
|
105
102
|
type: data.type,
|
|
@@ -130,9 +127,6 @@ async function uploadLargeFileWrapper(config, fetchFn, file, data, fields, onPro
|
|
|
130
127
|
* Creates a file record via GraphQL (metadata only).
|
|
131
128
|
*/
|
|
132
129
|
async function createFileRecord(config, fetchFn, data, fields) {
|
|
133
|
-
const {
|
|
134
|
-
executeGraphQL
|
|
135
|
-
} = await import("../executeGraphQL.js");
|
|
136
130
|
const fieldsSelection = buildFieldsSelection(fields);
|
|
137
131
|
const query = `
|
|
138
132
|
mutation CreateFile($data: FmFileCreateInput!) {
|
|
@@ -157,10 +151,7 @@ ${fieldsSelection}
|
|
|
157
151
|
}
|
|
158
152
|
const responseData = result.value;
|
|
159
153
|
if (responseData.fileManager.createFile.error) {
|
|
160
|
-
|
|
161
|
-
GraphQLError
|
|
162
|
-
} = await import("../../errors.js");
|
|
163
|
-
return Result.fail(new GraphQLError(responseData.fileManager.createFile.error.message, responseData.fileManager.createFile.error.code));
|
|
154
|
+
return Result.fail(new ApiError(responseData.fileManager.createFile.error.message, responseData.fileManager.createFile.error.code));
|
|
164
155
|
}
|
|
165
156
|
return Result.ok(responseData.fileManager.createFile.data);
|
|
166
157
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Result","getFileSize","buildFieldsSelection","createFile","config","fetchFn","params","file","data","fields","onProgress","multiPartThreshold","signal","createFileRecord","fileSize","thresholdBytes","name","type","fail","Error","uploadSmallFile","uploadLargeFileWrapper","error","getPresignedPostPayload","presignedResult","size","key","keyPrefix","isFail","uploadToS3","value","fileMetadata","id","uploadLargeFile","uploadedFile","chunkSize","parallelUploads","executeGraphQL","fieldsSelection","query","result","responseData","fileManager","GraphQLError","message","code","ok"],"sources":["createFile.ts"],"sourcesContent":["import type { WebinyConfig } from \"../../types.js\";\nimport { Result } from \"../../Result.js\";\nimport type { HttpError, GraphQLError, NetworkError } from \"../../errors.js\";\nimport type { FmFile, FmIdentity, FmLocationInput, UploadProgress } from \"./fileManagerTypes.js\";\nimport { getFileSize } from \"./utils/fileTypeDetection.js\";\nimport { buildFieldsSelection } from \"./buildFieldsSelection.js\";\n\nexport interface CreateFileData {\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?: FmLocationInput;\n name?: string;\n key?: string;\n keyPrefix?: string;\n type?: string;\n size?: number;\n tags?: string[];\n [key: string]: any;\n}\n\nexport interface CreateFileParams {\n file?: Buffer | Blob | File;\n data: CreateFileData;\n fields: string[];\n onProgress?: (progress: UploadProgress) => void;\n multiPartThreshold?: number;\n signal?: AbortSignal;\n}\n\n/**\n * Creates a new file in the file manager.\n * If a file is provided, it will be uploaded to S3 first, then the record is created.\n * If no file is provided, only the metadata record is created.\n *\n * @param config - SDK configuration\n * @param fetchFn - Fetch function to use for HTTP requests\n * @param params - Parameters for creating the file\n * @param params.file - Optional: The actual file content to upload\n * @param params.data - The file metadata\n * @param params.onProgress - Optional: Progress callback\n * @param params.multiPartThreshold - Optional: Threshold in MB for multi-part upload (default: 100)\n * @param params.signal - Optional: AbortSignal for cancellation\n * @returns Result containing the created file data or an error\n */\nexport async function createFile(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: CreateFileParams\n): Promise<Result<FmFile, HttpError | GraphQLError | NetworkError>> {\n const { file, data, fields, onProgress, multiPartThreshold = 100, signal } = params;\n\n // If no file provided, just create metadata record (existing behavior).\n if (!file) {\n return createFileRecord(config, fetchFn, data, fields);\n }\n\n // File upload flow.\n try {\n const fileSize = getFileSize(file);\n const thresholdBytes = multiPartThreshold * 1024 * 1024;\n\n // Ensure we have required metadata for upload.\n if (!data.name || !data.type) {\n return Result.fail(new Error(\"File name and type are required for upload\") as any);\n }\n\n // Decide upload strategy based on file size.\n if (fileSize < thresholdBytes) {\n // Simple upload.\n return await uploadSmallFile(config, fetchFn, file, data, fields, onProgress, signal);\n } else {\n // Multi-part upload.\n return await uploadLargeFileWrapper(\n config,\n fetchFn,\n file,\n data,\n fields,\n onProgress,\n signal\n );\n }\n } catch (error) {\n return Result.fail(error as any);\n }\n}\n\n/**\n * Uploads a small file using simple presigned POST.\n */\nasync function uploadSmallFile(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n file: Buffer | Blob | File,\n data: CreateFileData,\n fields: string[],\n onProgress?: (progress: UploadProgress) => void,\n signal?: AbortSignal\n): Promise<Result<FmFile, HttpError | GraphQLError | NetworkError>> {\n // 1. Get presigned POST payload.\n const { getPresignedPostPayload } = await import(\"./getPresignedPostPayload.js\");\n const presignedResult = await getPresignedPostPayload(config, fetchFn, {\n name: data.name!,\n type: data.type!,\n size: getFileSize(file),\n key: data.key,\n keyPrefix: data.keyPrefix\n });\n\n if (presignedResult.isFail()) {\n return Result.fail(presignedResult.error);\n }\n\n // 2. Upload to S3.\n const { uploadToS3 } = await import(\"./utils/uploadToS3.js\");\n await uploadToS3(file, presignedResult.value.data, { onProgress, signal });\n\n // 3. Create file record with S3 key from presigned response.\n const fileMetadata: CreateFileData = {\n ...data,\n id: presignedResult.value.file.id,\n key: presignedResult.value.file.key,\n size: presignedResult.value.file.size\n };\n\n return createFileRecord(config, fetchFn, fileMetadata, fields);\n}\n\n/**\n * Uploads a large file using multi-part upload.\n */\nasync function uploadLargeFileWrapper(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n file: Buffer | Blob | File,\n data: CreateFileData,\n fields: string[],\n onProgress?: (progress: UploadProgress) => void,\n signal?: AbortSignal\n): Promise<Result<FmFile, HttpError | GraphQLError | NetworkError>> {\n try {\n const { uploadLargeFile } = await import(\"./utils/uploadLargeFile.js\");\n const uploadedFile = await uploadLargeFile(\n file,\n {\n name: data.name!,\n type: data.type!,\n size: getFileSize(file),\n key: data.key,\n keyPrefix: data.keyPrefix\n },\n config,\n fetchFn,\n { onProgress, signal, chunkSize: 50, parallelUploads: 5 }\n );\n\n // Create file record with uploaded metadata.\n const fileMetadata: CreateFileData = {\n ...data,\n id: uploadedFile.id,\n key: uploadedFile.key,\n size: uploadedFile.size\n };\n\n return createFileRecord(config, fetchFn, fileMetadata, fields);\n } catch (error) {\n return Result.fail(error as any);\n }\n}\n\n/**\n * Creates a file record via GraphQL (metadata only).\n */\nasync function createFileRecord(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n data: CreateFileData,\n fields: string[]\n): Promise<Result<FmFile, HttpError | GraphQLError | NetworkError>> {\n const { executeGraphQL } = await import(\"../executeGraphQL.js\");\n\n const fieldsSelection = buildFieldsSelection(fields);\n\n const query = `\n mutation CreateFile($data: FmFileCreateInput!) {\n fileManager {\n createFile(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, { data });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.fileManager.createFile.error) {\n const { GraphQLError } = await import(\"../../errors.js\");\n return Result.fail(\n new GraphQLError(\n responseData.fileManager.createFile.error.message,\n responseData.fileManager.createFile.error.code\n )\n );\n }\n\n return Result.ok(responseData.fileManager.createFile.data);\n}\n"],"mappings":"AACA,SAASA,MAAM;AAGf,SAASC,WAAW;AACpB,SAASC,oBAAoB;AA6B7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,UAAUA,CAC5BC,MAAoB,EACpBC,OAAqB,EACrBC,MAAwB,EACwC;EAChE,MAAM;IAAEC,IAAI;IAAEC,IAAI;IAAEC,MAAM;IAAEC,UAAU;IAAEC,kBAAkB,GAAG,GAAG;IAAEC;EAAO,CAAC,GAAGN,MAAM;;EAEnF;EACA,IAAI,CAACC,IAAI,EAAE;IACP,OAAOM,gBAAgB,CAACT,MAAM,EAAEC,OAAO,EAAEG,IAAI,EAAEC,MAAM,CAAC;EAC1D;;EAEA;EACA,IAAI;IACA,MAAMK,QAAQ,GAAGb,WAAW,CAACM,IAAI,CAAC;IAClC,MAAMQ,cAAc,GAAGJ,kBAAkB,GAAG,IAAI,GAAG,IAAI;;IAEvD;IACA,IAAI,CAACH,IAAI,CAACQ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vC,UAAU,CAACK,IAAI,CAAC;AAC9D","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Result","getFileSize","buildFieldsSelection","executeGraphQL","ApiError","getPresignedPostPayload","uploadToS3","uploadLargeFile","createFile","config","fetchFn","params","file","data","fields","onProgress","multiPartThreshold","signal","createFileRecord","fileSize","thresholdBytes","name","type","fail","Error","uploadSmallFile","uploadLargeFileWrapper","error","presignedResult","size","key","keyPrefix","isFail","value","fileMetadata","id","uploadedFile","chunkSize","parallelUploads","fieldsSelection","query","result","responseData","fileManager","message","code","ok"],"sources":["createFile.ts"],"sourcesContent":["import type { WebinyConfig } from \"../../types.js\";\nimport { Result } from \"../../Result.js\";\nimport type { HttpError, NetworkError } from \"../../errors.js\";\nimport type { FmFile, FmIdentity, FmLocationInput, UploadProgress } from \"./fileManagerTypes.js\";\nimport { getFileSize } from \"./utils/fileTypeDetection.js\";\nimport { buildFieldsSelection } from \"./buildFieldsSelection.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.js\";\nimport { getPresignedPostPayload } from \"./getPresignedPostPayload.js\";\nimport { uploadToS3 } from \"./utils/uploadToS3.js\";\nimport { uploadLargeFile } from \"./utils/uploadLargeFile.js\";\n\nexport interface CreateFileData {\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?: FmLocationInput;\n name?: string;\n key?: string;\n keyPrefix?: string;\n type?: string;\n size?: number;\n tags?: string[];\n [key: string]: any;\n}\n\nexport interface CreateFileParams {\n file?: Buffer | Blob | File;\n data: CreateFileData;\n fields: string[];\n onProgress?: (progress: UploadProgress) => void;\n multiPartThreshold?: number;\n signal?: AbortSignal;\n}\n\n/**\n * Creates a new file in the file manager.\n * If a file is provided, it will be uploaded to S3 first, then the record is created.\n * If no file is provided, only the metadata record is created.\n *\n * @param config - SDK configuration\n * @param fetchFn - Fetch function to use for HTTP requests\n * @param params - Parameters for creating the file\n * @param params.file - Optional: The actual file content to upload\n * @param params.data - The file metadata\n * @param params.onProgress - Optional: Progress callback\n * @param params.multiPartThreshold - Optional: Threshold in MB for multi-part upload (default: 100)\n * @param params.signal - Optional: AbortSignal for cancellation\n * @returns Result containing the created file data or an error\n */\n// Not using createMethod: params include File/Buffer/Blob, onProgress callback, and AbortSignal — types Zod cannot validate.\nexport async function createFile(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: CreateFileParams\n): Promise<Result<FmFile, HttpError | ApiError | NetworkError>> {\n const { file, data, fields, onProgress, multiPartThreshold = 100, signal } = params;\n\n // If no file provided, just create metadata record (existing behavior).\n if (!file) {\n return createFileRecord(config, fetchFn, data, fields);\n }\n\n // File upload flow.\n try {\n const fileSize = getFileSize(file);\n const thresholdBytes = multiPartThreshold * 1024 * 1024;\n\n // Ensure we have required metadata for upload.\n if (!data.name || !data.type) {\n return Result.fail(new Error(\"File name and type are required for upload\") as any);\n }\n\n // Decide upload strategy based on file size.\n if (fileSize < thresholdBytes) {\n // Simple upload.\n return await uploadSmallFile(config, fetchFn, file, data, fields, onProgress, signal);\n } else {\n // Multi-part upload.\n return await uploadLargeFileWrapper(\n config,\n fetchFn,\n file,\n data,\n fields,\n onProgress,\n signal\n );\n }\n } catch (error) {\n return Result.fail(error as any);\n }\n}\n\n/**\n * Uploads a small file using simple presigned POST.\n */\nasync function uploadSmallFile(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n file: Buffer | Blob | File,\n data: CreateFileData,\n fields: string[],\n onProgress?: (progress: UploadProgress) => void,\n signal?: AbortSignal\n): Promise<Result<FmFile, HttpError | ApiError | NetworkError>> {\n // 1. Get presigned POST payload.\n const presignedResult = await getPresignedPostPayload(config, fetchFn, {\n name: data.name!,\n type: data.type!,\n size: getFileSize(file),\n key: data.key,\n keyPrefix: data.keyPrefix\n });\n\n if (presignedResult.isFail()) {\n return Result.fail(presignedResult.error);\n }\n\n // 2. Upload to S3.\n await uploadToS3(file, presignedResult.value.data, { onProgress, signal });\n\n // 3. Create file record with S3 key from presigned response.\n const fileMetadata: CreateFileData = {\n ...data,\n id: presignedResult.value.file.id,\n key: presignedResult.value.file.key,\n size: presignedResult.value.file.size\n };\n\n return createFileRecord(config, fetchFn, fileMetadata, fields);\n}\n\n/**\n * Uploads a large file using multi-part upload.\n */\nasync function uploadLargeFileWrapper(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n file: Buffer | Blob | File,\n data: CreateFileData,\n fields: string[],\n onProgress?: (progress: UploadProgress) => void,\n signal?: AbortSignal\n): Promise<Result<FmFile, HttpError | ApiError | NetworkError>> {\n try {\n const uploadedFile = await uploadLargeFile(\n file,\n {\n name: data.name!,\n type: data.type!,\n size: getFileSize(file),\n key: data.key,\n keyPrefix: data.keyPrefix\n },\n config,\n fetchFn,\n { onProgress, signal, chunkSize: 50, parallelUploads: 5 }\n );\n\n // Create file record with uploaded metadata.\n const fileMetadata: CreateFileData = {\n ...data,\n id: uploadedFile.id,\n key: uploadedFile.key,\n size: uploadedFile.size\n };\n\n return createFileRecord(config, fetchFn, fileMetadata, fields);\n } catch (error) {\n return Result.fail(error as any);\n }\n}\n\n/**\n * Creates a file record via GraphQL (metadata only).\n */\nasync function createFileRecord(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n data: CreateFileData,\n fields: string[]\n): Promise<Result<FmFile, HttpError | ApiError | NetworkError>> {\n const fieldsSelection = buildFieldsSelection(fields);\n\n const query = `\n mutation CreateFile($data: FmFileCreateInput!) {\n fileManager {\n createFile(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, { data });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.fileManager.createFile.error) {\n return Result.fail(\n new ApiError(\n responseData.fileManager.createFile.error.message,\n responseData.fileManager.createFile.error.code\n )\n );\n }\n\n return Result.ok(respon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,MAAM,CAACuB,IAAI,CAACkB,MAAM,CAACd,KAAK,CAAC;EACpC;EAEA,MAAMe,YAAY,GAAGD,MAAM,CAACR,KAAK;EAEjC,IAAIS,YAAY,CAACC,WAAW,CAACnC,UAAU,CAACmB,KAAK,EAAE;IAC3C,OAAO3B,MAAM,CAACuB,IAAI,CACd,IAAInB,QAAQ,CACRsC,YAAY,CAACC,WAAW,CAACnC,UAAU,CAACmB,KAAK,CAACiB,OAAO,EACjDF,YAAY,CAACC,WAAW,CAACnC,UAAU,CAACmB,KAAK,CAACkB,IAC9C,CACJ,CAAC;EACL;EAEA,OAAO7C,MAAM,CAAC8C,EAAE,CAACJ,YAAY,CAACC,WAAW,CAACnC,UAAU,CAACK,IAAI,CAAC;AAC9D","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { WebinyConfig } from "../../types.js";
|
|
2
2
|
import { Result } from "../../Result.js";
|
|
3
|
-
import type { HttpError,
|
|
3
|
+
import type { HttpError, ApiError, NetworkError } from "../../errors.js";
|
|
4
4
|
import type { FmFile, UploadProgress, BatchUploadStrategy } from "./fileManagerTypes.js";
|
|
5
5
|
import type { CreateFileData } from "./createFile.js";
|
|
6
6
|
export interface CreateFilesParams {
|
|
@@ -37,4 +37,4 @@ export interface CreateFilesResult {
|
|
|
37
37
|
* @param params.signal - Optional: AbortSignal for cancellation
|
|
38
38
|
* @returns Result containing the created files or an error
|
|
39
39
|
*/
|
|
40
|
-
export declare function createFiles(config: WebinyConfig, fetchFn: typeof fetch, params: CreateFilesParams): Promise<Result<CreateFilesResult, HttpError |
|
|
40
|
+
export declare function createFiles(config: WebinyConfig, fetchFn: typeof fetch, params: CreateFilesParams): Promise<Result<CreateFilesResult, HttpError | ApiError | NetworkError>>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Result } from "../../Result.js";
|
|
2
|
+
import { createFile } from "./createFile.js";
|
|
3
|
+
import pMap from "p-map";
|
|
2
4
|
/**
|
|
3
5
|
* Creates multiple files in the file manager.
|
|
4
6
|
* If files are provided, they will be uploaded to S3 first, then records are created.
|
|
@@ -14,6 +16,7 @@ import { Result } from "../../Result.js";
|
|
|
14
16
|
* @param params.signal - Optional: AbortSignal for cancellation
|
|
15
17
|
* @returns Result containing the created files or an error
|
|
16
18
|
*/
|
|
19
|
+
// Not using createMethod: params include File/Buffer/Blob entries and a BatchUploadStrategy callback.
|
|
17
20
|
export async function createFiles(config, fetchFn, params) {
|
|
18
21
|
const {
|
|
19
22
|
files,
|
|
@@ -26,7 +29,7 @@ export async function createFiles(config, fetchFn, params) {
|
|
|
26
29
|
const failed = [];
|
|
27
30
|
|
|
28
31
|
// Use p-map for controlled concurrency.
|
|
29
|
-
|
|
32
|
+
|
|
30
33
|
try {
|
|
31
34
|
await pMap(files, async fileItem => {
|
|
32
35
|
try {
|
|
@@ -36,9 +39,6 @@ export async function createFiles(config, fetchFn, params) {
|
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
// Upload single file.
|
|
39
|
-
const {
|
|
40
|
-
createFile
|
|
41
|
-
} = await import("./createFile.js");
|
|
42
42
|
const result = await createFile(config, fetchFn, {
|
|
43
43
|
file: fileItem.file,
|
|
44
44
|
data: fileItem.data,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Result","createFiles","config","fetchFn","params","files","multiPartThreshold","concurrency","strategy","signal","successful","failed","
|
|
1
|
+
{"version":3,"names":["Result","createFile","pMap","createFiles","config","fetchFn","params","files","multiPartThreshold","concurrency","strategy","signal","successful","failed","fileItem","aborted","Error","result","file","data","fields","onProgress","isOk","push","value","error","ok","fail"],"sources":["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"],"mappings":"AACA,SAASA,MAAM;AAIf,SAASC,UAAU;AACnB,OAAOC,IAAI,MAAM,OAAO;AAuBxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,WAAWA,CAC7BC,MAAoB,EACpBC,OAAqB,EACrBC,MAAyB,EAC8C;EACvE,MAAM;IACFC,KAAK;IACLC,kBAAkB,GAAG,GAAG;IACxBC,WAAW,GAAG,CAAC;IACfC,QAAQ,GAAG,WAAkC;IAC7CC;EACJ,CAAC,GAAGL,MAAM;EAEV,MAAMM,UAAoB,GAAG,EAAE;EAC/B,MAAMC,MAAqD,GAAG,EAAE;;EAEhE;;EAEA,IAAI;IACA,MAAMX,IAAI,CACNK,KAAK,EACL,MAAMO,QAAQ,IAAI;MACd,IAAI;QACA;QACA,IAAIH,MAAM,EAAEI,OAAO,EAAE;UACjB,MAAM,IAAIC,KAAK,CAAC,gBAAgB,CAAC;QACrC;;QAEA;QACA,MAAMC,MAAM,GAAG,MAAMhB,UAAU,CAACG,MAAM,EAAEC,OAAO,EAAE;UAC7Ca,IAAI,EAAEJ,QAAQ,CAACI,IAAI;UACnBC,IAAI,EAAEL,QAAQ,CAACK,IAAI;UACnBC,MAAM,EAAEN,QAAQ,CAACM,MAAM;UACvBC,UAAU,EAAEP,QAAQ,CAACO,UAAU;UAC/Bb,kBAAkB;UAClBG;QACJ,CAAC,CAAC;QAEF,IAAIM,MAAM,CAACK,IAAI,CAAC,CAAC,EAAE;UACfV,UAAU,CAACW,IAAI,CAACN,MAAM,CAACO,KAAK,CAAC;QACjC,CAAC,MAAM;UACH,IAAId,QAAQ,KAAK,WAAW,EAAE;YAC1B,MAAMO,MAAM,CAACQ,KAAK;UACtB;UACAZ,MAAM,CAACU,IAAI,CAAC;YAAEJ,IAAI,EAAEL,QAAQ,CAACK,IAAI;YAAEM,KAAK,EAAER,MAAM,CAACQ;UAAe,CAAC,CAAC;QACtE;MACJ,CAAC,CAAC,OAAOA,KAAK,EAAE;QACZ,IAAIf,QAAQ,KAAK,WAAW,EAAE;UAC1B,MAAMe,KAAK;QACf;QACAZ,MAAM,CAACU,IAAI,CAAC;UAAEJ,IAAI,EAAEL,QAAQ,CAACK,IAAI;UAAEM,KAAK,EAAEA;QAAe,CAAC,CAAC;MAC/D;IACJ,CAAC,EACD;MAAEhB;IAAY,CAClB,CAAC;IAED,OAAOT,MAAM,CAAC0B,EAAE,CAAC;MAAEd,UAAU;MAAEC;IAAO,CAAC,CAAC;EAC5C,CAAC,CAAC,OAAOY,KAAK,EAAE;IACZ;IACA,OAAOzB,MAAM,CAAC2B,IAAI,CAACF,KAAY,CAAC;EACpC;AACJ","ignoreList":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { WebinyConfig } from "../../types.js";
|
|
2
2
|
import { Result } from "../../Result.js";
|
|
3
|
-
import type { HttpError,
|
|
3
|
+
import type { HttpError, NetworkError } from "../../errors.js";
|
|
4
|
+
import { ApiError } from "../../errors.js";
|
|
4
5
|
export interface CreateMultiPartUploadParams {
|
|
5
6
|
data: {
|
|
6
7
|
name: string;
|
|
@@ -35,4 +36,4 @@ export interface MultiPartUploadResponse {
|
|
|
35
36
|
* @param params.numberOfParts - Number of parts to split the file into
|
|
36
37
|
* @returns Result containing the multi-part upload data or an error
|
|
37
38
|
*/
|
|
38
|
-
export declare function createMultiPartUpload(config: WebinyConfig, fetchFn: typeof fetch, params: CreateMultiPartUploadParams): Promise<Result<MultiPartUploadResponse, HttpError |
|
|
39
|
+
export declare function createMultiPartUpload(config: WebinyConfig, fetchFn: typeof fetch, params: CreateMultiPartUploadParams): Promise<Result<MultiPartUploadResponse, HttpError | ApiError | NetworkError>>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Result } from "../../Result.js";
|
|
2
|
+
import { executeGraphQL } from "../executeGraphQL.js";
|
|
3
|
+
import { ApiError } from "../../errors.js";
|
|
2
4
|
/**
|
|
3
5
|
* Creates a multi-part upload for a large file.
|
|
4
6
|
*
|
|
@@ -9,14 +11,12 @@ import { Result } from "../../Result.js";
|
|
|
9
11
|
* @param params.numberOfParts - Number of parts to split the file into
|
|
10
12
|
* @returns Result containing the multi-part upload data or an error
|
|
11
13
|
*/
|
|
14
|
+
// Not using createMethod: params include File/Buffer/Blob and an onProgress callback.
|
|
12
15
|
export async function createMultiPartUpload(config, fetchFn, params) {
|
|
13
16
|
const {
|
|
14
17
|
data,
|
|
15
18
|
numberOfParts
|
|
16
19
|
} = params;
|
|
17
|
-
const {
|
|
18
|
-
executeGraphQL
|
|
19
|
-
} = await import("../executeGraphQL.js");
|
|
20
20
|
const query = `
|
|
21
21
|
mutation CreateMultiPartUpload($data: PreSignedPostPayloadInput!, $numberOfParts: Number!) {
|
|
22
22
|
fileManager {
|
|
@@ -52,10 +52,7 @@ export async function createMultiPartUpload(config, fetchFn, params) {
|
|
|
52
52
|
}
|
|
53
53
|
const responseData = result.value;
|
|
54
54
|
if (responseData.fileManager.createMultiPartUpload.error) {
|
|
55
|
-
|
|
56
|
-
GraphQLError
|
|
57
|
-
} = await import("../../errors.js");
|
|
58
|
-
return Result.fail(new GraphQLError(responseData.fileManager.createMultiPartUpload.error.message, responseData.fileManager.createMultiPartUpload.error.code));
|
|
55
|
+
return Result.fail(new ApiError(responseData.fileManager.createMultiPartUpload.error.message, responseData.fileManager.createMultiPartUpload.error.code));
|
|
59
56
|
}
|
|
60
57
|
return Result.ok(responseData.fileManager.createMultiPartUpload.data);
|
|
61
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Result","createMultiPartUpload","config","fetchFn","params","data","numberOfParts","
|
|
1
|
+
{"version":3,"names":["Result","executeGraphQL","ApiError","createMultiPartUpload","config","fetchFn","params","data","numberOfParts","query","result","isFail","fail","error","responseData","value","fileManager","message","code","ok"],"sources":["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"],"mappings":"AACA,SAASA,MAAM;AAEf,SAASC,cAAc;AACvB,SAASC,QAAQ;AA4BjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,qBAAqBA,CACvCC,MAAoB,EACpBC,OAAqB,EACrBC,MAAmC,EAC0C;EAC7E,MAAM;IAAEC,IAAI;IAAEC;EAAc,CAAC,GAAGF,MAAM;EAEtC,MAAMG,KAAK,GAAG;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;EAED,MAAMC,MAAM,GAAG,MAAMT,cAAc,CAACG,MAAM,EAAEC,OAAO,EAAEI,KAAK,EAAE;IAAEF,IAAI;IAAEC;EAAc,CAAC,CAAC;EAEpF,IAAIE,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;IACjB,OAAOX,MAAM,CAACY,IAAI,CAACF,MAAM,CAACG,KAAK,CAAC;EACpC;EAEA,MAAMC,YAAY,GAAGJ,MAAM,CAACK,KAAK;EAEjC,IAAID,YAAY,CAACE,WAAW,CAACb,qBAAqB,CAACU,KAAK,EAAE;IACtD,OAAOb,MAAM,CAACY,IAAI,CACd,IAAIV,QAAQ,CACRY,YAAY,CAACE,WAAW,CAACb,qBAAqB,CAACU,KAAK,CAACI,OAAO,EAC5DH,YAAY,CAACE,WAAW,CAACb,qBAAqB,CAACU,KAAK,CAACK,IACzD,CACJ,CAAC;EACL;EAEA,OAAOlB,MAAM,CAACmB,EAAE,CAACL,YAAY,CAACE,WAAW,CAACb,qBAAqB,CAACI,IAAI,CAAC;AACzE","ignoreList":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { WebinyConfig } from "../../types.js";
|
|
2
2
|
import { Result } from "../../Result.js";
|
|
3
|
-
import type { HttpError,
|
|
3
|
+
import type { HttpError, NetworkError } from "../../errors.js";
|
|
4
|
+
import { ApiError } from "../../errors.js";
|
|
4
5
|
export interface DeleteFileParams {
|
|
5
6
|
id: string;
|
|
6
7
|
}
|
|
@@ -13,4 +14,4 @@ export interface DeleteFileParams {
|
|
|
13
14
|
* @param params.id - ID of the file to delete
|
|
14
15
|
* @returns Result containing true on success or an error
|
|
15
16
|
*/
|
|
16
|
-
export declare function deleteFile(config: WebinyConfig, fetchFn: typeof fetch, params: DeleteFileParams): Promise<Result<boolean, HttpError |
|
|
17
|
+
export declare function deleteFile(config: WebinyConfig, fetchFn: typeof fetch, params: DeleteFileParams): Promise<Result<boolean, HttpError | ApiError | NetworkError>>;
|