@webiny/sdk 6.0.0 → 6.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +4 -4
- package/utils/platform.d.ts +2 -0
- package/utils/platform.js +4 -0
- package/utils/platform.js.map +1 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { WebinyConfig } from "./types.js";
|
|
2
|
+
import type { FmFile, FmTag, PresignedPostPayloadResponse } from "./methods/fileManager/fileManagerTypes.js";
|
|
3
|
+
import type { GetFileParams } from "./methods/fileManager/getFile.js";
|
|
4
|
+
import type { ListFilesParams, ListFilesResult } from "./methods/fileManager/listFiles.js";
|
|
5
|
+
import type { CreateFileParams } from "./methods/fileManager/createFile.js";
|
|
6
|
+
import type { CreateFilesParams, CreateFilesResult } from "./methods/fileManager/createFiles.js";
|
|
7
|
+
import type { UpdateFileParams } from "./methods/fileManager/updateFile.js";
|
|
8
|
+
import type { DeleteFileParams } from "./methods/fileManager/deleteFile.js";
|
|
9
|
+
import type { ListTagsParams } from "./methods/fileManager/listTags.js";
|
|
10
|
+
import type { GetPresignedPostPayloadParams } from "./methods/fileManager/getPresignedPostPayload.js";
|
|
11
|
+
import type { GetPresignedPostPayloadsParams } from "./methods/fileManager/getPresignedPostPayloads.js";
|
|
12
|
+
import type { CreateMultiPartUploadParams, MultiPartUploadResponse } from "./methods/fileManager/createMultiPartUpload.js";
|
|
13
|
+
import type { CompleteMultiPartUploadParams } from "./methods/fileManager/completeMultiPartUpload.js";
|
|
14
|
+
import type { HttpError, GraphQLError, NetworkError } from "./errors.js";
|
|
15
|
+
import type { Result } from "./Result.js";
|
|
16
|
+
export declare class FileManagerSdk {
|
|
17
|
+
private config;
|
|
18
|
+
private fetchFn;
|
|
19
|
+
constructor(config: WebinyConfig);
|
|
20
|
+
getFile(params: GetFileParams): Promise<Result<FmFile, HttpError | GraphQLError | NetworkError>>;
|
|
21
|
+
listFiles(params: ListFilesParams): Promise<Result<ListFilesResult, HttpError | GraphQLError | NetworkError>>;
|
|
22
|
+
createFile(params: CreateFileParams): Promise<Result<FmFile, HttpError | GraphQLError | NetworkError>>;
|
|
23
|
+
createFiles(params: CreateFilesParams): Promise<Result<CreateFilesResult, HttpError | GraphQLError | NetworkError>>;
|
|
24
|
+
updateFile(params: UpdateFileParams): Promise<Result<FmFile, HttpError | GraphQLError | NetworkError>>;
|
|
25
|
+
deleteFile(params: DeleteFileParams): Promise<Result<boolean, HttpError | GraphQLError | NetworkError>>;
|
|
26
|
+
listTags(params?: ListTagsParams): Promise<Result<FmTag[], HttpError | GraphQLError | NetworkError>>;
|
|
27
|
+
getPresignedPostPayload(params: GetPresignedPostPayloadParams): Promise<Result<PresignedPostPayloadResponse, HttpError | GraphQLError | NetworkError>>;
|
|
28
|
+
getPresignedPostPayloads(params: GetPresignedPostPayloadsParams): Promise<Result<PresignedPostPayloadResponse[], HttpError | GraphQLError | NetworkError>>;
|
|
29
|
+
createMultiPartUpload(params: CreateMultiPartUploadParams): Promise<Result<MultiPartUploadResponse, HttpError | GraphQLError | NetworkError>>;
|
|
30
|
+
completeMultiPartUpload(params: CompleteMultiPartUploadParams): Promise<Result<boolean, HttpError | GraphQLError | NetworkError>>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { getFile as getFileFn } from "./methods/fileManager/getFile.js";
|
|
2
|
+
import { listFiles as listFilesFn } from "./methods/fileManager/listFiles.js";
|
|
3
|
+
import { createFile as createFileFn } from "./methods/fileManager/createFile.js";
|
|
4
|
+
import { createFiles as createFilesFn } from "./methods/fileManager/createFiles.js";
|
|
5
|
+
import { updateFile as updateFileFn } from "./methods/fileManager/updateFile.js";
|
|
6
|
+
import { deleteFile as deleteFileFn } from "./methods/fileManager/deleteFile.js";
|
|
7
|
+
import { listTags as listTagsFn } from "./methods/fileManager/listTags.js";
|
|
8
|
+
import { getPresignedPostPayload as getPresignedPostPayloadFn } from "./methods/fileManager/getPresignedPostPayload.js";
|
|
9
|
+
import { getPresignedPostPayloads as getPresignedPostPayloadsFn } from "./methods/fileManager/getPresignedPostPayloads.js";
|
|
10
|
+
import { createMultiPartUpload as createMultiPartUploadFn } from "./methods/fileManager/createMultiPartUpload.js";
|
|
11
|
+
import { completeMultiPartUpload as completeMultiPartUploadFn } from "./methods/fileManager/completeMultiPartUpload.js";
|
|
12
|
+
export class FileManagerSdk {
|
|
13
|
+
constructor(config) {
|
|
14
|
+
this.config = config;
|
|
15
|
+
this.fetchFn = config.fetch || fetch;
|
|
16
|
+
}
|
|
17
|
+
async getFile(params) {
|
|
18
|
+
return getFileFn(this.config, this.fetchFn, params);
|
|
19
|
+
}
|
|
20
|
+
async listFiles(params) {
|
|
21
|
+
return listFilesFn(this.config, this.fetchFn, params);
|
|
22
|
+
}
|
|
23
|
+
async createFile(params) {
|
|
24
|
+
return createFileFn(this.config, this.fetchFn, params);
|
|
25
|
+
}
|
|
26
|
+
async createFiles(params) {
|
|
27
|
+
return createFilesFn(this.config, this.fetchFn, params);
|
|
28
|
+
}
|
|
29
|
+
async updateFile(params) {
|
|
30
|
+
return updateFileFn(this.config, this.fetchFn, params);
|
|
31
|
+
}
|
|
32
|
+
async deleteFile(params) {
|
|
33
|
+
return deleteFileFn(this.config, this.fetchFn, params);
|
|
34
|
+
}
|
|
35
|
+
async listTags(params) {
|
|
36
|
+
return listTagsFn(this.config, this.fetchFn, params);
|
|
37
|
+
}
|
|
38
|
+
async getPresignedPostPayload(params) {
|
|
39
|
+
return getPresignedPostPayloadFn(this.config, this.fetchFn, params);
|
|
40
|
+
}
|
|
41
|
+
async getPresignedPostPayloads(params) {
|
|
42
|
+
return getPresignedPostPayloadsFn(this.config, this.fetchFn, params);
|
|
43
|
+
}
|
|
44
|
+
async createMultiPartUpload(params) {
|
|
45
|
+
return createMultiPartUploadFn(this.config, this.fetchFn, params);
|
|
46
|
+
}
|
|
47
|
+
async completeMultiPartUpload(params) {
|
|
48
|
+
return completeMultiPartUploadFn(this.config, this.fetchFn, params);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=FileManagerSdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getFile","getFileFn","listFiles","listFilesFn","createFile","createFileFn","createFiles","createFilesFn","updateFile","updateFileFn","deleteFile","deleteFileFn","listTags","listTagsFn","getPresignedPostPayload","getPresignedPostPayloadFn","getPresignedPostPayloads","getPresignedPostPayloadsFn","createMultiPartUpload","createMultiPartUploadFn","completeMultiPartUpload","completeMultiPartUploadFn","FileManagerSdk","constructor","config","fetchFn","fetch","params"],"sources":["FileManagerSdk.ts"],"sourcesContent":["import type { WebinyConfig } from \"./types.js\";\nimport type {\n FmFile,\n FmTag,\n PresignedPostPayloadResponse\n} from \"./methods/fileManager/fileManagerTypes.js\";\nimport type { GetFileParams } from \"./methods/fileManager/getFile.js\";\nimport type { ListFilesParams, ListFilesResult } from \"./methods/fileManager/listFiles.js\";\nimport type { CreateFileParams } from \"./methods/fileManager/createFile.js\";\nimport type { CreateFilesParams, CreateFilesResult } from \"./methods/fileManager/createFiles.js\";\nimport type { UpdateFileParams } from \"./methods/fileManager/updateFile.js\";\nimport type { DeleteFileParams } from \"./methods/fileManager/deleteFile.js\";\nimport type { ListTagsParams } from \"./methods/fileManager/listTags.js\";\nimport type { GetPresignedPostPayloadParams } from \"./methods/fileManager/getPresignedPostPayload.js\";\nimport type { GetPresignedPostPayloadsParams } from \"./methods/fileManager/getPresignedPostPayloads.js\";\nimport type {\n CreateMultiPartUploadParams,\n MultiPartUploadResponse\n} from \"./methods/fileManager/createMultiPartUpload.js\";\nimport type { CompleteMultiPartUploadParams } from \"./methods/fileManager/completeMultiPartUpload.js\";\nimport type { HttpError, GraphQLError, NetworkError } from \"./errors.js\";\nimport type { Result } from \"./Result.js\";\nimport { getFile as getFileFn } from \"./methods/fileManager/getFile.js\";\nimport { listFiles as listFilesFn } from \"./methods/fileManager/listFiles.js\";\nimport { createFile as createFileFn } from \"./methods/fileManager/createFile.js\";\nimport { createFiles as createFilesFn } from \"./methods/fileManager/createFiles.js\";\nimport { updateFile as updateFileFn } from \"./methods/fileManager/updateFile.js\";\nimport { deleteFile as deleteFileFn } from \"./methods/fileManager/deleteFile.js\";\nimport { listTags as listTagsFn } from \"./methods/fileManager/listTags.js\";\nimport { getPresignedPostPayload as getPresignedPostPayloadFn } from \"./methods/fileManager/getPresignedPostPayload.js\";\nimport { getPresignedPostPayloads as getPresignedPostPayloadsFn } from \"./methods/fileManager/getPresignedPostPayloads.js\";\nimport { createMultiPartUpload as createMultiPartUploadFn } from \"./methods/fileManager/createMultiPartUpload.js\";\nimport { completeMultiPartUpload as completeMultiPartUploadFn } from \"./methods/fileManager/completeMultiPartUpload.js\";\n\nexport class FileManagerSdk {\n private config: WebinyConfig;\n private fetchFn: typeof fetch;\n\n constructor(config: WebinyConfig) {\n this.config = config;\n this.fetchFn = config.fetch || fetch;\n }\n\n async getFile(\n params: GetFileParams\n ): Promise<Result<FmFile, HttpError | GraphQLError | NetworkError>> {\n return getFileFn(this.config, this.fetchFn, params);\n }\n\n async listFiles(\n params: ListFilesParams\n ): Promise<Result<ListFilesResult, HttpError | GraphQLError | NetworkError>> {\n return listFilesFn(this.config, this.fetchFn, params);\n }\n\n async createFile(\n params: CreateFileParams\n ): Promise<Result<FmFile, HttpError | GraphQLError | NetworkError>> {\n return createFileFn(this.config, this.fetchFn, params);\n }\n\n async createFiles(\n params: CreateFilesParams\n ): Promise<Result<CreateFilesResult, HttpError | GraphQLError | NetworkError>> {\n return createFilesFn(this.config, this.fetchFn, params);\n }\n\n async updateFile(\n params: UpdateFileParams\n ): Promise<Result<FmFile, HttpError | GraphQLError | NetworkError>> {\n return updateFileFn(this.config, this.fetchFn, params);\n }\n\n async deleteFile(\n params: DeleteFileParams\n ): Promise<Result<boolean, HttpError | GraphQLError | NetworkError>> {\n return deleteFileFn(this.config, this.fetchFn, params);\n }\n\n async listTags(\n params?: ListTagsParams\n ): Promise<Result<FmTag[], HttpError | GraphQLError | NetworkError>> {\n return listTagsFn(this.config, this.fetchFn, params);\n }\n\n async getPresignedPostPayload(\n params: GetPresignedPostPayloadParams\n ): Promise<Result<PresignedPostPayloadResponse, HttpError | GraphQLError | NetworkError>> {\n return getPresignedPostPayloadFn(this.config, this.fetchFn, params);\n }\n\n async getPresignedPostPayloads(\n params: GetPresignedPostPayloadsParams\n ): Promise<Result<PresignedPostPayloadResponse[], HttpError | GraphQLError | NetworkError>> {\n return getPresignedPostPayloadsFn(this.config, this.fetchFn, params);\n }\n\n async createMultiPartUpload(\n params: CreateMultiPartUploadParams\n ): Promise<Result<MultiPartUploadResponse, HttpError | GraphQLError | NetworkError>> {\n return createMultiPartUploadFn(this.config, this.fetchFn, params);\n }\n\n async completeMultiPartUpload(\n params: CompleteMultiPartUploadParams\n ): Promise<Result<boolean, HttpError | GraphQLError | NetworkError>> {\n return completeMultiPartUploadFn(this.config, this.fetchFn, params);\n }\n}\n"],"mappings":"AAsBA,SAASA,OAAO,IAAIC,SAAS;AAC7B,SAASC,SAAS,IAAIC,WAAW;AACjC,SAASC,UAAU,IAAIC,YAAY;AACnC,SAASC,WAAW,IAAIC,aAAa;AACrC,SAASC,UAAU,IAAIC,YAAY;AACnC,SAASC,UAAU,IAAIC,YAAY;AACnC,SAASC,QAAQ,IAAIC,UAAU;AAC/B,SAASC,uBAAuB,IAAIC,yBAAyB;AAC7D,SAASC,wBAAwB,IAAIC,0BAA0B;AAC/D,SAASC,qBAAqB,IAAIC,uBAAuB;AACzD,SAASC,uBAAuB,IAAIC,yBAAyB;AAE7D,OAAO,MAAMC,cAAc,CAAC;EAIxBC,WAAWA,CAACC,MAAoB,EAAE;IAC9B,IAAI,CAACA,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACE,KAAK,IAAIA,KAAK;EACxC;EAEA,MAAM1B,OAAOA,CACT2B,MAAqB,EAC2C;IAChE,OAAO1B,SAAS,CAAC,IAAI,CAACuB,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EACvD;EAEA,MAAMzB,SAASA,CACXyB,MAAuB,EACkD;IACzE,OAAOxB,WAAW,CAAC,IAAI,CAACqB,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EACzD;EAEA,MAAMvB,UAAUA,CACZuB,MAAwB,EACwC;IAChE,OAAOtB,YAAY,CAAC,IAAI,CAACmB,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EAC1D;EAEA,MAAMrB,WAAWA,CACbqB,MAAyB,EACkD;IAC3E,OAAOpB,aAAa,CAAC,IAAI,CAACiB,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EAC3D;EAEA,MAAMnB,UAAUA,CACZmB,MAAwB,EACwC;IAChE,OAAOlB,YAAY,CAAC,IAAI,CAACe,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EAC1D;EAEA,MAAMjB,UAAUA,CACZiB,MAAwB,EACyC;IACjE,OAAOhB,YAAY,CAAC,IAAI,CAACa,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EAC1D;EAEA,MAAMf,QAAQA,CACVe,MAAuB,EAC0C;IACjE,OAAOd,UAAU,CAAC,IAAI,CAACW,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EACxD;EAEA,MAAMb,uBAAuBA,CACzBa,MAAqC,EACiD;IACtF,OAAOZ,yBAAyB,CAAC,IAAI,CAACS,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EACvE;EAEA,MAAMX,wBAAwBA,CAC1BW,MAAsC,EACkD;IACxF,OAAOV,0BAA0B,CAAC,IAAI,CAACO,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EACxE;EAEA,MAAMT,qBAAqBA,CACvBS,MAAmC,EAC8C;IACjF,OAAOR,uBAAuB,CAAC,IAAI,CAACK,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EACrE;EAEA,MAAMP,uBAAuBA,CACzBO,MAAqC,EAC4B;IACjE,OAAON,yBAAyB,CAAC,IAAI,CAACG,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EACvE;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { WebinyConfig } from "./types.js";
|
|
2
|
+
import type { CreateTenantParams } from "./methods/tenantManager/createTenant.js";
|
|
3
|
+
import type { InstallTenantParams } from "./methods/tenantManager/installTenant.js";
|
|
4
|
+
import type { DisableTenantParams } from "./methods/tenantManager/disableTenant.js";
|
|
5
|
+
import type { EnableTenantParams } from "./methods/tenantManager/enableTenant.js";
|
|
6
|
+
import type { HttpError, GraphQLError, NetworkError } from "./errors.js";
|
|
7
|
+
import type { Result } from "./Result.js";
|
|
8
|
+
import type { Tenant } from "./methods/tenantManager/getCurrentTenant.js";
|
|
9
|
+
export declare class TenantManagerSdk {
|
|
10
|
+
private config;
|
|
11
|
+
private fetchFn;
|
|
12
|
+
constructor(config: WebinyConfig);
|
|
13
|
+
createTenant(params: CreateTenantParams): Promise<Result<boolean, HttpError | GraphQLError | NetworkError>>;
|
|
14
|
+
installTenant(params: InstallTenantParams): Promise<Result<boolean, HttpError | GraphQLError | NetworkError>>;
|
|
15
|
+
disableTenant(params: DisableTenantParams): Promise<Result<boolean, HttpError | GraphQLError | NetworkError>>;
|
|
16
|
+
enableTenant(params: EnableTenantParams): Promise<Result<boolean, HttpError | GraphQLError | NetworkError>>;
|
|
17
|
+
getCurrentTenant(): Promise<Result<Tenant, HttpError | GraphQLError | NetworkError>>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createTenant as createTenantFn } from "./methods/tenantManager/createTenant.js";
|
|
2
|
+
import { installTenant as installTenantFn } from "./methods/tenantManager/installTenant.js";
|
|
3
|
+
import { disableTenant as disableTenantFn } from "./methods/tenantManager/disableTenant.js";
|
|
4
|
+
import { enableTenant as enableTenantFn } from "./methods/tenantManager/enableTenant.js";
|
|
5
|
+
import { getCurrentTenant as getCurrentTenantFn } from "./methods/tenantManager/getCurrentTenant.js";
|
|
6
|
+
export class TenantManagerSdk {
|
|
7
|
+
constructor(config) {
|
|
8
|
+
this.config = config;
|
|
9
|
+
this.fetchFn = config.fetch || fetch;
|
|
10
|
+
}
|
|
11
|
+
async createTenant(params) {
|
|
12
|
+
return createTenantFn(this.config, this.fetchFn, params);
|
|
13
|
+
}
|
|
14
|
+
async installTenant(params) {
|
|
15
|
+
return installTenantFn(this.config, this.fetchFn, params);
|
|
16
|
+
}
|
|
17
|
+
async disableTenant(params) {
|
|
18
|
+
return disableTenantFn(this.config, this.fetchFn, params);
|
|
19
|
+
}
|
|
20
|
+
async enableTenant(params) {
|
|
21
|
+
return enableTenantFn(this.config, this.fetchFn, params);
|
|
22
|
+
}
|
|
23
|
+
async getCurrentTenant() {
|
|
24
|
+
return getCurrentTenantFn(this.config, this.fetchFn);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=TenantManagerSdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createTenant","createTenantFn","installTenant","installTenantFn","disableTenant","disableTenantFn","enableTenant","enableTenantFn","getCurrentTenant","getCurrentTenantFn","TenantManagerSdk","constructor","config","fetchFn","fetch","params"],"sources":["TenantManagerSdk.ts"],"sourcesContent":["import type { WebinyConfig } from \"./types.js\";\nimport type { CreateTenantParams } from \"./methods/tenantManager/createTenant.js\";\nimport type { InstallTenantParams } from \"./methods/tenantManager/installTenant.js\";\nimport type { DisableTenantParams } from \"./methods/tenantManager/disableTenant.js\";\nimport type { EnableTenantParams } from \"./methods/tenantManager/enableTenant.js\";\nimport type { HttpError, GraphQLError, NetworkError } from \"./errors.js\";\nimport type { Result } from \"./Result.js\";\nimport { createTenant as createTenantFn } from \"./methods/tenantManager/createTenant.js\";\nimport { installTenant as installTenantFn } from \"./methods/tenantManager/installTenant.js\";\nimport { disableTenant as disableTenantFn } from \"./methods/tenantManager/disableTenant.js\";\nimport { enableTenant as enableTenantFn } from \"./methods/tenantManager/enableTenant.js\";\nimport { getCurrentTenant as getCurrentTenantFn } from \"./methods/tenantManager/getCurrentTenant.js\";\nimport type { Tenant } from \"./methods/tenantManager/getCurrentTenant.js\";\n\nexport class TenantManagerSdk {\n private config: WebinyConfig;\n private fetchFn: typeof fetch;\n\n constructor(config: WebinyConfig) {\n this.config = config;\n this.fetchFn = config.fetch || fetch;\n }\n\n async createTenant(\n params: CreateTenantParams\n ): Promise<Result<boolean, HttpError | GraphQLError | NetworkError>> {\n return createTenantFn(this.config, this.fetchFn, params);\n }\n\n async installTenant(\n params: InstallTenantParams\n ): Promise<Result<boolean, HttpError | GraphQLError | NetworkError>> {\n return installTenantFn(this.config, this.fetchFn, params);\n }\n\n async disableTenant(\n params: DisableTenantParams\n ): Promise<Result<boolean, HttpError | GraphQLError | NetworkError>> {\n return disableTenantFn(this.config, this.fetchFn, params);\n }\n\n async enableTenant(\n params: EnableTenantParams\n ): Promise<Result<boolean, HttpError | GraphQLError | NetworkError>> {\n return enableTenantFn(this.config, this.fetchFn, params);\n }\n\n async getCurrentTenant(): Promise<Result<Tenant, HttpError | GraphQLError | NetworkError>> {\n return getCurrentTenantFn(this.config, this.fetchFn);\n }\n}\n"],"mappings":"AAOA,SAASA,YAAY,IAAIC,cAAc;AACvC,SAASC,aAAa,IAAIC,eAAe;AACzC,SAASC,aAAa,IAAIC,eAAe;AACzC,SAASC,YAAY,IAAIC,cAAc;AACvC,SAASC,gBAAgB,IAAIC,kBAAkB;AAG/C,OAAO,MAAMC,gBAAgB,CAAC;EAI1BC,WAAWA,CAACC,MAAoB,EAAE;IAC9B,IAAI,CAACA,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACE,KAAK,IAAIA,KAAK;EACxC;EAEA,MAAMd,YAAYA,CACde,MAA0B,EACuC;IACjE,OAAOd,cAAc,CAAC,IAAI,CAACW,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EAC5D;EAEA,MAAMb,aAAaA,CACfa,MAA2B,EACsC;IACjE,OAAOZ,eAAe,CAAC,IAAI,CAACS,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EAC7D;EAEA,MAAMX,aAAaA,CACfW,MAA2B,EACsC;IACjE,OAAOV,eAAe,CAAC,IAAI,CAACO,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EAC7D;EAEA,MAAMT,YAAYA,CACdS,MAA0B,EACuC;IACjE,OAAOR,cAAc,CAAC,IAAI,CAACK,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EAC5D;EAEA,MAAMP,gBAAgBA,CAAA,EAAqE;IACvF,OAAOC,kBAAkB,CAAC,IAAI,CAACG,MAAM,EAAE,IAAI,CAACC,OAAO,CAAC;EACxD;AACJ","ignoreList":[]}
|
package/Webiny.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { WebinyConfig } from "./types.js";
|
|
2
2
|
import { CmsSdk } from "./CmsSdk.js";
|
|
3
|
+
import { TenantManagerSdk } from "./TenantManagerSdk.js";
|
|
4
|
+
import { FileManagerSdk } from "./FileManagerSdk.js";
|
|
3
5
|
export declare class Webiny {
|
|
4
6
|
readonly cms: CmsSdk;
|
|
7
|
+
readonly tenantManager: TenantManagerSdk;
|
|
8
|
+
readonly fileManager: FileManagerSdk;
|
|
5
9
|
constructor(config: WebinyConfig);
|
|
6
10
|
}
|
|
7
11
|
export { Webiny as Sdk };
|
package/Webiny.js
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { CmsSdk } from "./CmsSdk.js";
|
|
2
|
+
import { TenantManagerSdk } from "./TenantManagerSdk.js";
|
|
3
|
+
import { FileManagerSdk } from "./FileManagerSdk.js";
|
|
2
4
|
export class Webiny {
|
|
3
5
|
constructor(config) {
|
|
4
6
|
this.cms = new CmsSdk({
|
|
5
7
|
...config,
|
|
6
8
|
tenant: config.tenant || "root"
|
|
7
9
|
});
|
|
10
|
+
this.tenantManager = new TenantManagerSdk({
|
|
11
|
+
...config,
|
|
12
|
+
tenant: config.tenant || "root"
|
|
13
|
+
});
|
|
14
|
+
this.fileManager = new FileManagerSdk({
|
|
15
|
+
...config,
|
|
16
|
+
tenant: config.tenant || "root"
|
|
17
|
+
});
|
|
8
18
|
}
|
|
9
19
|
}
|
|
10
20
|
|
package/Webiny.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CmsSdk","Webiny","constructor","config","cms","tenant","Sdk"],"sources":["Webiny.ts"],"sourcesContent":["import type { WebinyConfig } from \"./types.js\";\nimport { CmsSdk } from \"./CmsSdk.js\";\n\nexport class Webiny {\n public readonly cms: CmsSdk;\n\n constructor(config: WebinyConfig) {\n this.cms = new CmsSdk({\n ...config,\n tenant: config.tenant || \"root\"\n });\n }\n}\n\n// Backward compatibility exports.\nexport { Webiny as Sdk };\nexport type { WebinyConfig as SdkConfig };\n"],"mappings":"AACA,SAASA,MAAM;
|
|
1
|
+
{"version":3,"names":["CmsSdk","TenantManagerSdk","FileManagerSdk","Webiny","constructor","config","cms","tenant","tenantManager","fileManager","Sdk"],"sources":["Webiny.ts"],"sourcesContent":["import type { WebinyConfig } from \"./types.js\";\nimport { CmsSdk } from \"./CmsSdk.js\";\nimport { TenantManagerSdk } from \"./TenantManagerSdk.js\";\nimport { FileManagerSdk } from \"./FileManagerSdk.js\";\n\nexport class Webiny {\n public readonly cms: CmsSdk;\n public readonly tenantManager: TenantManagerSdk;\n public readonly fileManager: FileManagerSdk;\n\n constructor(config: WebinyConfig) {\n this.cms = new CmsSdk({\n ...config,\n tenant: config.tenant || \"root\"\n });\n this.tenantManager = new TenantManagerSdk({\n ...config,\n tenant: config.tenant || \"root\"\n });\n this.fileManager = new FileManagerSdk({\n ...config,\n tenant: config.tenant || \"root\"\n });\n }\n}\n\n// Backward compatibility exports.\nexport { Webiny as Sdk };\nexport type { WebinyConfig as SdkConfig };\n"],"mappings":"AACA,SAASA,MAAM;AACf,SAASC,gBAAgB;AACzB,SAASC,cAAc;AAEvB,OAAO,MAAMC,MAAM,CAAC;EAKhBC,WAAWA,CAACC,MAAoB,EAAE;IAC9B,IAAI,CAACC,GAAG,GAAG,IAAIN,MAAM,CAAC;MAClB,GAAGK,MAAM;MACTE,MAAM,EAAEF,MAAM,CAACE,MAAM,IAAI;IAC7B,CAAC,CAAC;IACF,IAAI,CAACC,aAAa,GAAG,IAAIP,gBAAgB,CAAC;MACtC,GAAGI,MAAM;MACTE,MAAM,EAAEF,MAAM,CAACE,MAAM,IAAI;IAC7B,CAAC,CAAC;IACF,IAAI,CAACE,WAAW,GAAG,IAAIP,cAAc,CAAC;MAClC,GAAGG,MAAM;MACTE,MAAM,EAAEF,MAAM,CAACE,MAAM,IAAI;IAC7B,CAAC,CAAC;EACN;AACJ;;AAEA;AACA,SAASJ,MAAM,IAAIO,GAAG","ignoreList":[]}
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from "./Webiny.js";
|
|
2
2
|
export * from "./CmsSdk.js";
|
|
3
|
+
export * from "./TenantManagerSdk.js";
|
|
4
|
+
export * from "./FileManagerSdk.js";
|
|
3
5
|
export * from "./types.js";
|
|
4
6
|
export { Result } from "./Result.js";
|
|
5
7
|
export { HttpError, GraphQLError, NetworkError } from "./errors.js";
|
|
@@ -11,3 +13,20 @@ export type { ListEntriesParams, ListEntriesResult } from "./methods/cms/listEnt
|
|
|
11
13
|
export type { DeleteEntryRevisionParams } from "./methods/cms/deleteEntryRevision.js";
|
|
12
14
|
export type { PublishEntryRevisionParams } from "./methods/cms/publishEntryRevision.js";
|
|
13
15
|
export type { UnpublishEntryRevisionParams } from "./methods/cms/unpublishEntryRevision.js";
|
|
16
|
+
export type { CreateTenantInput } from "./methods/tenantManager/tenantManagerTypes.js";
|
|
17
|
+
export type { CreateTenantParams } from "./methods/tenantManager/createTenant.js";
|
|
18
|
+
export type { InstallTenantParams } from "./methods/tenantManager/installTenant.js";
|
|
19
|
+
export type { DisableTenantParams } from "./methods/tenantManager/disableTenant.js";
|
|
20
|
+
export type { EnableTenantParams } from "./methods/tenantManager/enableTenant.js";
|
|
21
|
+
export type { FmIdentity, FmLocation, FmFile, FmTag, FmListMeta, FmLocationInput, FmLocationWhereInput, FmFileListWhereInput, FmFileListSorter, FmTagsListWhereInput, UploadProgress, PresignedPostPayload, PresignedPostPayloadResponse, BatchUploadStrategy } from "./methods/fileManager/fileManagerTypes.js";
|
|
22
|
+
export type { GetFileParams } from "./methods/fileManager/getFile.js";
|
|
23
|
+
export type { ListFilesParams, ListFilesResult } from "./methods/fileManager/listFiles.js";
|
|
24
|
+
export type { CreateFileData, CreateFileParams } from "./methods/fileManager/createFile.js";
|
|
25
|
+
export type { CreateFilesParams, CreateFilesResult } from "./methods/fileManager/createFiles.js";
|
|
26
|
+
export type { UpdateFileData, UpdateFileParams } from "./methods/fileManager/updateFile.js";
|
|
27
|
+
export type { DeleteFileParams } from "./methods/fileManager/deleteFile.js";
|
|
28
|
+
export type { ListTagsParams } from "./methods/fileManager/listTags.js";
|
|
29
|
+
export type { GetPresignedPostPayloadParams } from "./methods/fileManager/getPresignedPostPayload.js";
|
|
30
|
+
export type { GetPresignedPostPayloadsParams } from "./methods/fileManager/getPresignedPostPayloads.js";
|
|
31
|
+
export type { CreateMultiPartUploadParams, MultiPartUploadResponse } from "./methods/fileManager/createMultiPartUpload.js";
|
|
32
|
+
export type { CompleteMultiPartUploadParams } from "./methods/fileManager/completeMultiPartUpload.js";
|
package/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from "./Webiny.js";
|
|
2
2
|
export * from "./CmsSdk.js";
|
|
3
|
+
export * from "./TenantManagerSdk.js";
|
|
4
|
+
export * from "./FileManagerSdk.js";
|
|
3
5
|
export * from "./types.js";
|
|
4
6
|
export { Result } from "./Result.js";
|
|
5
7
|
export { HttpError, GraphQLError, NetworkError } from "./errors.js";
|
|
@@ -8,4 +10,12 @@ export { HttpError, GraphQLError, NetworkError } from "./errors.js";
|
|
|
8
10
|
|
|
9
11
|
// Export types from methods.
|
|
10
12
|
|
|
13
|
+
// Export TenantManager types.
|
|
14
|
+
|
|
15
|
+
// Export types from tenantManager methods.
|
|
16
|
+
|
|
17
|
+
// Export FileManager types.
|
|
18
|
+
|
|
19
|
+
// Export types from fileManager methods.
|
|
20
|
+
|
|
11
21
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Result","HttpError","GraphQLError","NetworkError"],"sources":["index.ts"],"sourcesContent":["export * from \"./Webiny.js\";\nexport * from \"./CmsSdk.js\";\nexport * from \"./types.js\";\nexport { Result } from \"./Result.js\";\nexport { HttpError, GraphQLError, NetworkError } from \"./errors.js\";\n\n// Export shared CMS types.\nexport type {\n CmsEntryValues,\n CmsEntryStatus,\n CmsIdentity,\n IEntryState,\n CmsEntryData\n} from \"./methods/cms/cmsTypes.js\";\n\n// Export types from methods.\nexport type { CreateCmsEntryData, CreateEntryParams } from \"./methods/cms/createEntry.js\";\n\nexport type {\n UpdateCmsEntryData,\n UpdateEntryRevisionParams\n} from \"./methods/cms/updateEntryRevision.js\";\n\nexport type { GetEntryParams, GetEntryWhere } from \"./methods/cms/getEntry.js\";\n\nexport type { ListEntriesParams, ListEntriesResult } from \"./methods/cms/listEntries.js\";\n\nexport type { DeleteEntryRevisionParams } from \"./methods/cms/deleteEntryRevision.js\";\n\nexport type { PublishEntryRevisionParams } from \"./methods/cms/publishEntryRevision.js\";\n\nexport type { UnpublishEntryRevisionParams } from \"./methods/cms/unpublishEntryRevision.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAM;AACf,SAASC,SAAS,EAAEC,YAAY,EAAEC,YAAY;;AAE9C;;AASA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Result","HttpError","GraphQLError","NetworkError"],"sources":["index.ts"],"sourcesContent":["export * from \"./Webiny.js\";\nexport * from \"./CmsSdk.js\";\nexport * from \"./TenantManagerSdk.js\";\nexport * from \"./FileManagerSdk.js\";\nexport * from \"./types.js\";\nexport { Result } from \"./Result.js\";\nexport { HttpError, GraphQLError, NetworkError } from \"./errors.js\";\n\n// Export shared CMS types.\nexport type {\n CmsEntryValues,\n CmsEntryStatus,\n CmsIdentity,\n IEntryState,\n CmsEntryData\n} from \"./methods/cms/cmsTypes.js\";\n\n// Export types from methods.\nexport type { CreateCmsEntryData, CreateEntryParams } from \"./methods/cms/createEntry.js\";\n\nexport type {\n UpdateCmsEntryData,\n UpdateEntryRevisionParams\n} from \"./methods/cms/updateEntryRevision.js\";\n\nexport type { GetEntryParams, GetEntryWhere } from \"./methods/cms/getEntry.js\";\n\nexport type { ListEntriesParams, ListEntriesResult } from \"./methods/cms/listEntries.js\";\n\nexport type { DeleteEntryRevisionParams } from \"./methods/cms/deleteEntryRevision.js\";\n\nexport type { PublishEntryRevisionParams } from \"./methods/cms/publishEntryRevision.js\";\n\nexport type { UnpublishEntryRevisionParams } from \"./methods/cms/unpublishEntryRevision.js\";\n\n// Export TenantManager types.\nexport type { CreateTenantInput } from \"./methods/tenantManager/tenantManagerTypes.js\";\n\n// Export types from tenantManager methods.\nexport type { CreateTenantParams } from \"./methods/tenantManager/createTenant.js\";\n\nexport type { InstallTenantParams } from \"./methods/tenantManager/installTenant.js\";\n\nexport type { DisableTenantParams } from \"./methods/tenantManager/disableTenant.js\";\n\nexport type { EnableTenantParams } from \"./methods/tenantManager/enableTenant.js\";\n\n// Export FileManager types.\nexport type {\n FmIdentity,\n FmLocation,\n FmFile,\n FmTag,\n FmListMeta,\n FmLocationInput,\n FmLocationWhereInput,\n FmFileListWhereInput,\n FmFileListSorter,\n FmTagsListWhereInput,\n UploadProgress,\n PresignedPostPayload,\n PresignedPostPayloadResponse,\n BatchUploadStrategy\n} from \"./methods/fileManager/fileManagerTypes.js\";\n\n// Export types from fileManager methods.\nexport type { GetFileParams } from \"./methods/fileManager/getFile.js\";\n\nexport type { ListFilesParams, ListFilesResult } from \"./methods/fileManager/listFiles.js\";\n\nexport type { CreateFileData, CreateFileParams } from \"./methods/fileManager/createFile.js\";\n\nexport type { CreateFilesParams, CreateFilesResult } from \"./methods/fileManager/createFiles.js\";\n\nexport type { UpdateFileData, UpdateFileParams } from \"./methods/fileManager/updateFile.js\";\n\nexport type { DeleteFileParams } from \"./methods/fileManager/deleteFile.js\";\n\nexport type { ListTagsParams } from \"./methods/fileManager/listTags.js\";\n\nexport type { GetPresignedPostPayloadParams } from \"./methods/fileManager/getPresignedPostPayload.js\";\n\nexport type { GetPresignedPostPayloadsParams } from \"./methods/fileManager/getPresignedPostPayloads.js\";\n\nexport type {\n CreateMultiPartUploadParams,\n MultiPartUploadResponse\n} from \"./methods/fileManager/createMultiPartUpload.js\";\n\nexport type { CompleteMultiPartUploadParams } from \"./methods/fileManager/completeMultiPartUpload.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,SAASA,MAAM;AACf,SAASC,SAAS,EAAEC,YAAY,EAAEC,YAAY;;AAE9C;;AASA;;AAkBA;;AAGA;;AASA;;AAkBA","ignoreList":[]}
|
|
@@ -8,6 +8,7 @@ export interface ListEntriesParams {
|
|
|
8
8
|
sort?: Record<string, "asc" | "desc">;
|
|
9
9
|
limit?: number;
|
|
10
10
|
after?: string;
|
|
11
|
+
search?: string;
|
|
11
12
|
fields: string[];
|
|
12
13
|
preview?: boolean;
|
|
13
14
|
}
|
|
@@ -31,6 +32,7 @@ export interface ListEntriesResult<TValues extends CmsEntryValues = CmsEntryValu
|
|
|
31
32
|
* @param params.sort - Optional sort configuration
|
|
32
33
|
* @param params.limit - Maximum number of entries to return (default: 10)
|
|
33
34
|
* @param params.after - Cursor for pagination
|
|
35
|
+
* @param params.search - Optional full-text search term to filter entries across searchable fields (text, longText fields with fullTextSearch enabled)
|
|
34
36
|
* @param params.fields - Specific fields to return. Use "values." prefix for entry values (e.g., "values.author.name") or specify top-level fields like "createdOn"
|
|
35
37
|
* @param params.preview - When true, uses preview API to access unpublished/draft content. When false (default), uses read API for published content only.
|
|
36
38
|
* @returns Result containing list of entries with pagination metadata or an error
|
|
@@ -11,6 +11,7 @@ import { Result } from "../../Result.js";
|
|
|
11
11
|
* @param params.sort - Optional sort configuration
|
|
12
12
|
* @param params.limit - Maximum number of entries to return (default: 10)
|
|
13
13
|
* @param params.after - Cursor for pagination
|
|
14
|
+
* @param params.search - Optional full-text search term to filter entries across searchable fields (text, longText fields with fullTextSearch enabled)
|
|
14
15
|
* @param params.fields - Specific fields to return. Use "values." prefix for entry values (e.g., "values.author.name") or specify top-level fields like "createdOn"
|
|
15
16
|
* @param params.preview - When true, uses preview API to access unpublished/draft content. When false (default), uses read API for published content only.
|
|
16
17
|
* @returns Result containing list of entries with pagination metadata or an error
|
|
@@ -22,6 +23,7 @@ export async function listEntries(config, fetchFn, params) {
|
|
|
22
23
|
sort,
|
|
23
24
|
limit = 10,
|
|
24
25
|
after,
|
|
26
|
+
search,
|
|
25
27
|
fields,
|
|
26
28
|
preview
|
|
27
29
|
} = params;
|
|
@@ -35,6 +37,7 @@ export async function listEntries(config, fetchFn, params) {
|
|
|
35
37
|
$sort: JSON
|
|
36
38
|
$limit: Int
|
|
37
39
|
$after: String
|
|
40
|
+
$search: String
|
|
38
41
|
$fields: [String!]!
|
|
39
42
|
$preview: Boolean
|
|
40
43
|
) {
|
|
@@ -45,6 +48,7 @@ export async function listEntries(config, fetchFn, params) {
|
|
|
45
48
|
sort: $sort
|
|
46
49
|
limit: $limit
|
|
47
50
|
after: $after
|
|
51
|
+
search: $search
|
|
48
52
|
fields: $fields
|
|
49
53
|
preview: $preview
|
|
50
54
|
) {
|
|
@@ -68,6 +72,7 @@ export async function listEntries(config, fetchFn, params) {
|
|
|
68
72
|
sort,
|
|
69
73
|
limit,
|
|
70
74
|
after,
|
|
75
|
+
search,
|
|
71
76
|
fields,
|
|
72
77
|
preview
|
|
73
78
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Result","listEntries","config","fetchFn","params","modelId","where","sort","limit","after","fields","preview","executeGraphQL","query","result","isFail","fail","error","responseData","value","cms","GraphQLError","message","code","ok","data","meta"],"sources":["listEntries.ts"],"sourcesContent":["import type { WebinyConfig } from \"../../types.js\";\nimport { Result } from \"../../Result.js\";\nimport type { HttpError, GraphQLError, NetworkError } from \"../../errors.js\";\nimport type { CmsEntryValues, CmsEntryData } from \"./cmsTypes.js\";\n\nexport interface ListEntriesParams {\n modelId: string;\n where?: Record<string, unknown>;\n sort?: Record<string, \"asc\" | \"desc\">;\n limit?: number;\n after?: string;\n fields: string[];\n preview?: boolean;\n}\n\nexport interface ListEntriesResult<TValues extends CmsEntryValues = CmsEntryValues> {\n data: CmsEntryData<TValues>[];\n meta: {\n cursor: string | null;\n hasMoreItems: boolean;\n totalCount: number;\n };\n}\n\n/**\n * Lists entries from the CMS with filtering, sorting, and pagination support.\n *\n * @template TValues - Type of the entry data objects. Users should specify this to include all fields they're requesting (id, entryId, values, createdOn, etc.)\n * @param config - SDK configuration\n * @param fetchFn - Fetch function to use for HTTP requests\n * @param params - Parameters for listing entries\n * @param params.modelId - The model ID of entries to list\n * @param params.where - Optional where conditions to filter entries\n * @param params.sort - Optional sort configuration\n * @param params.limit - Maximum number of entries to return (default: 10)\n * @param params.after - Cursor for pagination\n * @param params.fields - Specific fields to return. Use \"values.\" prefix for entry values (e.g., \"values.author.name\") or specify top-level fields like \"createdOn\"\n * @param params.preview - When true, uses preview API to access unpublished/draft content. When false (default), uses read API for published content only.\n * @returns Result containing list of entries with pagination metadata or an error\n */\nexport async function listEntries<TValues extends CmsEntryValues = CmsEntryValues>(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: ListEntriesParams\n): Promise<Result<ListEntriesResult<TValues>, HttpError | GraphQLError | NetworkError>> {\n const { modelId, where, sort, limit = 10, after, fields, preview } = params;\n\n const { executeGraphQL } = await import(\"../executeGraphQL.js\");\n\n const query = `\n query ListEntries(\n $modelId: ID!\n $where: JSON\n $sort: JSON\n $limit: Int\n $after: String\n $fields: [String!]!\n $preview: Boolean\n ) {\n cms {\n listEntries(\n modelId: $modelId\n where: $where\n sort: $sort\n limit: $limit\n after: $after\n fields: $fields\n preview: $preview\n ) {\n data\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 modelId,\n where,\n sort,\n limit,\n after,\n fields,\n preview\n });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.cms.listEntries.error) {\n const { GraphQLError } = await import(\"../../errors.js\");\n return Result.fail(\n new GraphQLError(\n responseData.cms.listEntries.error.message,\n responseData.cms.listEntries.error.code\n )\n );\n }\n\n return Result.ok({\n data: responseData.cms.listEntries.data,\n meta: responseData.cms.listEntries.meta\n });\n}\n"],"mappings":"AACA,SAASA,MAAM;
|
|
1
|
+
{"version":3,"names":["Result","listEntries","config","fetchFn","params","modelId","where","sort","limit","after","search","fields","preview","executeGraphQL","query","result","isFail","fail","error","responseData","value","cms","GraphQLError","message","code","ok","data","meta"],"sources":["listEntries.ts"],"sourcesContent":["import type { WebinyConfig } from \"../../types.js\";\nimport { Result } from \"../../Result.js\";\nimport type { HttpError, GraphQLError, NetworkError } from \"../../errors.js\";\nimport type { CmsEntryValues, CmsEntryData } from \"./cmsTypes.js\";\n\nexport interface ListEntriesParams {\n modelId: string;\n where?: Record<string, unknown>;\n sort?: Record<string, \"asc\" | \"desc\">;\n limit?: number;\n after?: string;\n search?: string;\n fields: string[];\n preview?: boolean;\n}\n\nexport interface ListEntriesResult<TValues extends CmsEntryValues = CmsEntryValues> {\n data: CmsEntryData<TValues>[];\n meta: {\n cursor: string | null;\n hasMoreItems: boolean;\n totalCount: number;\n };\n}\n\n/**\n * Lists entries from the CMS with filtering, sorting, and pagination support.\n *\n * @template TValues - Type of the entry data objects. Users should specify this to include all fields they're requesting (id, entryId, values, createdOn, etc.)\n * @param config - SDK configuration\n * @param fetchFn - Fetch function to use for HTTP requests\n * @param params - Parameters for listing entries\n * @param params.modelId - The model ID of entries to list\n * @param params.where - Optional where conditions to filter entries\n * @param params.sort - Optional sort configuration\n * @param params.limit - Maximum number of entries to return (default: 10)\n * @param params.after - Cursor for pagination\n * @param params.search - Optional full-text search term to filter entries across searchable fields (text, longText fields with fullTextSearch enabled)\n * @param params.fields - Specific fields to return. Use \"values.\" prefix for entry values (e.g., \"values.author.name\") or specify top-level fields like \"createdOn\"\n * @param params.preview - When true, uses preview API to access unpublished/draft content. When false (default), uses read API for published content only.\n * @returns Result containing list of entries with pagination metadata or an error\n */\nexport async function listEntries<TValues extends CmsEntryValues = CmsEntryValues>(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: ListEntriesParams\n): Promise<Result<ListEntriesResult<TValues>, HttpError | GraphQLError | NetworkError>> {\n const { modelId, where, sort, limit = 10, after, search, fields, preview } = params;\n\n const { executeGraphQL } = await import(\"../executeGraphQL.js\");\n\n const query = `\n query ListEntries(\n $modelId: ID!\n $where: JSON\n $sort: JSON\n $limit: Int\n $after: String\n $search: String\n $fields: [String!]!\n $preview: Boolean\n ) {\n cms {\n listEntries(\n modelId: $modelId\n where: $where\n sort: $sort\n limit: $limit\n after: $after\n search: $search\n fields: $fields\n preview: $preview\n ) {\n data\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 modelId,\n where,\n sort,\n limit,\n after,\n search,\n fields,\n preview\n });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.cms.listEntries.error) {\n const { GraphQLError } = await import(\"../../errors.js\");\n return Result.fail(\n new GraphQLError(\n responseData.cms.listEntries.error.message,\n responseData.cms.listEntries.error.code\n )\n );\n }\n\n return Result.ok({\n data: responseData.cms.listEntries.data,\n meta: responseData.cms.listEntries.meta\n });\n}\n"],"mappings":"AACA,SAASA,MAAM;AAwBf;AACA;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,EAC2D;EACpF,MAAM;IAAEC,OAAO;IAAEC,KAAK;IAAEC,IAAI;IAAEC,KAAK,GAAG,EAAE;IAAEC,KAAK;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGR,MAAM;EAEnF,MAAM;IAAES;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;EAED,MAAMC,MAAM,GAAG,MAAMF,cAAc,CAACX,MAAM,EAAEC,OAAO,EAAEW,KAAK,EAAE;IACxDT,OAAO;IACPC,KAAK;IACLC,IAAI;IACJC,KAAK;IACLC,KAAK;IACLC,MAAM;IACNC,MAAM;IACNC;EACJ,CAAC,CAAC;EAEF,IAAIG,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,GAAG,CAACpB,WAAW,CAACiB,KAAK,EAAE;IACpC,MAAM;MAAEI;IAAa,CAAC,GAAG,MAAM,MAAM,kBAAkB,CAAC;IACxD,OAAOtB,MAAM,CAACiB,IAAI,CACd,IAAIK,YAAY,CACZH,YAAY,CAACE,GAAG,CAACpB,WAAW,CAACiB,KAAK,CAACK,OAAO,EAC1CJ,YAAY,CAACE,GAAG,CAACpB,WAAW,CAACiB,KAAK,CAACM,IACvC,CACJ,CAAC;EACL;EAEA,OAAOxB,MAAM,CAACyB,EAAE,CAAC;IACbC,IAAI,EAAEP,YAAY,CAACE,GAAG,CAACpB,WAAW,CAACyB,IAAI;IACvCC,IAAI,EAAER,YAAY,CAACE,GAAG,CAACpB,WAAW,CAAC0B;EACvC,CAAC,CAAC;AACN","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper to build GraphQL fields selection from fields array.
|
|
3
|
+
* Supports both top-level fields (e.g., "id", "name") and nested fields (e.g., "location.folderId", "createdBy.displayName").
|
|
4
|
+
* Properly merges nested fields that share common parent paths.
|
|
5
|
+
*
|
|
6
|
+
* @param fields - Array of field paths in dot notation
|
|
7
|
+
* @returns GraphQL selection string with proper field nesting
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* buildFieldsSelection(["id", "name", "location.folderId", "createdBy.id", "createdBy.displayName"])
|
|
11
|
+
* // Returns:
|
|
12
|
+
* // id
|
|
13
|
+
* // name
|
|
14
|
+
* // location {
|
|
15
|
+
* // folderId
|
|
16
|
+
* // }
|
|
17
|
+
* // createdBy {
|
|
18
|
+
* // id
|
|
19
|
+
* // displayName
|
|
20
|
+
* // }
|
|
21
|
+
*/
|
|
22
|
+
export declare const buildFieldsSelection: (fields: string[]) => string;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper to build GraphQL fields selection from fields array.
|
|
3
|
+
* Supports both top-level fields (e.g., "id", "name") and nested fields (e.g., "location.folderId", "createdBy.displayName").
|
|
4
|
+
* Properly merges nested fields that share common parent paths.
|
|
5
|
+
*
|
|
6
|
+
* @param fields - Array of field paths in dot notation
|
|
7
|
+
* @returns GraphQL selection string with proper field nesting
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* buildFieldsSelection(["id", "name", "location.folderId", "createdBy.id", "createdBy.displayName"])
|
|
11
|
+
* // Returns:
|
|
12
|
+
* // id
|
|
13
|
+
* // name
|
|
14
|
+
* // location {
|
|
15
|
+
* // folderId
|
|
16
|
+
* // }
|
|
17
|
+
* // createdBy {
|
|
18
|
+
* // id
|
|
19
|
+
* // displayName
|
|
20
|
+
* // }
|
|
21
|
+
*/
|
|
22
|
+
export const buildFieldsSelection = fields => {
|
|
23
|
+
const fieldTree = {};
|
|
24
|
+
fields.forEach(field => {
|
|
25
|
+
const parts = field.split(".");
|
|
26
|
+
let current = fieldTree;
|
|
27
|
+
parts.forEach((part, index) => {
|
|
28
|
+
if (current[part] === undefined) {
|
|
29
|
+
// Leaf node (null) or new branch (empty object)
|
|
30
|
+
current[part] = index === parts.length - 1 ? null : {};
|
|
31
|
+
} else if (current[part] === null && index < parts.length - 1) {
|
|
32
|
+
// Convert leaf to branch if we need to traverse deeper
|
|
33
|
+
current[part] = {};
|
|
34
|
+
}
|
|
35
|
+
if (current[part] !== null) {
|
|
36
|
+
current = current[part];
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Recursively converts the field tree into a GraphQL selection string.
|
|
43
|
+
*
|
|
44
|
+
* @param node - The current field tree node to process
|
|
45
|
+
* @param indent - Current indentation level for formatting
|
|
46
|
+
* @returns GraphQL selection string for this node and its children
|
|
47
|
+
*
|
|
48
|
+
* Handles two cases:
|
|
49
|
+
* - Leaf nodes (value === null): Simple field name
|
|
50
|
+
* - Branch nodes (value === object): Field name with nested selection in braces
|
|
51
|
+
*/
|
|
52
|
+
const buildSelection = (node, indent = " ") => {
|
|
53
|
+
const lines = [];
|
|
54
|
+
Object.keys(node).sort().forEach(key => {
|
|
55
|
+
const value = node[key];
|
|
56
|
+
if (value === null) {
|
|
57
|
+
// Leaf field - just the field name
|
|
58
|
+
lines.push(`${indent}${key}`);
|
|
59
|
+
} else {
|
|
60
|
+
// Branch field - field name with nested selection
|
|
61
|
+
lines.push(`${indent}${key} {`);
|
|
62
|
+
lines.push(buildSelection(value, indent + " "));
|
|
63
|
+
lines.push(`${indent}}`);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return lines.join("\n");
|
|
67
|
+
};
|
|
68
|
+
return buildSelection(fieldTree);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=buildFieldsSelection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["buildFieldsSelection","fields","fieldTree","forEach","field","parts","split","current","part","index","undefined","length","buildSelection","node","indent","lines","Object","keys","sort","key","value","push","join"],"sources":["buildFieldsSelection.ts"],"sourcesContent":["/**\n * Helper to build GraphQL fields selection from fields array.\n * Supports both top-level fields (e.g., \"id\", \"name\") and nested fields (e.g., \"location.folderId\", \"createdBy.displayName\").\n * Properly merges nested fields that share common parent paths.\n *\n * @param fields - Array of field paths in dot notation\n * @returns GraphQL selection string with proper field nesting\n *\n * @example\n * buildFieldsSelection([\"id\", \"name\", \"location.folderId\", \"createdBy.id\", \"createdBy.displayName\"])\n * // Returns:\n * // id\n * // name\n * // location {\n * // folderId\n * // }\n * // createdBy {\n * // id\n * // displayName\n * // }\n */\nexport const buildFieldsSelection = (fields: string[]): string => {\n interface FieldNode {\n [key: string]: FieldNode | null;\n }\n\n const fieldTree: FieldNode = {};\n\n fields.forEach(field => {\n const parts = field.split(\".\");\n let current = fieldTree;\n\n parts.forEach((part, index) => {\n if (current[part] === undefined) {\n // Leaf node (null) or new branch (empty object)\n current[part] = index === parts.length - 1 ? null : {};\n } else if (current[part] === null && index < parts.length - 1) {\n // Convert leaf to branch if we need to traverse deeper\n current[part] = {};\n }\n if (current[part] !== null) {\n current = current[part] as FieldNode;\n }\n });\n });\n\n /**\n * Recursively converts the field tree into a GraphQL selection string.\n *\n * @param node - The current field tree node to process\n * @param indent - Current indentation level for formatting\n * @returns GraphQL selection string for this node and its children\n *\n * Handles two cases:\n * - Leaf nodes (value === null): Simple field name\n * - Branch nodes (value === object): Field name with nested selection in braces\n */\n const buildSelection = (node: FieldNode, indent: string = \" \"): string => {\n const lines: string[] = [];\n\n Object.keys(node)\n .sort()\n .forEach(key => {\n const value = node[key];\n if (value === null) {\n // Leaf field - just the field name\n lines.push(`${indent}${key}`);\n } else {\n // Branch field - field name with nested selection\n lines.push(`${indent}${key} {`);\n lines.push(buildSelection(value, indent + \" \"));\n lines.push(`${indent}}`);\n }\n });\n\n return lines.join(\"\\n\");\n };\n\n return buildSelection(fieldTree);\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,oBAAoB,GAAIC,MAAgB,IAAa;EAK9D,MAAMC,SAAoB,GAAG,CAAC,CAAC;EAE/BD,MAAM,CAACE,OAAO,CAACC,KAAK,IAAI;IACpB,MAAMC,KAAK,GAAGD,KAAK,CAACE,KAAK,CAAC,GAAG,CAAC;IAC9B,IAAIC,OAAO,GAAGL,SAAS;IAEvBG,KAAK,CAACF,OAAO,CAAC,CAACK,IAAI,EAAEC,KAAK,KAAK;MAC3B,IAAIF,OAAO,CAACC,IAAI,CAAC,KAAKE,SAAS,EAAE;QAC7B;QACAH,OAAO,CAACC,IAAI,CAAC,GAAGC,KAAK,KAAKJ,KAAK,CAACM,MAAM,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC;MAC1D,CAAC,MAAM,IAAIJ,OAAO,CAACC,IAAI,CAAC,KAAK,IAAI,IAAIC,KAAK,GAAGJ,KAAK,CAACM,MAAM,GAAG,CAAC,EAAE;QAC3D;QACAJ,OAAO,CAACC,IAAI,CAAC,GAAG,CAAC,CAAC;MACtB;MACA,IAAID,OAAO,CAACC,IAAI,CAAC,KAAK,IAAI,EAAE;QACxBD,OAAO,GAAGA,OAAO,CAACC,IAAI,CAAc;MACxC;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;;EAEF;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACI,MAAMI,cAAc,GAAGA,CAACC,IAAe,EAAEC,MAAc,GAAG,UAAU,KAAa;IAC7E,MAAMC,KAAe,GAAG,EAAE;IAE1BC,MAAM,CAACC,IAAI,CAACJ,IAAI,CAAC,CACZK,IAAI,CAAC,CAAC,CACNf,OAAO,CAACgB,GAAG,IAAI;MACZ,MAAMC,KAAK,GAAGP,IAAI,CAACM,GAAG,CAAC;MACvB,IAAIC,KAAK,KAAK,IAAI,EAAE;QAChB;QACAL,KAAK,CAACM,IAAI,CAAC,GAAGP,MAAM,GAAGK,GAAG,EAAE,CAAC;MACjC,CAAC,MAAM;QACH;QACAJ,KAAK,CAACM,IAAI,CAAC,GAAGP,MAAM,GAAGK,GAAG,IAAI,CAAC;QAC/BJ,KAAK,CAACM,IAAI,CAACT,cAAc,CAACQ,KAAK,EAAEN,MAAM,GAAG,MAAM,CAAC,CAAC;QAClDC,KAAK,CAACM,IAAI,CAAC,GAAGP,MAAM,GAAG,CAAC;MAC5B;IACJ,CAAC,CAAC;IAEN,OAAOC,KAAK,CAACO,IAAI,CAAC,IAAI,CAAC;EAC3B,CAAC;EAED,OAAOV,cAAc,CAACV,SAAS,CAAC;AACpC,CAAC","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
|
+
export interface CompleteMultiPartUploadParams {
|
|
5
|
+
fileKey: string;
|
|
6
|
+
uploadId: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Completes a multi-part upload.
|
|
10
|
+
*
|
|
11
|
+
* @param config - SDK configuration
|
|
12
|
+
* @param fetchFn - Fetch function to use for HTTP requests
|
|
13
|
+
* @param params - Parameters for completing the multi-part upload
|
|
14
|
+
* @param params.fileKey - S3 key of the uploaded file
|
|
15
|
+
* @param params.uploadId - Upload ID from createMultiPartUpload
|
|
16
|
+
* @returns Result containing true on success or an error
|
|
17
|
+
*/
|
|
18
|
+
export declare function completeMultiPartUpload(config: WebinyConfig, fetchFn: typeof fetch, params: CompleteMultiPartUploadParams): Promise<Result<boolean, HttpError | GraphQLError | NetworkError>>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Result } from "../../Result.js";
|
|
2
|
+
/**
|
|
3
|
+
* Completes a multi-part upload.
|
|
4
|
+
*
|
|
5
|
+
* @param config - SDK configuration
|
|
6
|
+
* @param fetchFn - Fetch function to use for HTTP requests
|
|
7
|
+
* @param params - Parameters for completing the multi-part upload
|
|
8
|
+
* @param params.fileKey - S3 key of the uploaded file
|
|
9
|
+
* @param params.uploadId - Upload ID from createMultiPartUpload
|
|
10
|
+
* @returns Result containing true on success or an error
|
|
11
|
+
*/
|
|
12
|
+
export async function completeMultiPartUpload(config, fetchFn, params) {
|
|
13
|
+
const {
|
|
14
|
+
fileKey,
|
|
15
|
+
uploadId
|
|
16
|
+
} = params;
|
|
17
|
+
const {
|
|
18
|
+
executeGraphQL
|
|
19
|
+
} = await import("../executeGraphQL.js");
|
|
20
|
+
const query = `
|
|
21
|
+
mutation CompleteMultiPartUpload($fileKey: String!, $uploadId: String!) {
|
|
22
|
+
fileManager {
|
|
23
|
+
completeMultiPartUpload(fileKey: $fileKey, uploadId: $uploadId) {
|
|
24
|
+
data
|
|
25
|
+
error {
|
|
26
|
+
message
|
|
27
|
+
code
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
const result = await executeGraphQL(config, fetchFn, query, {
|
|
34
|
+
fileKey,
|
|
35
|
+
uploadId
|
|
36
|
+
});
|
|
37
|
+
if (result.isFail()) {
|
|
38
|
+
return Result.fail(result.error);
|
|
39
|
+
}
|
|
40
|
+
const responseData = result.value;
|
|
41
|
+
if (responseData.fileManager.completeMultiPartUpload.error) {
|
|
42
|
+
const {
|
|
43
|
+
GraphQLError
|
|
44
|
+
} = await import("../../errors.js");
|
|
45
|
+
return Result.fail(new GraphQLError(responseData.fileManager.completeMultiPartUpload.error.message, responseData.fileManager.completeMultiPartUpload.error.code));
|
|
46
|
+
}
|
|
47
|
+
return Result.ok(responseData.fileManager.completeMultiPartUpload.data);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=completeMultiPartUpload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Result","completeMultiPartUpload","config","fetchFn","params","fileKey","uploadId","executeGraphQL","query","result","isFail","fail","error","responseData","value","fileManager","GraphQLError","message","code","ok","data"],"sources":["completeMultiPartUpload.ts"],"sourcesContent":["import type { WebinyConfig } from \"../../types.js\";\nimport { Result } from \"../../Result.js\";\nimport type { HttpError, GraphQLError, NetworkError } 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 */\nexport async function completeMultiPartUpload(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: CompleteMultiPartUploadParams\n): Promise<Result<boolean, HttpError | GraphQLError | NetworkError>> {\n const { fileKey, uploadId } = params;\n\n const { executeGraphQL } = await import(\"../executeGraphQL.js\");\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 const { GraphQLError } = await import(\"../../errors.js\");\n return Result.fail(\n new GraphQLError(\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;AAQf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,uBAAuBA,CACzCC,MAAoB,EACpBC,OAAqB,EACrBC,MAAqC,EAC4B;EACjE,MAAM;IAAEC,OAAO;IAAEC;EAAS,CAAC,GAAGF,MAAM;EAEpC,MAAM;IAAEG;EAAe,CAAC,GAAG,MAAM,MAAM,uBAAuB,CAAC;EAE/D,MAAMC,KAAK,GAAG;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;EAED,MAAMC,MAAM,GAAG,MAAMF,cAAc,CAACL,MAAM,EAAEC,OAAO,EAAEK,KAAK,EAAE;IAAEH,OAAO;IAAEC;EAAS,CAAC,CAAC;EAElF,IAAIG,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;IACjB,OAAOV,MAAM,CAACW,IAAI,CAACF,MAAM,CAACG,KAAK,CAAC;EACpC;EAEA,MAAMC,YAAY,GAAGJ,MAAM,CAACK,KAAK;EAEjC,IAAID,YAAY,CAACE,WAAW,CAACd,uBAAuB,CAACW,KAAK,EAAE;IACxD,MAAM;MAAEI;IAAa,CAAC,GAAG,MAAM,MAAM,kBAAkB,CAAC;IACxD,OAAOhB,MAAM,CAACW,IAAI,CACd,IAAIK,YAAY,CACZH,YAAY,CAACE,WAAW,CAACd,uBAAuB,CAACW,KAAK,CAACK,OAAO,EAC9DJ,YAAY,CAACE,WAAW,CAACd,uBAAuB,CAACW,KAAK,CAACM,IAC3D,CACJ,CAAC;EACL;EAEA,OAAOlB,MAAM,CAACmB,EAAE,CAACN,YAAY,CAACE,WAAW,CAACd,uBAAuB,CAACmB,IAAI,CAAC;AAC3E","ignoreList":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
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, UploadProgress } from "./fileManagerTypes.js";
|
|
5
|
+
export interface CreateFileData {
|
|
6
|
+
id?: string;
|
|
7
|
+
createdOn?: Date | string;
|
|
8
|
+
modifiedOn?: Date | string;
|
|
9
|
+
savedOn?: Date | string;
|
|
10
|
+
createdBy?: FmIdentity;
|
|
11
|
+
modifiedBy?: FmIdentity;
|
|
12
|
+
savedBy?: FmIdentity;
|
|
13
|
+
location?: FmLocationInput;
|
|
14
|
+
name?: string;
|
|
15
|
+
key?: string;
|
|
16
|
+
keyPrefix?: string;
|
|
17
|
+
type?: string;
|
|
18
|
+
size?: number;
|
|
19
|
+
tags?: string[];
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}
|
|
22
|
+
export interface CreateFileParams {
|
|
23
|
+
file?: Buffer | Blob | File;
|
|
24
|
+
data: CreateFileData;
|
|
25
|
+
fields: string[];
|
|
26
|
+
onProgress?: (progress: UploadProgress) => void;
|
|
27
|
+
multiPartThreshold?: number;
|
|
28
|
+
signal?: AbortSignal;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new file in the file manager.
|
|
32
|
+
* If a file is provided, it will be uploaded to S3 first, then the record is created.
|
|
33
|
+
* If no file is provided, only the metadata record is created.
|
|
34
|
+
*
|
|
35
|
+
* @param config - SDK configuration
|
|
36
|
+
* @param fetchFn - Fetch function to use for HTTP requests
|
|
37
|
+
* @param params - Parameters for creating the file
|
|
38
|
+
* @param params.file - Optional: The actual file content to upload
|
|
39
|
+
* @param params.data - The file metadata
|
|
40
|
+
* @param params.onProgress - Optional: Progress callback
|
|
41
|
+
* @param params.multiPartThreshold - Optional: Threshold in MB for multi-part upload (default: 100)
|
|
42
|
+
* @param params.signal - Optional: AbortSignal for cancellation
|
|
43
|
+
* @returns Result containing the created file data or an error
|
|
44
|
+
*/
|
|
45
|
+
export declare function createFile(config: WebinyConfig, fetchFn: typeof fetch, params: CreateFileParams): Promise<Result<FmFile, HttpError | GraphQLError | NetworkError>>;
|