@webiny/sdk 6.0.0 → 6.1.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/FileManagerSdk.d.ts +31 -0
- package/FileManagerSdk.js +52 -0
- package/FileManagerSdk.js.map +1 -0
- package/TenantManagerSdk.d.ts +18 -0
- package/TenantManagerSdk.js +28 -0
- package/TenantManagerSdk.js.map +1 -0
- package/Webiny.d.ts +4 -0
- package/Webiny.js +10 -0
- package/Webiny.js.map +1 -1
- package/index.d.ts +19 -0
- package/index.js +10 -0
- package/index.js.map +1 -1
- package/methods/cms/listEntries.d.ts +2 -0
- package/methods/cms/listEntries.js +5 -0
- package/methods/cms/listEntries.js.map +1 -1
- package/methods/fileManager/buildFieldsSelection.d.ts +22 -0
- package/methods/fileManager/buildFieldsSelection.js +71 -0
- package/methods/fileManager/buildFieldsSelection.js.map +1 -0
- package/methods/fileManager/completeMultiPartUpload.d.ts +18 -0
- package/methods/fileManager/completeMultiPartUpload.js +50 -0
- package/methods/fileManager/completeMultiPartUpload.js.map +1 -0
- package/methods/fileManager/createFile.d.ts +45 -0
- package/methods/fileManager/createFile.js +168 -0
- package/methods/fileManager/createFile.js.map +1 -0
- package/methods/fileManager/createFiles.d.ts +40 -0
- package/methods/fileManager/createFiles.js +83 -0
- package/methods/fileManager/createFiles.js.map +1 -0
- package/methods/fileManager/createMultiPartUpload.d.ts +38 -0
- package/methods/fileManager/createMultiPartUpload.js +63 -0
- package/methods/fileManager/createMultiPartUpload.js.map +1 -0
- package/methods/fileManager/deleteFile.d.ts +16 -0
- package/methods/fileManager/deleteFile.js +47 -0
- package/methods/fileManager/deleteFile.js.map +1 -0
- package/methods/fileManager/fileManagerTypes.d.ts +117 -0
- package/methods/fileManager/fileManagerTypes.js +22 -0
- package/methods/fileManager/fileManagerTypes.js.map +1 -0
- package/methods/fileManager/getFile.d.ts +18 -0
- package/methods/fileManager/getFile.js +52 -0
- package/methods/fileManager/getFile.js.map +1 -0
- package/methods/fileManager/getPresignedPostPayload.d.ts +25 -0
- package/methods/fileManager/getPresignedPostPayload.js +70 -0
- package/methods/fileManager/getPresignedPostPayload.js.map +1 -0
- package/methods/fileManager/getPresignedPostPayloads.d.ts +18 -0
- package/methods/fileManager/getPresignedPostPayloads.js +62 -0
- package/methods/fileManager/getPresignedPostPayloads.js.map +1 -0
- package/methods/fileManager/listFiles.d.ts +30 -0
- package/methods/fileManager/listFiles.js +72 -0
- package/methods/fileManager/listFiles.js.map +1 -0
- package/methods/fileManager/listTags.d.ts +17 -0
- package/methods/fileManager/listTags.js +50 -0
- package/methods/fileManager/listTags.js.map +1 -0
- package/methods/fileManager/updateFile.d.ts +35 -0
- package/methods/fileManager/updateFile.js +55 -0
- package/methods/fileManager/updateFile.js.map +1 -0
- package/methods/fileManager/utils/fileTypeDetection.d.ts +4 -0
- package/methods/fileManager/utils/fileTypeDetection.js +19 -0
- package/methods/fileManager/utils/fileTypeDetection.js.map +1 -0
- package/methods/fileManager/utils/uploadLargeFile.d.ts +25 -0
- package/methods/fileManager/utils/uploadLargeFile.js +187 -0
- package/methods/fileManager/utils/uploadLargeFile.js.map +1 -0
- package/methods/fileManager/utils/uploadToS3.d.ts +14 -0
- package/methods/fileManager/utils/uploadToS3.js +105 -0
- package/methods/fileManager/utils/uploadToS3.js.map +1 -0
- package/methods/tenantManager/createTenant.d.ts +17 -0
- package/methods/tenantManager/createTenant.js +47 -0
- package/methods/tenantManager/createTenant.js.map +1 -0
- package/methods/tenantManager/disableTenant.d.ts +16 -0
- package/methods/tenantManager/disableTenant.js +47 -0
- package/methods/tenantManager/disableTenant.js.map +1 -0
- package/methods/tenantManager/enableTenant.d.ts +16 -0
- package/methods/tenantManager/enableTenant.js +47 -0
- package/methods/tenantManager/enableTenant.js.map +1 -0
- package/methods/tenantManager/getCurrentTenant.d.ts +15 -0
- package/methods/tenantManager/getCurrentTenant.js +43 -0
- package/methods/tenantManager/getCurrentTenant.js.map +1 -0
- package/methods/tenantManager/installTenant.d.ts +16 -0
- package/methods/tenantManager/installTenant.js +47 -0
- package/methods/tenantManager/installTenant.js.map +1 -0
- package/methods/tenantManager/tenantManagerTypes.d.ts +5 -0
- package/methods/tenantManager/tenantManagerTypes.js +3 -0
- package/methods/tenantManager/tenantManagerTypes.js.map +1 -0
- package/package.json +16 -4
- package/utils/platform.d.ts +2 -0
- package/utils/platform.js +4 -0
- package/utils/platform.js.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["FmFileListSorter","BatchUploadStrategy"],"sources":["fileManagerTypes.ts"],"sourcesContent":["export interface FmIdentity {\n id: string;\n displayName: string;\n type: string;\n}\n\nexport interface FmLocation {\n folderId: string;\n}\n\nexport interface FmFile_Metadata {\n image?: {\n width?: number;\n height?: number;\n format?: string;\n orientation?: number;\n };\n exif?: Record<string, any>;\n iptc?: Record<string, any>;\n [key: string]: any;\n}\n\nexport type FmFile_AccessControl = {\n type: \"public\" | \"private-authenticated\";\n};\n\nexport interface FmFile {\n id: string;\n createdOn: Date | string;\n modifiedOn?: Date | string;\n savedOn: Date | string;\n createdBy: FmIdentity;\n modifiedBy?: FmIdentity;\n savedBy: FmIdentity;\n location: FmLocation;\n src?: string;\n name?: string;\n key?: string;\n type?: string;\n size?: number;\n metadata?: FmFile_Metadata;\n tags?: string[];\n accessControl?: FmFile_AccessControl;\n [key: string]: any;\n}\n\nexport interface FmTag {\n tag: string;\n count: number;\n}\n\nexport interface FmListMeta {\n cursor: string | null;\n hasMoreItems: boolean;\n totalCount: number;\n}\n\nexport interface FmLocationInput {\n folderId: string;\n}\n\nexport interface FmLocationWhereInput {\n folderId?: string;\n folderId_in?: string[];\n folderId_not?: string;\n folderId_not_in?: string[];\n}\n\nexport interface FmFileListWhereInput {\n location?: FmLocationWhereInput;\n name?: string;\n name_contains?: string;\n name_not_contains?: string;\n type?: string;\n type_in?: string[];\n type_not?: string;\n type_not_in?: string[];\n tags?: string[];\n tags_in?: string[];\n tags_not?: string;\n tags_not_in?: string[];\n AND?: FmFileListWhereInput[];\n OR?: FmFileListWhereInput[];\n}\n\nexport enum FmFileListSorter {\n SAVED_ON_ASC = \"savedOn_ASC\",\n SAVED_ON_DESC = \"savedOn_DESC\",\n CREATED_ON_ASC = \"createdOn_ASC\",\n CREATED_ON_DESC = \"createdOn_DESC\",\n NAME_ASC = \"name_ASC\",\n NAME_DESC = \"name_DESC\",\n KEY_ASC = \"key_ASC\",\n KEY_DESC = \"key_DESC\",\n TYPE_ASC = \"type_ASC\",\n TYPE_DESC = \"type_DESC\",\n SIZE_ASC = \"size_ASC\",\n SIZE_DESC = \"size_DESC\"\n}\n\nexport interface FmTagsListWhereInput {\n createdBy?: string;\n tags_startsWith?: string;\n tags_not_startsWith?: string;\n}\n\nexport interface UploadProgress {\n sent: number;\n total: number;\n percentage: number;\n}\n\nexport interface PresignedPostPayload {\n url: string;\n fields: Record<string, string>;\n}\n\nexport interface PresignedPostPayloadResponse {\n data: PresignedPostPayload;\n file: {\n id: string;\n name: string;\n type: string;\n size: number;\n key: string;\n };\n}\n\nexport enum BatchUploadStrategy {\n FAIL_FAST = \"fail-fast\",\n CONTINUE = \"continue\"\n}\n"],"mappings":"AAqFA,WAAYA,gBAAgB,0BAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAA,OAAhBA,gBAAgB;AAAA;AA2C5B,WAAYC,mBAAmB,0BAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAA,OAAnBA,mBAAmB;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { WebinyConfig } from "../../types.js";
|
|
2
|
+
import { Result } from "../../Result.js";
|
|
3
|
+
import type { HttpError, GraphQLError, NetworkError } from "../../errors.js";
|
|
4
|
+
import type { FmFile } from "./fileManagerTypes.js";
|
|
5
|
+
export interface GetFileParams {
|
|
6
|
+
id: string;
|
|
7
|
+
fields: string[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Gets a single file from the file manager.
|
|
11
|
+
*
|
|
12
|
+
* @param config - SDK configuration
|
|
13
|
+
* @param fetchFn - Fetch function to use for HTTP requests
|
|
14
|
+
* @param params - Parameters for getting the file
|
|
15
|
+
* @param params.id - ID of the file to get
|
|
16
|
+
* @returns Result containing the file data or an error
|
|
17
|
+
*/
|
|
18
|
+
export declare function getFile(config: WebinyConfig, fetchFn: typeof fetch, params: GetFileParams): Promise<Result<FmFile, HttpError | GraphQLError | NetworkError>>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Result } from "../../Result.js";
|
|
2
|
+
import { buildFieldsSelection } from "./buildFieldsSelection.js";
|
|
3
|
+
/**
|
|
4
|
+
* Gets a single file from the file manager.
|
|
5
|
+
*
|
|
6
|
+
* @param config - SDK configuration
|
|
7
|
+
* @param fetchFn - Fetch function to use for HTTP requests
|
|
8
|
+
* @param params - Parameters for getting the file
|
|
9
|
+
* @param params.id - ID of the file to get
|
|
10
|
+
* @returns Result containing the file data or an error
|
|
11
|
+
*/
|
|
12
|
+
export async function getFile(config, fetchFn, params) {
|
|
13
|
+
const {
|
|
14
|
+
id,
|
|
15
|
+
fields
|
|
16
|
+
} = params;
|
|
17
|
+
const {
|
|
18
|
+
executeGraphQL
|
|
19
|
+
} = await import("../executeGraphQL.js");
|
|
20
|
+
const fieldsSelection = buildFieldsSelection(fields);
|
|
21
|
+
const query = `
|
|
22
|
+
query GetFile($id: ID!) {
|
|
23
|
+
fileManager {
|
|
24
|
+
getFile(id: $id) {
|
|
25
|
+
data {
|
|
26
|
+
${fieldsSelection}
|
|
27
|
+
}
|
|
28
|
+
error {
|
|
29
|
+
message
|
|
30
|
+
code
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
const result = await executeGraphQL(config, fetchFn, query, {
|
|
37
|
+
id
|
|
38
|
+
});
|
|
39
|
+
if (result.isFail()) {
|
|
40
|
+
return Result.fail(result.error);
|
|
41
|
+
}
|
|
42
|
+
const responseData = result.value;
|
|
43
|
+
if (responseData.fileManager.getFile.error) {
|
|
44
|
+
const {
|
|
45
|
+
GraphQLError
|
|
46
|
+
} = await import("../../errors.js");
|
|
47
|
+
return Result.fail(new GraphQLError(responseData.fileManager.getFile.error.message, responseData.fileManager.getFile.error.code));
|
|
48
|
+
}
|
|
49
|
+
return Result.ok(responseData.fileManager.getFile.data);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=getFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Result","buildFieldsSelection","getFile","config","fetchFn","params","id","fields","executeGraphQL","fieldsSelection","query","result","isFail","fail","error","responseData","value","fileManager","GraphQLError","message","code","ok","data"],"sources":["getFile.ts"],"sourcesContent":["import type { WebinyConfig } from \"../../types.js\";\nimport { Result } from \"../../Result.js\";\nimport type { HttpError, GraphQLError, NetworkError } from \"../../errors.js\";\nimport type { FmFile } from \"./fileManagerTypes.js\";\nimport { buildFieldsSelection } from \"./buildFieldsSelection.js\";\n\nexport interface GetFileParams {\n id: string;\n fields: string[];\n}\n\n/**\n * Gets a single file from the file manager.\n *\n * @param config - SDK configuration\n * @param fetchFn - Fetch function to use for HTTP requests\n * @param params - Parameters for getting the file\n * @param params.id - ID of the file to get\n * @returns Result containing the file data or an error\n */\nexport async function getFile(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: GetFileParams\n): Promise<Result<FmFile, HttpError | GraphQLError | NetworkError>> {\n const { id, fields } = params;\n\n const { executeGraphQL } = await import(\"../executeGraphQL.js\");\n\n const fieldsSelection = buildFieldsSelection(fields);\n\n const query = `\n query GetFile($id: ID!) {\n fileManager {\n getFile(id: $id) {\n data {\n${fieldsSelection}\n }\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, { id });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.fileManager.getFile.error) {\n const { GraphQLError } = await import(\"../../errors.js\");\n return Result.fail(\n new GraphQLError(\n responseData.fileManager.getFile.error.message,\n responseData.fileManager.getFile.error.code\n )\n );\n }\n\n return Result.ok(responseData.fileManager.getFile.data);\n}\n"],"mappings":"AACA,SAASA,MAAM;AAGf,SAASC,oBAAoB;AAO7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,OAAOA,CACzBC,MAAoB,EACpBC,OAAqB,EACrBC,MAAqB,EAC2C;EAChE,MAAM;IAAEC,EAAE;IAAEC;EAAO,CAAC,GAAGF,MAAM;EAE7B,MAAM;IAAEG;EAAe,CAAC,GAAG,MAAM,MAAM,uBAAuB,CAAC;EAE/D,MAAMC,eAAe,GAAGR,oBAAoB,CAACM,MAAM,CAAC;EAEpD,MAAMG,KAAK,GAAG;AAClB;AACA;AACA;AACA;AACA,EAAED,eAAe;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;EAED,MAAME,MAAM,GAAG,MAAMH,cAAc,CAACL,MAAM,EAAEC,OAAO,EAAEM,KAAK,EAAE;IAAEJ;EAAG,CAAC,CAAC;EAEnE,IAAIK,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;IACjB,OAAOZ,MAAM,CAACa,IAAI,CAACF,MAAM,CAACG,KAAK,CAAC;EACpC;EAEA,MAAMC,YAAY,GAAGJ,MAAM,CAACK,KAAK;EAEjC,IAAID,YAAY,CAACE,WAAW,CAACf,OAAO,CAACY,KAAK,EAAE;IACxC,MAAM;MAAEI;IAAa,CAAC,GAAG,MAAM,MAAM,kBAAkB,CAAC;IACxD,OAAOlB,MAAM,CAACa,IAAI,CACd,IAAIK,YAAY,CACZH,YAAY,CAACE,WAAW,CAACf,OAAO,CAACY,KAAK,CAACK,OAAO,EAC9CJ,YAAY,CAACE,WAAW,CAACf,OAAO,CAACY,KAAK,CAACM,IAC3C,CACJ,CAAC;EACL;EAEA,OAAOpB,MAAM,CAACqB,EAAE,CAACN,YAAY,CAACE,WAAW,CAACf,OAAO,CAACoB,IAAI,CAAC;AAC3D","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { WebinyConfig } from "../../types.js";
|
|
2
|
+
import { Result } from "../../Result.js";
|
|
3
|
+
import type { HttpError, GraphQLError, NetworkError } from "../../errors.js";
|
|
4
|
+
import type { PresignedPostPayloadResponse } from "./fileManagerTypes.js";
|
|
5
|
+
export interface GetPresignedPostPayloadParams {
|
|
6
|
+
name: string;
|
|
7
|
+
type: string;
|
|
8
|
+
size: number;
|
|
9
|
+
key?: string;
|
|
10
|
+
keyPrefix?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Gets a presigned POST payload for uploading a file to S3.
|
|
14
|
+
*
|
|
15
|
+
* @param config - SDK configuration
|
|
16
|
+
* @param fetchFn - Fetch function to use for HTTP requests
|
|
17
|
+
* @param params - Parameters for getting the presigned POST payload
|
|
18
|
+
* @param params.name - File name
|
|
19
|
+
* @param params.type - File MIME type
|
|
20
|
+
* @param params.size - File size in bytes
|
|
21
|
+
* @param params.key - Optional custom S3 key
|
|
22
|
+
* @param params.keyPrefix - Optional custom key prefix
|
|
23
|
+
* @returns Result containing the presigned POST payload or an error
|
|
24
|
+
*/
|
|
25
|
+
export declare function getPresignedPostPayload(config: WebinyConfig, fetchFn: typeof fetch, params: GetPresignedPostPayloadParams): Promise<Result<PresignedPostPayloadResponse, HttpError | GraphQLError | NetworkError>>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Result } from "../../Result.js";
|
|
2
|
+
/**
|
|
3
|
+
* Gets a presigned POST payload for uploading a file to S3.
|
|
4
|
+
*
|
|
5
|
+
* @param config - SDK configuration
|
|
6
|
+
* @param fetchFn - Fetch function to use for HTTP requests
|
|
7
|
+
* @param params - Parameters for getting the presigned POST payload
|
|
8
|
+
* @param params.name - File name
|
|
9
|
+
* @param params.type - File MIME type
|
|
10
|
+
* @param params.size - File size in bytes
|
|
11
|
+
* @param params.key - Optional custom S3 key
|
|
12
|
+
* @param params.keyPrefix - Optional custom key prefix
|
|
13
|
+
* @returns Result containing the presigned POST payload or an error
|
|
14
|
+
*/
|
|
15
|
+
export async function getPresignedPostPayload(config, fetchFn, params) {
|
|
16
|
+
const {
|
|
17
|
+
name,
|
|
18
|
+
type,
|
|
19
|
+
size,
|
|
20
|
+
key,
|
|
21
|
+
keyPrefix
|
|
22
|
+
} = params;
|
|
23
|
+
const {
|
|
24
|
+
executeGraphQL
|
|
25
|
+
} = await import("../executeGraphQL.js");
|
|
26
|
+
const query = `
|
|
27
|
+
query GetPreSignedPostPayload($data: PreSignedPostPayloadInput!) {
|
|
28
|
+
fileManager {
|
|
29
|
+
getPreSignedPostPayload(data: $data) {
|
|
30
|
+
data {
|
|
31
|
+
data
|
|
32
|
+
file {
|
|
33
|
+
id
|
|
34
|
+
name
|
|
35
|
+
type
|
|
36
|
+
size
|
|
37
|
+
key
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
error {
|
|
41
|
+
message
|
|
42
|
+
code
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
const result = await executeGraphQL(config, fetchFn, query, {
|
|
49
|
+
data: {
|
|
50
|
+
name,
|
|
51
|
+
type,
|
|
52
|
+
size,
|
|
53
|
+
key,
|
|
54
|
+
keyPrefix
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
if (result.isFail()) {
|
|
58
|
+
return Result.fail(result.error);
|
|
59
|
+
}
|
|
60
|
+
const responseData = result.value;
|
|
61
|
+
if (responseData.fileManager.getPreSignedPostPayload.error) {
|
|
62
|
+
const {
|
|
63
|
+
GraphQLError
|
|
64
|
+
} = await import("../../errors.js");
|
|
65
|
+
return Result.fail(new GraphQLError(responseData.fileManager.getPreSignedPostPayload.error.message, responseData.fileManager.getPreSignedPostPayload.error.code));
|
|
66
|
+
}
|
|
67
|
+
return Result.ok(responseData.fileManager.getPreSignedPostPayload.data);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=getPresignedPostPayload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Result","getPresignedPostPayload","config","fetchFn","params","name","type","size","key","keyPrefix","executeGraphQL","query","result","data","isFail","fail","error","responseData","value","fileManager","getPreSignedPostPayload","GraphQLError","message","code","ok"],"sources":["getPresignedPostPayload.ts"],"sourcesContent":["import type { WebinyConfig } from \"../../types.js\";\nimport { Result } from \"../../Result.js\";\nimport type { HttpError, GraphQLError, NetworkError } from \"../../errors.js\";\nimport type { PresignedPostPayloadResponse } from \"./fileManagerTypes.js\";\n\nexport interface GetPresignedPostPayloadParams {\n name: string;\n type: string;\n size: number;\n key?: string;\n keyPrefix?: string;\n}\n\n/**\n * Gets a presigned POST payload for uploading a file to S3.\n *\n * @param config - SDK configuration\n * @param fetchFn - Fetch function to use for HTTP requests\n * @param params - Parameters for getting the presigned POST payload\n * @param params.name - File name\n * @param params.type - File MIME type\n * @param params.size - File size in bytes\n * @param params.key - Optional custom S3 key\n * @param params.keyPrefix - Optional custom key prefix\n * @returns Result containing the presigned POST payload or an error\n */\nexport async function getPresignedPostPayload(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: GetPresignedPostPayloadParams\n): Promise<Result<PresignedPostPayloadResponse, HttpError | GraphQLError | NetworkError>> {\n const { name, type, size, key, keyPrefix } = params;\n\n const { executeGraphQL } = await import(\"../executeGraphQL.js\");\n\n const query = `\n query GetPreSignedPostPayload($data: PreSignedPostPayloadInput!) {\n fileManager {\n getPreSignedPostPayload(data: $data) {\n data {\n data\n file {\n id\n name\n type\n size\n key\n }\n }\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, {\n data: { name, type, size, key, keyPrefix }\n });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.fileManager.getPreSignedPostPayload.error) {\n const { GraphQLError } = await import(\"../../errors.js\");\n return Result.fail(\n new GraphQLError(\n responseData.fileManager.getPreSignedPostPayload.error.message,\n responseData.fileManager.getPreSignedPostPayload.error.code\n )\n );\n }\n\n return Result.ok(responseData.fileManager.getPreSignedPostPayload.data);\n}\n"],"mappings":"AACA,SAASA,MAAM;AAYf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,uBAAuBA,CACzCC,MAAoB,EACpBC,OAAqB,EACrBC,MAAqC,EACiD;EACtF,MAAM;IAAEC,IAAI;IAAEC,IAAI;IAAEC,IAAI;IAAEC,GAAG;IAAEC;EAAU,CAAC,GAAGL,MAAM;EAEnD,MAAM;IAAEM;EAAe,CAAC,GAAG,MAAM,MAAM,uBAAuB,CAAC;EAE/D,MAAMC,KAAK,GAAG;AAClB;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,MAAMF,cAAc,CAACR,MAAM,EAAEC,OAAO,EAAEQ,KAAK,EAAE;IACxDE,IAAI,EAAE;MAAER,IAAI;MAAEC,IAAI;MAAEC,IAAI;MAAEC,GAAG;MAAEC;IAAU;EAC7C,CAAC,CAAC;EAEF,IAAIG,MAAM,CAACE,MAAM,CAAC,CAAC,EAAE;IACjB,OAAOd,MAAM,CAACe,IAAI,CAACH,MAAM,CAACI,KAAK,CAAC;EACpC;EAEA,MAAMC,YAAY,GAAGL,MAAM,CAACM,KAAK;EAEjC,IAAID,YAAY,CAACE,WAAW,CAACC,uBAAuB,CAACJ,KAAK,EAAE;IACxD,MAAM;MAAEK;IAAa,CAAC,GAAG,MAAM,MAAM,kBAAkB,CAAC;IACxD,OAAOrB,MAAM,CAACe,IAAI,CACd,IAAIM,YAAY,CACZJ,YAAY,CAACE,WAAW,CAACC,uBAAuB,CAACJ,KAAK,CAACM,OAAO,EAC9DL,YAAY,CAACE,WAAW,CAACC,uBAAuB,CAACJ,KAAK,CAACO,IAC3D,CACJ,CAAC;EACL;EAEA,OAAOvB,MAAM,CAACwB,EAAE,CAACP,YAAY,CAACE,WAAW,CAACC,uBAAuB,CAACP,IAAI,CAAC;AAC3E","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { WebinyConfig } from "../../types.js";
|
|
2
|
+
import { Result } from "../../Result.js";
|
|
3
|
+
import type { HttpError, GraphQLError, NetworkError } from "../../errors.js";
|
|
4
|
+
import type { PresignedPostPayloadResponse } from "./fileManagerTypes.js";
|
|
5
|
+
import type { GetPresignedPostPayloadParams } from "./getPresignedPostPayload.js";
|
|
6
|
+
export interface GetPresignedPostPayloadsParams {
|
|
7
|
+
files: GetPresignedPostPayloadParams[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Gets presigned POST payloads for uploading multiple files to S3.
|
|
11
|
+
*
|
|
12
|
+
* @param config - SDK configuration
|
|
13
|
+
* @param fetchFn - Fetch function to use for HTTP requests
|
|
14
|
+
* @param params - Parameters for getting the presigned POST payloads
|
|
15
|
+
* @param params.files - Array of file metadata for which to get presigned POST payloads
|
|
16
|
+
* @returns Result containing the presigned POST payloads or an error
|
|
17
|
+
*/
|
|
18
|
+
export declare function getPresignedPostPayloads(config: WebinyConfig, fetchFn: typeof fetch, params: GetPresignedPostPayloadsParams): Promise<Result<PresignedPostPayloadResponse[], HttpError | GraphQLError | NetworkError>>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Result } from "../../Result.js";
|
|
2
|
+
/**
|
|
3
|
+
* Gets presigned POST payloads for uploading multiple files to S3.
|
|
4
|
+
*
|
|
5
|
+
* @param config - SDK configuration
|
|
6
|
+
* @param fetchFn - Fetch function to use for HTTP requests
|
|
7
|
+
* @param params - Parameters for getting the presigned POST payloads
|
|
8
|
+
* @param params.files - Array of file metadata for which to get presigned POST payloads
|
|
9
|
+
* @returns Result containing the presigned POST payloads or an error
|
|
10
|
+
*/
|
|
11
|
+
export async function getPresignedPostPayloads(config, fetchFn, params) {
|
|
12
|
+
const {
|
|
13
|
+
files
|
|
14
|
+
} = params;
|
|
15
|
+
const {
|
|
16
|
+
executeGraphQL
|
|
17
|
+
} = await import("../executeGraphQL.js");
|
|
18
|
+
const query = `
|
|
19
|
+
query GetPreSignedPostPayloads($data: [PreSignedPostPayloadInput]!) {
|
|
20
|
+
fileManager {
|
|
21
|
+
getPreSignedPostPayloads(data: $data) {
|
|
22
|
+
data {
|
|
23
|
+
data
|
|
24
|
+
file {
|
|
25
|
+
id
|
|
26
|
+
name
|
|
27
|
+
type
|
|
28
|
+
size
|
|
29
|
+
key
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
error {
|
|
33
|
+
message
|
|
34
|
+
code
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
40
|
+
const result = await executeGraphQL(config, fetchFn, query, {
|
|
41
|
+
data: files.map(f => ({
|
|
42
|
+
name: f.name,
|
|
43
|
+
type: f.type,
|
|
44
|
+
size: f.size,
|
|
45
|
+
key: f.key,
|
|
46
|
+
keyPrefix: f.keyPrefix
|
|
47
|
+
}))
|
|
48
|
+
});
|
|
49
|
+
if (result.isFail()) {
|
|
50
|
+
return Result.fail(result.error);
|
|
51
|
+
}
|
|
52
|
+
const responseData = result.value;
|
|
53
|
+
if (responseData.fileManager.getPreSignedPostPayloads.error) {
|
|
54
|
+
const {
|
|
55
|
+
GraphQLError
|
|
56
|
+
} = await import("../../errors.js");
|
|
57
|
+
return Result.fail(new GraphQLError(responseData.fileManager.getPreSignedPostPayloads.error.message, responseData.fileManager.getPreSignedPostPayloads.error.code));
|
|
58
|
+
}
|
|
59
|
+
return Result.ok(responseData.fileManager.getPreSignedPostPayloads.data);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=getPresignedPostPayloads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Result","getPresignedPostPayloads","config","fetchFn","params","files","executeGraphQL","query","result","data","map","f","name","type","size","key","keyPrefix","isFail","fail","error","responseData","value","fileManager","getPreSignedPostPayloads","GraphQLError","message","code","ok"],"sources":["getPresignedPostPayloads.ts"],"sourcesContent":["import type { WebinyConfig } from \"../../types.js\";\nimport { Result } from \"../../Result.js\";\nimport type { HttpError, GraphQLError, NetworkError } from \"../../errors.js\";\nimport type { PresignedPostPayloadResponse } from \"./fileManagerTypes.js\";\nimport type { GetPresignedPostPayloadParams } from \"./getPresignedPostPayload.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 */\nexport async function getPresignedPostPayloads(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: GetPresignedPostPayloadsParams\n): Promise<Result<PresignedPostPayloadResponse[], HttpError | GraphQLError | NetworkError>> {\n const { files } = params;\n\n const { executeGraphQL } = await import(\"../executeGraphQL.js\");\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 const { GraphQLError } = await import(\"../../errors.js\");\n return Result.fail(\n new GraphQLError(\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"],"mappings":"AACA,SAASA,MAAM;AASf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,wBAAwBA,CAC1CC,MAAoB,EACpBC,OAAqB,EACrBC,MAAsC,EACkD;EACxF,MAAM;IAAEC;EAAM,CAAC,GAAGD,MAAM;EAExB,MAAM;IAAEE;EAAe,CAAC,GAAG,MAAM,MAAM,uBAAuB,CAAC;EAE/D,MAAMC,KAAK,GAAG;AAClB;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,MAAMF,cAAc,CAACJ,MAAM,EAAEC,OAAO,EAAEI,KAAK,EAAE;IACxDE,IAAI,EAAEJ,KAAK,CAACK,GAAG,CAACC,CAAC,KAAK;MAClBC,IAAI,EAAED,CAAC,CAACC,IAAI;MACZC,IAAI,EAAEF,CAAC,CAACE,IAAI;MACZC,IAAI,EAAEH,CAAC,CAACG,IAAI;MACZC,GAAG,EAAEJ,CAAC,CAACI,GAAG;MACVC,SAAS,EAAEL,CAAC,CAACK;IACjB,CAAC,CAAC;EACN,CAAC,CAAC;EAEF,IAAIR,MAAM,CAACS,MAAM,CAAC,CAAC,EAAE;IACjB,OAAOjB,MAAM,CAACkB,IAAI,CAACV,MAAM,CAACW,KAAK,CAAC;EACpC;EAEA,MAAMC,YAAY,GAAGZ,MAAM,CAACa,KAAK;EAEjC,IAAID,YAAY,CAACE,WAAW,CAACC,wBAAwB,CAACJ,KAAK,EAAE;IACzD,MAAM;MAAEK;IAAa,CAAC,GAAG,MAAM,MAAM,kBAAkB,CAAC;IACxD,OAAOxB,MAAM,CAACkB,IAAI,CACd,IAAIM,YAAY,CACZJ,YAAY,CAACE,WAAW,CAACC,wBAAwB,CAACJ,KAAK,CAACM,OAAO,EAC/DL,YAAY,CAACE,WAAW,CAACC,wBAAwB,CAACJ,KAAK,CAACO,IAC5D,CACJ,CAAC;EACL;EAEA,OAAO1B,MAAM,CAAC2B,EAAE,CAACP,YAAY,CAACE,WAAW,CAACC,wBAAwB,CAACd,IAAI,CAAC;AAC5E","ignoreList":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { WebinyConfig } from "../../types.js";
|
|
2
|
+
import { Result } from "../../Result.js";
|
|
3
|
+
import type { HttpError, GraphQLError, NetworkError } from "../../errors.js";
|
|
4
|
+
import type { FmFile, FmFileListWhereInput, FmFileListSorter, FmListMeta } from "./fileManagerTypes.js";
|
|
5
|
+
export interface ListFilesParams {
|
|
6
|
+
search?: string;
|
|
7
|
+
where?: FmFileListWhereInput;
|
|
8
|
+
limit?: number;
|
|
9
|
+
after?: string;
|
|
10
|
+
sort?: FmFileListSorter[];
|
|
11
|
+
fields: string[];
|
|
12
|
+
}
|
|
13
|
+
export interface ListFilesResult {
|
|
14
|
+
data: FmFile[];
|
|
15
|
+
meta: FmListMeta;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Lists files from the file manager.
|
|
19
|
+
*
|
|
20
|
+
* @param config - SDK configuration
|
|
21
|
+
* @param fetchFn - Fetch function to use for HTTP requests
|
|
22
|
+
* @param params - Parameters for listing files
|
|
23
|
+
* @param params.search - Search query
|
|
24
|
+
* @param params.where - Filter conditions
|
|
25
|
+
* @param params.limit - Maximum number of items to return
|
|
26
|
+
* @param params.after - Cursor for pagination
|
|
27
|
+
* @param params.sort - Sort order
|
|
28
|
+
* @returns Result containing the list of files or an error
|
|
29
|
+
*/
|
|
30
|
+
export declare function listFiles(config: WebinyConfig, fetchFn: typeof fetch, params: ListFilesParams): Promise<Result<ListFilesResult, HttpError | GraphQLError | NetworkError>>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Result } from "../../Result.js";
|
|
2
|
+
import { buildFieldsSelection } from "./buildFieldsSelection.js";
|
|
3
|
+
/**
|
|
4
|
+
* Lists files from the file manager.
|
|
5
|
+
*
|
|
6
|
+
* @param config - SDK configuration
|
|
7
|
+
* @param fetchFn - Fetch function to use for HTTP requests
|
|
8
|
+
* @param params - Parameters for listing files
|
|
9
|
+
* @param params.search - Search query
|
|
10
|
+
* @param params.where - Filter conditions
|
|
11
|
+
* @param params.limit - Maximum number of items to return
|
|
12
|
+
* @param params.after - Cursor for pagination
|
|
13
|
+
* @param params.sort - Sort order
|
|
14
|
+
* @returns Result containing the list of files or an error
|
|
15
|
+
*/
|
|
16
|
+
export async function listFiles(config, fetchFn, params) {
|
|
17
|
+
const {
|
|
18
|
+
search,
|
|
19
|
+
where,
|
|
20
|
+
limit,
|
|
21
|
+
after,
|
|
22
|
+
sort,
|
|
23
|
+
fields
|
|
24
|
+
} = params;
|
|
25
|
+
const {
|
|
26
|
+
executeGraphQL
|
|
27
|
+
} = await import("../executeGraphQL.js");
|
|
28
|
+
const fieldsSelection = buildFieldsSelection(fields);
|
|
29
|
+
const query = `
|
|
30
|
+
query ListFiles($search: String, $where: FmFileListWhereInput, $limit: Int, $after: String, $sort: [FmFileListSorter!]) {
|
|
31
|
+
fileManager {
|
|
32
|
+
listFiles(search: $search, where: $where, limit: $limit, after: $after, sort: $sort) {
|
|
33
|
+
data {
|
|
34
|
+
${fieldsSelection}
|
|
35
|
+
}
|
|
36
|
+
meta {
|
|
37
|
+
cursor
|
|
38
|
+
hasMoreItems
|
|
39
|
+
totalCount
|
|
40
|
+
}
|
|
41
|
+
error {
|
|
42
|
+
message
|
|
43
|
+
code
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
const result = await executeGraphQL(config, fetchFn, query, {
|
|
50
|
+
search,
|
|
51
|
+
where,
|
|
52
|
+
limit,
|
|
53
|
+
after,
|
|
54
|
+
sort
|
|
55
|
+
});
|
|
56
|
+
if (result.isFail()) {
|
|
57
|
+
return Result.fail(result.error);
|
|
58
|
+
}
|
|
59
|
+
const responseData = result.value;
|
|
60
|
+
if (responseData.fileManager.listFiles.error) {
|
|
61
|
+
const {
|
|
62
|
+
GraphQLError
|
|
63
|
+
} = await import("../../errors.js");
|
|
64
|
+
return Result.fail(new GraphQLError(responseData.fileManager.listFiles.error.message, responseData.fileManager.listFiles.error.code));
|
|
65
|
+
}
|
|
66
|
+
return Result.ok({
|
|
67
|
+
data: responseData.fileManager.listFiles.data,
|
|
68
|
+
meta: responseData.fileManager.listFiles.meta
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=listFiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Result","buildFieldsSelection","listFiles","config","fetchFn","params","search","where","limit","after","sort","fields","executeGraphQL","fieldsSelection","query","result","isFail","fail","error","responseData","value","fileManager","GraphQLError","message","code","ok","data","meta"],"sources":["listFiles.ts"],"sourcesContent":["import type { WebinyConfig } from \"../../types.js\";\nimport { Result } from \"../../Result.js\";\nimport type { HttpError, GraphQLError, NetworkError } from \"../../errors.js\";\nimport type {\n FmFile,\n FmFileListWhereInput,\n FmFileListSorter,\n FmListMeta\n} from \"./fileManagerTypes.js\";\nimport { buildFieldsSelection } from \"./buildFieldsSelection.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 async function listFiles(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: ListFilesParams\n): Promise<Result<ListFilesResult, HttpError | GraphQLError | NetworkError>> {\n const { search, where, limit, after, sort, fields } = params;\n\n const { executeGraphQL } = await import(\"../executeGraphQL.js\");\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 return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.fileManager.listFiles.error) {\n const { GraphQLError } = await import(\"../../errors.js\");\n return Result.fail(\n new GraphQLError(\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,\n meta: responseData.fileManager.listFiles.meta\n });\n}\n"],"mappings":"AACA,SAASA,MAAM;AAQf,SAASC,oBAAoB;AAgB7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,SAASA,CAC3BC,MAAoB,EACpBC,OAAqB,EACrBC,MAAuB,EACkD;EACzE,MAAM;IAAEC,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEC,KAAK;IAAEC,IAAI;IAAEC;EAAO,CAAC,GAAGN,MAAM;EAE5D,MAAM;IAAEO;EAAe,CAAC,GAAG,MAAM,MAAM,uBAAuB,CAAC;EAE/D,MAAMC,eAAe,GAAGZ,oBAAoB,CAACU,MAAM,CAAC;EAEpD,MAAMG,KAAK,GAAG;AAClB;AACA;AACA;AACA;AACA,EAAED,eAAe;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;EAED,MAAME,MAAM,GAAG,MAAMH,cAAc,CAACT,MAAM,EAAEC,OAAO,EAAEU,KAAK,EAAE;IACxDR,MAAM;IACNC,KAAK;IACLC,KAAK;IACLC,KAAK;IACLC;EACJ,CAAC,CAAC;EAEF,IAAIK,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;IACjB,OAAOhB,MAAM,CAACiB,IAAI,CAACF,MAAM,CAACG,KAAK,CAAC;EACpC;EAEA,MAAMC,YAAY,GAAGJ,MAAM,CAACK,KAAK;EAEjC,IAAID,YAAY,CAACE,WAAW,CAACnB,SAAS,CAACgB,KAAK,EAAE;IAC1C,MAAM;MAAEI;IAAa,CAAC,GAAG,MAAM,MAAM,kBAAkB,CAAC;IACxD,OAAOtB,MAAM,CAACiB,IAAI,CACd,IAAIK,YAAY,CACZH,YAAY,CAACE,WAAW,CAACnB,SAAS,CAACgB,KAAK,CAACK,OAAO,EAChDJ,YAAY,CAACE,WAAW,CAACnB,SAAS,CAACgB,KAAK,CAACM,IAC7C,CACJ,CAAC;EACL;EAEA,OAAOxB,MAAM,CAACyB,EAAE,CAAC;IACbC,IAAI,EAAEP,YAAY,CAACE,WAAW,CAACnB,SAAS,CAACwB,IAAI;IAC7CC,IAAI,EAAER,YAAY,CAACE,WAAW,CAACnB,SAAS,CAACyB;EAC7C,CAAC,CAAC;AACN","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { WebinyConfig } from "../../types.js";
|
|
2
|
+
import { Result } from "../../Result.js";
|
|
3
|
+
import type { HttpError, GraphQLError, NetworkError } from "../../errors.js";
|
|
4
|
+
import type { FmTag, FmTagsListWhereInput } from "./fileManagerTypes.js";
|
|
5
|
+
export interface ListTagsParams {
|
|
6
|
+
where?: FmTagsListWhereInput;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Lists tags from the file manager.
|
|
10
|
+
*
|
|
11
|
+
* @param config - SDK configuration
|
|
12
|
+
* @param fetchFn - Fetch function to use for HTTP requests
|
|
13
|
+
* @param params - Parameters for listing tags
|
|
14
|
+
* @param params.where - Filter conditions
|
|
15
|
+
* @returns Result containing the list of tags or an error
|
|
16
|
+
*/
|
|
17
|
+
export declare function listTags(config: WebinyConfig, fetchFn: typeof fetch, params?: ListTagsParams): Promise<Result<FmTag[], HttpError | GraphQLError | NetworkError>>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Result } from "../../Result.js";
|
|
2
|
+
/**
|
|
3
|
+
* Lists tags from the file manager.
|
|
4
|
+
*
|
|
5
|
+
* @param config - SDK configuration
|
|
6
|
+
* @param fetchFn - Fetch function to use for HTTP requests
|
|
7
|
+
* @param params - Parameters for listing tags
|
|
8
|
+
* @param params.where - Filter conditions
|
|
9
|
+
* @returns Result containing the list of tags or an error
|
|
10
|
+
*/
|
|
11
|
+
export async function listTags(config, fetchFn, params = {}) {
|
|
12
|
+
const {
|
|
13
|
+
where
|
|
14
|
+
} = params;
|
|
15
|
+
const {
|
|
16
|
+
executeGraphQL
|
|
17
|
+
} = await import("../executeGraphQL.js");
|
|
18
|
+
const query = `
|
|
19
|
+
query ListTags($where: FmTagsListWhereInput) {
|
|
20
|
+
fileManager {
|
|
21
|
+
listTags(where: $where) {
|
|
22
|
+
data {
|
|
23
|
+
tag
|
|
24
|
+
count
|
|
25
|
+
}
|
|
26
|
+
error {
|
|
27
|
+
message
|
|
28
|
+
code
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
const result = await executeGraphQL(config, fetchFn, query, {
|
|
35
|
+
where
|
|
36
|
+
});
|
|
37
|
+
if (result.isFail()) {
|
|
38
|
+
return Result.fail(result.error);
|
|
39
|
+
}
|
|
40
|
+
const responseData = result.value;
|
|
41
|
+
if (responseData.fileManager.listTags.error) {
|
|
42
|
+
const {
|
|
43
|
+
GraphQLError
|
|
44
|
+
} = await import("../../errors.js");
|
|
45
|
+
return Result.fail(new GraphQLError(responseData.fileManager.listTags.error.message, responseData.fileManager.listTags.error.code));
|
|
46
|
+
}
|
|
47
|
+
return Result.ok(responseData.fileManager.listTags.data);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=listTags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Result","listTags","config","fetchFn","params","where","executeGraphQL","query","result","isFail","fail","error","responseData","value","fileManager","GraphQLError","message","code","ok","data"],"sources":["listTags.ts"],"sourcesContent":["import type { WebinyConfig } from \"../../types.js\";\nimport { Result } from \"../../Result.js\";\nimport type { HttpError, GraphQLError, NetworkError } from \"../../errors.js\";\nimport type { FmTag, FmTagsListWhereInput } from \"./fileManagerTypes.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 | GraphQLError | NetworkError>> {\n const { where } = params;\n\n const { executeGraphQL } = await import(\"../executeGraphQL.js\");\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 const { GraphQLError } = await import(\"../../errors.js\");\n return Result.fail(\n new GraphQLError(\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"],"mappings":"AACA,SAASA,MAAM;AAQf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,QAAQA,CAC1BC,MAAoB,EACpBC,OAAqB,EACrBC,MAAsB,GAAG,CAAC,CAAC,EACsC;EACjE,MAAM;IAAEC;EAAM,CAAC,GAAGD,MAAM;EAExB,MAAM;IAAEE;EAAe,CAAC,GAAG,MAAM,MAAM,uBAAuB,CAAC;EAE/D,MAAMC,KAAK,GAAG;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;EAED,MAAMC,MAAM,GAAG,MAAMF,cAAc,CAACJ,MAAM,EAAEC,OAAO,EAAEI,KAAK,EAAE;IAAEF;EAAM,CAAC,CAAC;EAEtE,IAAIG,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;IACjB,OAAOT,MAAM,CAACU,IAAI,CAACF,MAAM,CAACG,KAAK,CAAC;EACpC;EAEA,MAAMC,YAAY,GAAGJ,MAAM,CAACK,KAAK;EAEjC,IAAID,YAAY,CAACE,WAAW,CAACb,QAAQ,CAACU,KAAK,EAAE;IACzC,MAAM;MAAEI;IAAa,CAAC,GAAG,MAAM,MAAM,kBAAkB,CAAC;IACxD,OAAOf,MAAM,CAACU,IAAI,CACd,IAAIK,YAAY,CACZH,YAAY,CAACE,WAAW,CAACb,QAAQ,CAACU,KAAK,CAACK,OAAO,EAC/CJ,YAAY,CAACE,WAAW,CAACb,QAAQ,CAACU,KAAK,CAACM,IAC5C,CACJ,CAAC;EACL;EAEA,OAAOjB,MAAM,CAACkB,EAAE,CAACN,YAAY,CAACE,WAAW,CAACb,QAAQ,CAACkB,IAAI,CAAC;AAC5D","ignoreList":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { WebinyConfig } from "../../types.js";
|
|
2
|
+
import { Result } from "../../Result.js";
|
|
3
|
+
import type { HttpError, GraphQLError, NetworkError } from "../../errors.js";
|
|
4
|
+
import type { FmFile, FmIdentity, FmLocationInput } from "./fileManagerTypes.js";
|
|
5
|
+
export interface UpdateFileData {
|
|
6
|
+
createdOn?: Date | string;
|
|
7
|
+
modifiedOn?: Date | string;
|
|
8
|
+
savedOn?: Date | string;
|
|
9
|
+
createdBy?: FmIdentity;
|
|
10
|
+
modifiedBy?: FmIdentity;
|
|
11
|
+
savedBy?: FmIdentity;
|
|
12
|
+
location?: FmLocationInput;
|
|
13
|
+
name?: string;
|
|
14
|
+
key?: string;
|
|
15
|
+
type?: string;
|
|
16
|
+
size?: number;
|
|
17
|
+
tags?: string[];
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}
|
|
20
|
+
export interface UpdateFileParams {
|
|
21
|
+
id: string;
|
|
22
|
+
data: UpdateFileData;
|
|
23
|
+
fields: string[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Updates a file in the file manager.
|
|
27
|
+
*
|
|
28
|
+
* @param config - SDK configuration
|
|
29
|
+
* @param fetchFn - Fetch function to use for HTTP requests
|
|
30
|
+
* @param params - Parameters for updating the file
|
|
31
|
+
* @param params.id - ID of the file to update
|
|
32
|
+
* @param params.data - The file data to update
|
|
33
|
+
* @returns Result containing the updated file data or an error
|
|
34
|
+
*/
|
|
35
|
+
export declare function updateFile(config: WebinyConfig, fetchFn: typeof fetch, params: UpdateFileParams): Promise<Result<FmFile, HttpError | GraphQLError | NetworkError>>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Result } from "../../Result.js";
|
|
2
|
+
import { buildFieldsSelection } from "./buildFieldsSelection.js";
|
|
3
|
+
/**
|
|
4
|
+
* Updates a file in the file manager.
|
|
5
|
+
*
|
|
6
|
+
* @param config - SDK configuration
|
|
7
|
+
* @param fetchFn - Fetch function to use for HTTP requests
|
|
8
|
+
* @param params - Parameters for updating the file
|
|
9
|
+
* @param params.id - ID of the file to update
|
|
10
|
+
* @param params.data - The file data to update
|
|
11
|
+
* @returns Result containing the updated file data or an error
|
|
12
|
+
*/
|
|
13
|
+
export async function updateFile(config, fetchFn, params) {
|
|
14
|
+
const {
|
|
15
|
+
id,
|
|
16
|
+
data,
|
|
17
|
+
fields
|
|
18
|
+
} = params;
|
|
19
|
+
const {
|
|
20
|
+
executeGraphQL
|
|
21
|
+
} = await import("../executeGraphQL.js");
|
|
22
|
+
const fieldsSelection = buildFieldsSelection(fields);
|
|
23
|
+
const query = `
|
|
24
|
+
mutation UpdateFile($id: ID!, $data: FmFileUpdateInput!) {
|
|
25
|
+
fileManager {
|
|
26
|
+
updateFile(id: $id, data: $data) {
|
|
27
|
+
data {
|
|
28
|
+
${fieldsSelection}
|
|
29
|
+
}
|
|
30
|
+
error {
|
|
31
|
+
message
|
|
32
|
+
code
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
const result = await executeGraphQL(config, fetchFn, query, {
|
|
39
|
+
id,
|
|
40
|
+
data
|
|
41
|
+
});
|
|
42
|
+
if (result.isFail()) {
|
|
43
|
+
return Result.fail(result.error);
|
|
44
|
+
}
|
|
45
|
+
const responseData = result.value;
|
|
46
|
+
if (responseData.fileManager.updateFile.error) {
|
|
47
|
+
const {
|
|
48
|
+
GraphQLError
|
|
49
|
+
} = await import("../../errors.js");
|
|
50
|
+
return Result.fail(new GraphQLError(responseData.fileManager.updateFile.error.message, responseData.fileManager.updateFile.error.code));
|
|
51
|
+
}
|
|
52
|
+
return Result.ok(responseData.fileManager.updateFile.data);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=updateFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Result","buildFieldsSelection","updateFile","config","fetchFn","params","id","data","fields","executeGraphQL","fieldsSelection","query","result","isFail","fail","error","responseData","value","fileManager","GraphQLError","message","code","ok"],"sources":["updateFile.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 } from \"./fileManagerTypes.js\";\nimport { buildFieldsSelection } from \"./buildFieldsSelection.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 async function updateFile(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: UpdateFileParams\n): Promise<Result<FmFile, HttpError | GraphQLError | NetworkError>> {\n const { id, data, fields } = params;\n\n const { executeGraphQL } = await import(\"../executeGraphQL.js\");\n\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 const { GraphQLError } = await import(\"../../errors.js\");\n return Result.fail(\n new GraphQLError(\n responseData.fileManager.updateFile.error.message,\n responseData.fileManager.updateFile.error.code\n )\n );\n }\n\n return Result.ok(responseData.fileManager.updateFile.data);\n}\n"],"mappings":"AACA,SAASA,MAAM;AAGf,SAASC,oBAAoB;AAwB7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,UAAUA,CAC5BC,MAAoB,EACpBC,OAAqB,EACrBC,MAAwB,EACwC;EAChE,MAAM;IAAEC,EAAE;IAAEC,IAAI;IAAEC;EAAO,CAAC,GAAGH,MAAM;EAEnC,MAAM;IAAEI;EAAe,CAAC,GAAG,MAAM,MAAM,uBAAuB,CAAC;EAE/D,MAAMC,eAAe,GAAGT,oBAAoB,CAACO,MAAM,CAAC;EAEpD,MAAMG,KAAK,GAAG;AAClB;AACA;AACA;AACA;AACA,EAAED,eAAe;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;EAED,MAAME,MAAM,GAAG,MAAMH,cAAc,CAACN,MAAM,EAAEC,OAAO,EAAEO,KAAK,EAAE;IAAEL,EAAE;IAAEC;EAAK,CAAC,CAAC;EAEzE,IAAIK,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;IACjB,OAAOb,MAAM,CAACc,IAAI,CAACF,MAAM,CAACG,KAAK,CAAC;EACpC;EAEA,MAAMC,YAAY,GAAGJ,MAAM,CAACK,KAAK;EAEjC,IAAID,YAAY,CAACE,WAAW,CAAChB,UAAU,CAACa,KAAK,EAAE;IAC3C,MAAM;MAAEI;IAAa,CAAC,GAAG,MAAM,MAAM,kBAAkB,CAAC;IACxD,OAAOnB,MAAM,CAACc,IAAI,CACd,IAAIK,YAAY,CACZH,YAAY,CAACE,WAAW,CAAChB,UAAU,CAACa,KAAK,CAACK,OAAO,EACjDJ,YAAY,CAACE,WAAW,CAAChB,UAAU,CAACa,KAAK,CAACM,IAC9C,CACJ,CAAC;EACL;EAEA,OAAOrB,MAAM,CAACsB,EAAE,CAACN,YAAY,CAACE,WAAW,CAAChB,UAAU,CAACK,IAAI,CAAC;AAC9D","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { isBrowser } from "../../../utils/platform.js";
|
|
2
|
+
export function isBuffer(file) {
|
|
3
|
+
// Check if Buffer exists (Node.js) before using it.
|
|
4
|
+
return typeof Buffer !== "undefined" && Buffer.isBuffer(file);
|
|
5
|
+
}
|
|
6
|
+
export function isBlob(file) {
|
|
7
|
+
return typeof Blob !== "undefined" && file instanceof Blob;
|
|
8
|
+
}
|
|
9
|
+
export function isFile(file) {
|
|
10
|
+
return isBrowser && typeof File !== "undefined" && file instanceof File;
|
|
11
|
+
}
|
|
12
|
+
export function getFileSize(file) {
|
|
13
|
+
if (isBuffer(file)) {
|
|
14
|
+
return file.length;
|
|
15
|
+
}
|
|
16
|
+
return file.size;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=fileTypeDetection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isBrowser","isBuffer","file","Buffer","isBlob","Blob","isFile","File","getFileSize","length","size"],"sources":["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"],"mappings":"AAAA,SAASA,SAAS;AAElB,OAAO,SAASC,QAAQA,CAACC,IAAS,EAAkB;EAChD;EACA,OAAO,OAAOC,MAAM,KAAK,WAAW,IAAIA,MAAM,CAACF,QAAQ,CAACC,IAAI,CAAC;AACjE;AAEA,OAAO,SAASE,MAAMA,CAACF,IAAS,EAAgB;EAC5C,OAAO,OAAOG,IAAI,KAAK,WAAW,IAAIH,IAAI,YAAYG,IAAI;AAC9D;AAEA,OAAO,SAASC,MAAMA,CAACJ,IAAS,EAAgB;EAC5C,OAAOF,SAAS,IAAI,OAAOO,IAAI,KAAK,WAAW,IAAIL,IAAI,YAAYK,IAAI;AAC3E;AAEA,OAAO,SAASC,WAAWA,CAACN,IAA0B,EAAU;EAC5D,IAAID,QAAQ,CAACC,IAAI,CAAC,EAAE;IAChB,OAAOA,IAAI,CAACO,MAAM;EACtB;EACA,OAAOP,IAAI,CAACQ,IAAI;AACpB","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { WebinyConfig } from "../../../types.js";
|
|
2
|
+
import type { FmFile, UploadProgress } from "../fileManagerTypes.js";
|
|
3
|
+
export interface UploadLargeFileOptions {
|
|
4
|
+
onProgress?: (progress: UploadProgress) => void;
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
chunkSize?: number;
|
|
7
|
+
parallelUploads?: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Uploads a large file to S3 using multi-part upload.
|
|
11
|
+
*
|
|
12
|
+
* @param file - The file to upload (Buffer, Blob, or File)
|
|
13
|
+
* @param fileData - File metadata
|
|
14
|
+
* @param config - SDK configuration
|
|
15
|
+
* @param fetchFn - Fetch function to use for HTTP requests
|
|
16
|
+
* @param options - Upload options
|
|
17
|
+
* @returns Promise that resolves with the uploaded file metadata
|
|
18
|
+
*/
|
|
19
|
+
export declare function uploadLargeFile(file: Buffer | Blob | File, fileData: {
|
|
20
|
+
name: string;
|
|
21
|
+
type: string;
|
|
22
|
+
size: number;
|
|
23
|
+
key?: string;
|
|
24
|
+
keyPrefix?: string;
|
|
25
|
+
}, config: WebinyConfig, fetchFn: typeof fetch, options?: UploadLargeFileOptions): Promise<FmFile>;
|