@webiny/sdk 6.3.0-beta.4 → 6.4.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BaseError.js +8 -7
- package/BaseError.js.map +1 -1
- package/CmsSdk.js +34 -33
- package/CmsSdk.js.map +1 -1
- package/FileManagerSdk.js +50 -49
- package/FileManagerSdk.js.map +1 -1
- package/LanguagesSdk.js +10 -9
- package/LanguagesSdk.js.map +1 -1
- package/Result.js +40 -134
- package/Result.js.map +1 -1
- package/TasksSdk.js +26 -25
- package/TasksSdk.js.map +1 -1
- package/TenantManagerSdk.js +26 -25
- package/TenantManagerSdk.js.map +1 -1
- package/Webiny.js +24 -26
- package/Webiny.js.map +1 -1
- package/errors.js +31 -48
- package/errors.js.map +1 -1
- package/index.js +1 -21
- package/methods/cms/cmsTypes.js +0 -3
- package/methods/cms/createEntry.js +14 -39
- package/methods/cms/createEntry.js.map +1 -1
- package/methods/cms/deleteEntryRevision.js +12 -30
- package/methods/cms/deleteEntryRevision.js.map +1 -1
- package/methods/cms/getEntry.js +15 -36
- package/methods/cms/getEntry.js.map +1 -1
- package/methods/cms/listEntries.js +22 -51
- package/methods/cms/listEntries.js.map +1 -1
- package/methods/cms/publishEntryRevision.js +14 -33
- package/methods/cms/publishEntryRevision.js.map +1 -1
- package/methods/cms/schemas.js +39 -35
- package/methods/cms/schemas.js.map +1 -1
- package/methods/cms/unpublishEntryRevision.js +14 -33
- package/methods/cms/unpublishEntryRevision.js.map +1 -1
- package/methods/cms/updateEntryRevision.js +15 -42
- package/methods/cms/updateEntryRevision.js.map +1 -1
- package/methods/executeGraphQL.js +38 -41
- package/methods/executeGraphQL.js.map +1 -1
- package/methods/fileManager/buildFieldsSelection.js +25 -67
- package/methods/fileManager/buildFieldsSelection.js.map +1 -1
- package/methods/fileManager/completeMultiPartUpload.js +12 -29
- package/methods/fileManager/completeMultiPartUpload.js.map +1 -1
- package/methods/fileManager/createFile.js +61 -125
- package/methods/fileManager/createFile.js.map +1 -1
- package/methods/fileManager/createFiles.js +41 -76
- package/methods/fileManager/createFiles.js.map +1 -1
- package/methods/fileManager/createMultiPartUpload.js +12 -29
- package/methods/fileManager/createMultiPartUpload.js.map +1 -1
- package/methods/fileManager/deleteFile.js +11 -26
- package/methods/fileManager/deleteFile.js.map +1 -1
- package/methods/fileManager/fileManagerTypes.js +19 -18
- package/methods/fileManager/fileManagerTypes.js.map +1 -1
- package/methods/fileManager/getFile.js +15 -30
- package/methods/fileManager/getFile.js.map +1 -1
- package/methods/fileManager/getPresignedPostPayload.js +17 -40
- package/methods/fileManager/getPresignedPostPayload.js.map +1 -1
- package/methods/fileManager/getPresignedPostPayloads.js +17 -32
- package/methods/fileManager/getPresignedPostPayloads.js.map +1 -1
- package/methods/fileManager/listFiles.js +22 -45
- package/methods/fileManager/listFiles.js.map +1 -1
- package/methods/fileManager/listTags.js +11 -25
- package/methods/fileManager/listTags.js.map +1 -1
- package/methods/fileManager/schemas.js +15 -14
- package/methods/fileManager/schemas.js.map +1 -1
- package/methods/fileManager/updateFile.js +12 -29
- package/methods/fileManager/updateFile.js.map +1 -1
- package/methods/fileManager/utils/fileTypeDetection.js +10 -12
- package/methods/fileManager/utils/fileTypeDetection.js.map +1 -1
- package/methods/fileManager/utils/uploadLargeFile.js +86 -165
- package/methods/fileManager/utils/uploadLargeFile.js.map +1 -1
- package/methods/fileManager/utils/uploadToS3.js +41 -94
- package/methods/fileManager/utils/uploadToS3.js.map +1 -1
- package/methods/languages/listLanguages.js +8 -11
- package/methods/languages/listLanguages.js.map +1 -1
- package/methods/tasks/abortTask.js +11 -17
- package/methods/tasks/abortTask.js.map +1 -1
- package/methods/tasks/listDefinitions.js +8 -11
- package/methods/tasks/listDefinitions.js.map +1 -1
- package/methods/tasks/listLogs.js +10 -15
- package/methods/tasks/listLogs.js.map +1 -1
- package/methods/tasks/listTasks.js +8 -11
- package/methods/tasks/listTasks.js.map +1 -1
- package/methods/tasks/schemas.js +11 -10
- package/methods/tasks/schemas.js.map +1 -1
- package/methods/tasks/taskTypes.js +0 -3
- package/methods/tasks/triggerTask.js +11 -17
- package/methods/tasks/triggerTask.js.map +1 -1
- package/methods/tenantManager/createTenant.js +10 -24
- package/methods/tenantManager/createTenant.js.map +1 -1
- package/methods/tenantManager/disableTenant.js +10 -24
- package/methods/tenantManager/disableTenant.js.map +1 -1
- package/methods/tenantManager/enableTenant.js +10 -24
- package/methods/tenantManager/enableTenant.js.map +1 -1
- package/methods/tenantManager/getCurrentTenant.js +8 -18
- package/methods/tenantManager/getCurrentTenant.js.map +1 -1
- package/methods/tenantManager/installTenant.js +10 -24
- package/methods/tenantManager/installTenant.js.map +1 -1
- package/methods/tenantManager/schemas.js +13 -12
- package/methods/tenantManager/schemas.js.map +1 -1
- package/methods/tenantManager/tenantManagerTypes.js +0 -3
- package/package.json +5 -5
- package/types.js +0 -3
- package/utils/createMethod.js +6 -24
- package/utils/createMethod.js.map +1 -1
- package/utils/platform.js +3 -2
- package/utils/platform.js.map +1 -1
- package/utils/transformFieldErrors.js +14 -33
- package/utils/transformFieldErrors.js.map +1 -1
- package/utils/validateParams.js +13 -16
- package/utils/validateParams.js.map +1 -1
- package/index.js.map +0 -1
- package/methods/cms/cmsTypes.js.map +0 -1
- package/methods/tasks/taskTypes.js.map +0 -1
- package/methods/tenantManager/tenantManagerTypes.js.map +0 -1
- package/types.js.map +0 -1
|
@@ -4,34 +4,8 @@ import { createMethod } from "../../utils/createMethod.js";
|
|
|
4
4
|
import { listEntriesSchema } from "./schemas.js";
|
|
5
5
|
import { executeGraphQL } from "../executeGraphQL.js";
|
|
6
6
|
import { ApiError } from "../../errors.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
* @template TValues - Type of the entry data objects. Users should specify this to include all fields they're requesting (id, entryId, values, createdOn, etc.)
|
|
11
|
-
* @param config - SDK configuration
|
|
12
|
-
* @param fetchFn - Fetch function to use for HTTP requests
|
|
13
|
-
* @param params - Parameters for listing entries
|
|
14
|
-
* @param params.modelId - The model ID of entries to list
|
|
15
|
-
* @param params.where - Optional where conditions to filter entries
|
|
16
|
-
* @param params.sort - Optional sort configuration
|
|
17
|
-
* @param params.limit - Maximum number of entries to return (default: 10)
|
|
18
|
-
* @param params.after - Cursor for pagination
|
|
19
|
-
* @param params.search - Optional full-text search term to filter entries across searchable fields (text, longText fields with fullTextSearch enabled)
|
|
20
|
-
* @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"
|
|
21
|
-
* @param params.preview - When true, uses preview API to access unpublished/draft content. When false (default), uses read API for published content only.
|
|
22
|
-
* @returns Result containing list of entries with pagination metadata or an error
|
|
23
|
-
*/
|
|
24
|
-
const _impl = createMethod(listEntriesSchema, async (config, fetchFn, {
|
|
25
|
-
modelId,
|
|
26
|
-
where,
|
|
27
|
-
sort,
|
|
28
|
-
limit = 10,
|
|
29
|
-
after,
|
|
30
|
-
search,
|
|
31
|
-
fields,
|
|
32
|
-
preview
|
|
33
|
-
}) => {
|
|
34
|
-
const query = `
|
|
7
|
+
const _impl = createMethod(listEntriesSchema, async (config, fetchFn, { modelId, where, sort, limit = 10, after, search, fields, preview })=>{
|
|
8
|
+
const query = `
|
|
35
9
|
query ListEntries(
|
|
36
10
|
$modelId: ID!
|
|
37
11
|
$where: JSON
|
|
@@ -67,30 +41,27 @@ const _impl = createMethod(listEntriesSchema, async (config, fetchFn, {
|
|
|
67
41
|
}
|
|
68
42
|
}
|
|
69
43
|
`;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return Result.ok({
|
|
88
|
-
data: responseData.cms.listEntries.data,
|
|
89
|
-
meta: responseData.cms.listEntries.meta
|
|
90
|
-
});
|
|
44
|
+
const result = await executeGraphQL(config, fetchFn, query, {
|
|
45
|
+
modelId,
|
|
46
|
+
where,
|
|
47
|
+
sort,
|
|
48
|
+
limit,
|
|
49
|
+
after,
|
|
50
|
+
search,
|
|
51
|
+
fields,
|
|
52
|
+
preview
|
|
53
|
+
});
|
|
54
|
+
if (result.isFail()) return Result.fail(result.error);
|
|
55
|
+
const responseData = result.value;
|
|
56
|
+
if (responseData.cms.listEntries.error) return Result.fail(new ApiError(transformFieldErrors(responseData.cms.listEntries.error.message, fields), responseData.cms.listEntries.error.code));
|
|
57
|
+
return Result.ok({
|
|
58
|
+
data: responseData.cms.listEntries.data,
|
|
59
|
+
meta: responseData.cms.listEntries.meta
|
|
60
|
+
});
|
|
91
61
|
});
|
|
92
|
-
|
|
93
|
-
|
|
62
|
+
function listEntries(config, fetchFn, params) {
|
|
63
|
+
return _impl(config, fetchFn, params);
|
|
94
64
|
}
|
|
65
|
+
export { listEntries };
|
|
95
66
|
|
|
96
67
|
//# sourceMappingURL=listEntries.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"methods/cms/listEntries.js","sources":["../../../src/methods/cms/listEntries.ts"],"sourcesContent":["import type { WebinyConfig } from \"../../types.js\";\nimport { Result } from \"../../Result.js\";\nimport type { HttpError, NetworkError, ValidationError } from \"../../errors.js\";\nimport type { CmsEntryValues, CmsEntryData } from \"./cmsTypes.js\";\nimport { transformFieldErrors } from \"../../utils/transformFieldErrors.js\";\nimport { createMethod } from \"../../utils/createMethod.js\";\nimport { listEntriesSchema } from \"./schemas.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.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 */\nconst _impl = createMethod(\n listEntriesSchema,\n async (\n config,\n fetchFn,\n { modelId, where, sort, limit = 10, after, search, fields, preview }\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 return Result.fail(\n new ApiError(\n transformFieldErrors(responseData.cms.listEntries.error.message, fields),\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);\n\nexport function listEntries<TValues extends CmsEntryValues = CmsEntryValues>(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: ListEntriesParams\n): Promise<\n Result<ListEntriesResult<TValues>, HttpError | ApiError | NetworkError | ValidationError>\n> {\n return _impl(config, fetchFn, params) as Promise<\n Result<ListEntriesResult<TValues>, HttpError | ApiError | NetworkError | ValidationError>\n >;\n}\n"],"names":["_impl","createMethod","listEntriesSchema","config","fetchFn","modelId","where","sort","limit","after","search","fields","preview","query","result","executeGraphQL","Result","responseData","ApiError","transformFieldErrors","listEntries","params"],"mappings":";;;;;;AA+CA,MAAMA,QAAQC,aACVC,mBACA,OACIC,QACAC,SACA,EAAEC,OAAO,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAE,EAAEC,KAAK,EAAEC,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE;IAEpE,MAAMC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAmCnB,CAAC;IAEG,MAAMC,SAAS,MAAMC,eAAeZ,QAAQC,SAASS,OAAO;QACxDR;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;IACJ;IAEA,IAAIE,OAAO,MAAM,IACb,OAAOE,OAAO,IAAI,CAACF,OAAO,KAAK;IAGnC,MAAMG,eAAeH,OAAO,KAAK;IAEjC,IAAIG,aAAa,GAAG,CAAC,WAAW,CAAC,KAAK,EAClC,OAAOD,OAAO,IAAI,CACd,IAAIE,SACAC,qBAAqBF,aAAa,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,EAAEN,SACjEM,aAAa,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI;IAKnD,OAAOD,OAAO,EAAE,CAAC;QACb,MAAMC,aAAa,GAAG,CAAC,WAAW,CAAC,IAAI;QACvC,MAAMA,aAAa,GAAG,CAAC,WAAW,CAAC,IAAI;IAC3C;AACJ;AAGG,SAASG,YACZjB,MAAoB,EACpBC,OAAqB,EACrBiB,MAAyB;IAIzB,OAAOrB,MAAMG,QAAQC,SAASiB;AAGlC"}
|
|
@@ -4,24 +4,8 @@ import { createMethod } from "../../utils/createMethod.js";
|
|
|
4
4
|
import { publishEntryRevisionSchema } from "./schemas.js";
|
|
5
5
|
import { executeGraphQL } from "../executeGraphQL.js";
|
|
6
6
|
import { ApiError } from "../../errors.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
* @template TValues - Type of the entry values object
|
|
11
|
-
* @param config - SDK configuration
|
|
12
|
-
* @param fetchFn - Fetch function to use for HTTP requests
|
|
13
|
-
* @param params - Parameters for publishing the entry revision
|
|
14
|
-
* @param params.modelId - The model ID of the entry to publish
|
|
15
|
-
* @param params.revisionId - The revision ID of the entry to publish (e.g., "123#0001")
|
|
16
|
-
* @param params.fields - Fields to include in response
|
|
17
|
-
* @returns Result containing the published entry data or an error
|
|
18
|
-
*/
|
|
19
|
-
const _impl = createMethod(publishEntryRevisionSchema, async (config, fetchFn, {
|
|
20
|
-
modelId,
|
|
21
|
-
revisionId,
|
|
22
|
-
fields
|
|
23
|
-
}) => {
|
|
24
|
-
const query = `
|
|
7
|
+
const _impl = createMethod(publishEntryRevisionSchema, async (config, fetchFn, { modelId, revisionId, fields })=>{
|
|
8
|
+
const query = `
|
|
25
9
|
mutation PublishEntryRevision($modelId: ID!, $revisionId: ID!, $fields: [String!]!) {
|
|
26
10
|
cms {
|
|
27
11
|
publishEntryRevision(modelId: $modelId, revisionId: $revisionId, fields: $fields) {
|
|
@@ -34,22 +18,19 @@ const _impl = createMethod(publishEntryRevisionSchema, async (config, fetchFn, {
|
|
|
34
18
|
}
|
|
35
19
|
}
|
|
36
20
|
`;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (responseData.cms.publishEntryRevision.error) {
|
|
47
|
-
return Result.fail(new ApiError(transformFieldErrors(responseData.cms.publishEntryRevision.error.message, fields), responseData.cms.publishEntryRevision.error.code));
|
|
48
|
-
}
|
|
49
|
-
return Result.ok(responseData.cms.publishEntryRevision.data);
|
|
21
|
+
const result = await executeGraphQL(config, fetchFn, query, {
|
|
22
|
+
modelId,
|
|
23
|
+
revisionId,
|
|
24
|
+
fields
|
|
25
|
+
});
|
|
26
|
+
if (result.isFail()) return Result.fail(result.error);
|
|
27
|
+
const responseData = result.value;
|
|
28
|
+
if (responseData.cms.publishEntryRevision.error) return Result.fail(new ApiError(transformFieldErrors(responseData.cms.publishEntryRevision.error.message, fields), responseData.cms.publishEntryRevision.error.code));
|
|
29
|
+
return Result.ok(responseData.cms.publishEntryRevision.data);
|
|
50
30
|
});
|
|
51
|
-
|
|
52
|
-
|
|
31
|
+
function publishEntryRevision(config, fetchFn, params) {
|
|
32
|
+
return _impl(config, fetchFn, params);
|
|
53
33
|
}
|
|
34
|
+
export { publishEntryRevision };
|
|
54
35
|
|
|
55
36
|
//# sourceMappingURL=publishEntryRevision.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"methods/cms/publishEntryRevision.js","sources":["../../../src/methods/cms/publishEntryRevision.ts"],"sourcesContent":["import type { WebinyConfig } from \"../../types.js\";\nimport { Result } from \"../../Result.js\";\nimport type { HttpError, NetworkError, ValidationError } from \"../../errors.js\";\nimport type { CmsEntryValues, CmsEntryData } from \"./cmsTypes.js\";\nimport { transformFieldErrors } from \"../../utils/transformFieldErrors.js\";\nimport { createMethod } from \"../../utils/createMethod.js\";\nimport { publishEntryRevisionSchema } from \"./schemas.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.js\";\n\nexport interface PublishEntryRevisionParams {\n modelId: string;\n revisionId: string;\n fields: string[];\n}\n\n/**\n * Publishes an entry revision in the CMS.\n *\n * @template TValues - Type of the entry values object\n * @param config - SDK configuration\n * @param fetchFn - Fetch function to use for HTTP requests\n * @param params - Parameters for publishing the entry revision\n * @param params.modelId - The model ID of the entry to publish\n * @param params.revisionId - The revision ID of the entry to publish (e.g., \"123#0001\")\n * @param params.fields - Fields to include in response\n * @returns Result containing the published entry data or an error\n */\nconst _impl = createMethod(\n publishEntryRevisionSchema,\n async (config, fetchFn, { modelId, revisionId, fields }) => {\n const query = `\n mutation PublishEntryRevision($modelId: ID!, $revisionId: ID!, $fields: [String!]!) {\n cms {\n publishEntryRevision(modelId: $modelId, revisionId: $revisionId, fields: $fields) {\n data\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, {\n modelId,\n revisionId,\n fields\n });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.cms.publishEntryRevision.error) {\n return Result.fail(\n new ApiError(\n transformFieldErrors(\n responseData.cms.publishEntryRevision.error.message,\n fields\n ),\n responseData.cms.publishEntryRevision.error.code\n )\n );\n }\n\n return Result.ok(responseData.cms.publishEntryRevision.data);\n }\n);\n\nexport function publishEntryRevision<TValues extends CmsEntryValues = CmsEntryValues>(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: PublishEntryRevisionParams\n): Promise<Result<CmsEntryData<TValues>, HttpError | ApiError | NetworkError | ValidationError>> {\n return _impl(config, fetchFn, params) as Promise<\n Result<CmsEntryData<TValues>, HttpError | ApiError | NetworkError | ValidationError>\n >;\n}\n"],"names":["_impl","createMethod","publishEntryRevisionSchema","config","fetchFn","modelId","revisionId","fields","query","result","executeGraphQL","Result","responseData","ApiError","transformFieldErrors","publishEntryRevision","params"],"mappings":";;;;;;AA4BA,MAAMA,QAAQC,aACVC,4BACA,OAAOC,QAAQC,SAAS,EAAEC,OAAO,EAAEC,UAAU,EAAEC,MAAM,EAAE;IACnD,MAAMC,QAAQ,CAAC;;;;;;;;;;;;IAYnB,CAAC;IAEG,MAAMC,SAAS,MAAMC,eAAeP,QAAQC,SAASI,OAAO;QACxDH;QACAC;QACAC;IACJ;IAEA,IAAIE,OAAO,MAAM,IACb,OAAOE,OAAO,IAAI,CAACF,OAAO,KAAK;IAGnC,MAAMG,eAAeH,OAAO,KAAK;IAEjC,IAAIG,aAAa,GAAG,CAAC,oBAAoB,CAAC,KAAK,EAC3C,OAAOD,OAAO,IAAI,CACd,IAAIE,SACAC,qBACIF,aAAa,GAAG,CAAC,oBAAoB,CAAC,KAAK,CAAC,OAAO,EACnDL,SAEJK,aAAa,GAAG,CAAC,oBAAoB,CAAC,KAAK,CAAC,IAAI;IAK5D,OAAOD,OAAO,EAAE,CAACC,aAAa,GAAG,CAAC,oBAAoB,CAAC,IAAI;AAC/D;AAGG,SAASG,qBACZZ,MAAoB,EACpBC,OAAqB,EACrBY,MAAkC;IAElC,OAAOhB,MAAMG,QAAQC,SAASY;AAGlC"}
|
package/methods/cms/schemas.js
CHANGED
|
@@ -4,47 +4,51 @@ const revisionId = z.string().min(1, "revisionId is required");
|
|
|
4
4
|
const fields = z.array(z.string().min(1)).min(1, "fields must contain at least one entry");
|
|
5
5
|
const where = z.record(z.string(), z.unknown()).optional();
|
|
6
6
|
const preview = z.boolean().optional();
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
const listEntriesSchema = z.object({
|
|
8
|
+
modelId: modelId,
|
|
9
|
+
where: where,
|
|
10
|
+
sort: z.record(z.string(), z.union([
|
|
11
|
+
z.literal("asc"),
|
|
12
|
+
z.literal("desc")
|
|
13
|
+
])).optional(),
|
|
14
|
+
limit: z.number().int().positive().optional(),
|
|
15
|
+
after: z.string().optional(),
|
|
16
|
+
search: z.string().optional(),
|
|
17
|
+
fields: fields,
|
|
18
|
+
preview: preview
|
|
16
19
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
const getEntrySchema = z.object({
|
|
21
|
+
modelId: modelId,
|
|
22
|
+
where: z.record(z.string(), z.unknown()),
|
|
23
|
+
fields: fields,
|
|
24
|
+
preview: preview
|
|
22
25
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
const createEntrySchema = z.object({
|
|
27
|
+
modelId: modelId,
|
|
28
|
+
data: z.record(z.string(), z.unknown()),
|
|
29
|
+
fields: fields
|
|
27
30
|
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
const updateEntryRevisionSchema = z.object({
|
|
32
|
+
modelId: modelId,
|
|
33
|
+
revisionId: revisionId,
|
|
34
|
+
data: z.record(z.string(), z.unknown()),
|
|
35
|
+
fields: fields
|
|
33
36
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
const publishEntryRevisionSchema = z.object({
|
|
38
|
+
modelId: modelId,
|
|
39
|
+
revisionId: revisionId,
|
|
40
|
+
fields: fields
|
|
38
41
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
const unpublishEntryRevisionSchema = z.object({
|
|
43
|
+
modelId: modelId,
|
|
44
|
+
revisionId: revisionId,
|
|
45
|
+
fields: fields
|
|
43
46
|
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
const deleteEntryRevisionSchema = z.object({
|
|
48
|
+
modelId: modelId,
|
|
49
|
+
revisionId: revisionId,
|
|
50
|
+
permanent: z.boolean().optional()
|
|
48
51
|
});
|
|
52
|
+
export { createEntrySchema, deleteEntryRevisionSchema, getEntrySchema, listEntriesSchema, publishEntryRevisionSchema, unpublishEntryRevisionSchema, updateEntryRevisionSchema };
|
|
49
53
|
|
|
50
54
|
//# sourceMappingURL=schemas.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"methods/cms/schemas.js","sources":["../../../src/methods/cms/schemas.ts"],"sourcesContent":["import { z } from \"zod\";\n\nconst modelId = z.string().min(1, \"modelId is required\");\nconst revisionId = z.string().min(1, \"revisionId is required\");\nconst fields = z.array(z.string().min(1)).min(1, \"fields must contain at least one entry\");\nconst where = z.record(z.string(), z.unknown()).optional();\nconst preview = z.boolean().optional();\n\nexport const listEntriesSchema = z.object({\n modelId,\n where,\n sort: z.record(z.string(), z.union([z.literal(\"asc\"), z.literal(\"desc\")])).optional(),\n limit: z.number().int().positive().optional(),\n after: z.string().optional(),\n search: z.string().optional(),\n fields,\n preview\n});\n\nexport const getEntrySchema = z.object({\n modelId,\n where: z.record(z.string(), z.unknown()),\n fields,\n preview\n});\n\nexport const createEntrySchema = z.object({\n modelId,\n data: z.record(z.string(), z.unknown()),\n fields\n});\n\nexport const updateEntryRevisionSchema = z.object({\n modelId,\n revisionId,\n data: z.record(z.string(), z.unknown()),\n fields\n});\n\nexport const publishEntryRevisionSchema = z.object({\n modelId,\n revisionId,\n fields\n});\n\nexport const unpublishEntryRevisionSchema = z.object({\n modelId,\n revisionId,\n fields\n});\n\nexport const deleteEntryRevisionSchema = z.object({\n modelId,\n revisionId,\n permanent: z.boolean().optional()\n});\n"],"names":["modelId","z","revisionId","fields","where","preview","listEntriesSchema","getEntrySchema","createEntrySchema","updateEntryRevisionSchema","publishEntryRevisionSchema","unpublishEntryRevisionSchema","deleteEntryRevisionSchema"],"mappings":";AAEA,MAAMA,UAAUC,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG;AAClC,MAAMC,aAAaD,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG;AACrC,MAAME,SAASF,EAAE,KAAK,CAACA,EAAE,MAAM,GAAG,GAAG,CAAC,IAAI,GAAG,CAAC,GAAG;AACjD,MAAMG,QAAQH,EAAE,MAAM,CAACA,EAAE,MAAM,IAAIA,EAAE,OAAO,IAAI,QAAQ;AACxD,MAAMI,UAAUJ,EAAE,OAAO,GAAG,QAAQ;AAE7B,MAAMK,oBAAoBL,EAAE,MAAM,CAAC;IACtCD,SAAAA;IACAI,OAAAA;IACA,MAAMH,EAAE,MAAM,CAACA,EAAE,MAAM,IAAIA,EAAE,KAAK,CAAC;QAACA,EAAE,OAAO,CAAC;QAAQA,EAAE,OAAO,CAAC;KAAQ,GAAG,QAAQ;IACnF,OAAOA,EAAE,MAAM,GAAG,GAAG,GAAG,QAAQ,GAAG,QAAQ;IAC3C,OAAOA,EAAE,MAAM,GAAG,QAAQ;IAC1B,QAAQA,EAAE,MAAM,GAAG,QAAQ;IAC3BE,QAAAA;IACAE,SAAAA;AACJ;AAEO,MAAME,iBAAiBN,EAAE,MAAM,CAAC;IACnCD,SAAAA;IACA,OAAOC,EAAE,MAAM,CAACA,EAAE,MAAM,IAAIA,EAAE,OAAO;IACrCE,QAAAA;IACAE,SAAAA;AACJ;AAEO,MAAMG,oBAAoBP,EAAE,MAAM,CAAC;IACtCD,SAAAA;IACA,MAAMC,EAAE,MAAM,CAACA,EAAE,MAAM,IAAIA,EAAE,OAAO;IACpCE,QAAAA;AACJ;AAEO,MAAMM,4BAA4BR,EAAE,MAAM,CAAC;IAC9CD,SAAAA;IACAE,YAAAA;IACA,MAAMD,EAAE,MAAM,CAACA,EAAE,MAAM,IAAIA,EAAE,OAAO;IACpCE,QAAAA;AACJ;AAEO,MAAMO,6BAA6BT,EAAE,MAAM,CAAC;IAC/CD,SAAAA;IACAE,YAAAA;IACAC,QAAAA;AACJ;AAEO,MAAMQ,+BAA+BV,EAAE,MAAM,CAAC;IACjDD,SAAAA;IACAE,YAAAA;IACAC,QAAAA;AACJ;AAEO,MAAMS,4BAA4BX,EAAE,MAAM,CAAC;IAC9CD,SAAAA;IACAE,YAAAA;IACA,WAAWD,EAAE,OAAO,GAAG,QAAQ;AACnC"}
|
|
@@ -4,24 +4,8 @@ import { createMethod } from "../../utils/createMethod.js";
|
|
|
4
4
|
import { unpublishEntryRevisionSchema } from "./schemas.js";
|
|
5
5
|
import { executeGraphQL } from "../executeGraphQL.js";
|
|
6
6
|
import { ApiError } from "../../errors.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
* @template TValues - Type of the entry values object
|
|
11
|
-
* @param config - SDK configuration
|
|
12
|
-
* @param fetchFn - Fetch function to use for HTTP requests
|
|
13
|
-
* @param params - Parameters for unpublishing the entry revision
|
|
14
|
-
* @param params.modelId - The model ID of the entry to unpublish
|
|
15
|
-
* @param params.revisionId - The revision ID of the entry to unpublish (e.g., "123#0001")
|
|
16
|
-
* @param params.fields - Fields to include in response
|
|
17
|
-
* @returns Result containing the unpublished entry data or an error
|
|
18
|
-
*/
|
|
19
|
-
const _impl = createMethod(unpublishEntryRevisionSchema, async (config, fetchFn, {
|
|
20
|
-
modelId,
|
|
21
|
-
revisionId,
|
|
22
|
-
fields
|
|
23
|
-
}) => {
|
|
24
|
-
const query = `
|
|
7
|
+
const _impl = createMethod(unpublishEntryRevisionSchema, async (config, fetchFn, { modelId, revisionId, fields })=>{
|
|
8
|
+
const query = `
|
|
25
9
|
mutation UnpublishEntryRevision($modelId: ID!, $revisionId: ID!, $fields: [String!]!) {
|
|
26
10
|
cms {
|
|
27
11
|
unpublishEntryRevision(modelId: $modelId, revisionId: $revisionId, fields: $fields) {
|
|
@@ -34,22 +18,19 @@ const _impl = createMethod(unpublishEntryRevisionSchema, async (config, fetchFn,
|
|
|
34
18
|
}
|
|
35
19
|
}
|
|
36
20
|
`;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (data.cms.unpublishEntryRevision.error) {
|
|
47
|
-
return Result.fail(new ApiError(transformFieldErrors(data.cms.unpublishEntryRevision.error.message, fields), data.cms.unpublishEntryRevision.error.code));
|
|
48
|
-
}
|
|
49
|
-
return Result.ok(data.cms.unpublishEntryRevision.data);
|
|
21
|
+
const result = await executeGraphQL(config, fetchFn, query, {
|
|
22
|
+
modelId,
|
|
23
|
+
revisionId,
|
|
24
|
+
fields
|
|
25
|
+
});
|
|
26
|
+
if (result.isFail()) return result;
|
|
27
|
+
const data = result.value;
|
|
28
|
+
if (data.cms.unpublishEntryRevision.error) return Result.fail(new ApiError(transformFieldErrors(data.cms.unpublishEntryRevision.error.message, fields), data.cms.unpublishEntryRevision.error.code));
|
|
29
|
+
return Result.ok(data.cms.unpublishEntryRevision.data);
|
|
50
30
|
});
|
|
51
|
-
|
|
52
|
-
|
|
31
|
+
function unpublishEntryRevision(config, fetchFn, params) {
|
|
32
|
+
return _impl(config, fetchFn, params);
|
|
53
33
|
}
|
|
34
|
+
export { unpublishEntryRevision };
|
|
54
35
|
|
|
55
36
|
//# sourceMappingURL=unpublishEntryRevision.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"methods/cms/unpublishEntryRevision.js","sources":["../../../src/methods/cms/unpublishEntryRevision.ts"],"sourcesContent":["import type { WebinyConfig } from \"../../types.js\";\nimport { Result } from \"../../Result.js\";\nimport type { HttpError, NetworkError, ValidationError } from \"../../errors.js\";\nimport type { CmsEntryValues, CmsEntryData } from \"./cmsTypes.js\";\nimport { transformFieldErrors } from \"../../utils/transformFieldErrors.js\";\nimport { createMethod } from \"../../utils/createMethod.js\";\nimport { unpublishEntryRevisionSchema } from \"./schemas.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.js\";\n\nexport interface UnpublishEntryRevisionParams {\n modelId: string;\n revisionId: string;\n fields: string[];\n}\n\n/**\n * Unpublishes an entry revision in the CMS.\n *\n * @template TValues - Type of the entry values object\n * @param config - SDK configuration\n * @param fetchFn - Fetch function to use for HTTP requests\n * @param params - Parameters for unpublishing the entry revision\n * @param params.modelId - The model ID of the entry to unpublish\n * @param params.revisionId - The revision ID of the entry to unpublish (e.g., \"123#0001\")\n * @param params.fields - Fields to include in response\n * @returns Result containing the unpublished entry data or an error\n */\nconst _impl = createMethod(\n unpublishEntryRevisionSchema,\n async (config, fetchFn, { modelId, revisionId, fields }) => {\n const query = `\n mutation UnpublishEntryRevision($modelId: ID!, $revisionId: ID!, $fields: [String!]!) {\n cms {\n unpublishEntryRevision(modelId: $modelId, revisionId: $revisionId, fields: $fields) {\n data\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, {\n modelId,\n revisionId,\n fields\n });\n\n if (result.isFail()) {\n return result;\n }\n\n const data = result.value;\n\n if (data.cms.unpublishEntryRevision.error) {\n return Result.fail(\n new ApiError(\n transformFieldErrors(data.cms.unpublishEntryRevision.error.message, fields),\n data.cms.unpublishEntryRevision.error.code\n )\n );\n }\n\n return Result.ok(data.cms.unpublishEntryRevision.data);\n }\n);\n\nexport function unpublishEntryRevision<TValues extends CmsEntryValues = CmsEntryValues>(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: UnpublishEntryRevisionParams\n): Promise<Result<CmsEntryData<TValues>, HttpError | ApiError | NetworkError | ValidationError>> {\n return _impl(config, fetchFn, params) as Promise<\n Result<CmsEntryData<TValues>, HttpError | ApiError | NetworkError | ValidationError>\n >;\n}\n"],"names":["_impl","createMethod","unpublishEntryRevisionSchema","config","fetchFn","modelId","revisionId","fields","query","result","executeGraphQL","data","Result","ApiError","transformFieldErrors","unpublishEntryRevision","params"],"mappings":";;;;;;AA4BA,MAAMA,QAAQC,aACVC,8BACA,OAAOC,QAAQC,SAAS,EAAEC,OAAO,EAAEC,UAAU,EAAEC,MAAM,EAAE;IACnD,MAAMC,QAAQ,CAAC;;;;;;;;;;;;IAYnB,CAAC;IAEG,MAAMC,SAAS,MAAMC,eAAeP,QAAQC,SAASI,OAAO;QACxDH;QACAC;QACAC;IACJ;IAEA,IAAIE,OAAO,MAAM,IACb,OAAOA;IAGX,MAAME,OAAOF,OAAO,KAAK;IAEzB,IAAIE,KAAK,GAAG,CAAC,sBAAsB,CAAC,KAAK,EACrC,OAAOC,OAAO,IAAI,CACd,IAAIC,SACAC,qBAAqBH,KAAK,GAAG,CAAC,sBAAsB,CAAC,KAAK,CAAC,OAAO,EAAEJ,SACpEI,KAAK,GAAG,CAAC,sBAAsB,CAAC,KAAK,CAAC,IAAI;IAKtD,OAAOC,OAAO,EAAE,CAACD,KAAK,GAAG,CAAC,sBAAsB,CAAC,IAAI;AACzD;AAGG,SAASI,uBACZZ,MAAoB,EACpBC,OAAqB,EACrBY,MAAoC;IAEpC,OAAOhB,MAAMG,QAAQC,SAASY;AAGlC"}
|
|
@@ -4,32 +4,8 @@ import { createMethod } from "../../utils/createMethod.js";
|
|
|
4
4
|
import { updateEntryRevisionSchema } from "./schemas.js";
|
|
5
5
|
import { executeGraphQL } from "../executeGraphQL.js";
|
|
6
6
|
import { ApiError } from "../../errors.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* Update entry revision data.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**1`
|
|
13
|
-
* Updates an existing entry revision in the CMS.
|
|
14
|
-
*
|
|
15
|
-
* @template TValues - Type of the entry data object returned (typically contains id and entryId, or additional fields if specified)
|
|
16
|
-
* @param config - SDK configuration
|
|
17
|
-
* @param fetchFn - Fetch function to use for HTTP requests
|
|
18
|
-
* @param params - Parameters for updating the entry revision
|
|
19
|
-
* @param params.modelId - The model ID for the entry
|
|
20
|
-
* @param params.revisionId - The revision ID of the entry to update (e.g., "123#0001")
|
|
21
|
-
* @param params.data - The updated entry data
|
|
22
|
-
* @param params.fields - Fields to include in the response. Use "values." prefix for entry values (e.g., "values.author.name") or specify top-level fields like "createdOn"
|
|
23
|
-
* @returns Result containing the updated entry data or an error
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
const _impl = createMethod(updateEntryRevisionSchema, async (config, fetchFn, {
|
|
27
|
-
modelId,
|
|
28
|
-
revisionId,
|
|
29
|
-
data,
|
|
30
|
-
fields
|
|
31
|
-
}) => {
|
|
32
|
-
const query = `
|
|
7
|
+
const _impl = createMethod(updateEntryRevisionSchema, async (config, fetchFn, { modelId, revisionId, data, fields })=>{
|
|
8
|
+
const query = `
|
|
33
9
|
mutation UpdateEntryRevision($modelId: ID!, $revisionId: ID!, $data: JSON!, $fields: [String!]!) {
|
|
34
10
|
cms {
|
|
35
11
|
updateEntryRevision(modelId: $modelId, revisionId: $revisionId, data: $data, fields: $fields) {
|
|
@@ -42,23 +18,20 @@ const _impl = createMethod(updateEntryRevisionSchema, async (config, fetchFn, {
|
|
|
42
18
|
}
|
|
43
19
|
}
|
|
44
20
|
`;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (responseData.cms.updateEntryRevision.error) {
|
|
56
|
-
return Result.fail(new ApiError(transformFieldErrors(responseData.cms.updateEntryRevision.error.message, fields), responseData.cms.updateEntryRevision.error.code));
|
|
57
|
-
}
|
|
58
|
-
return Result.ok(responseData.cms.updateEntryRevision.data);
|
|
21
|
+
const result = await executeGraphQL(config, fetchFn, query, {
|
|
22
|
+
modelId,
|
|
23
|
+
revisionId,
|
|
24
|
+
data,
|
|
25
|
+
fields
|
|
26
|
+
});
|
|
27
|
+
if (result.isFail()) return Result.fail(result.error);
|
|
28
|
+
const responseData = result.value;
|
|
29
|
+
if (responseData.cms.updateEntryRevision.error) return Result.fail(new ApiError(transformFieldErrors(responseData.cms.updateEntryRevision.error.message, fields), responseData.cms.updateEntryRevision.error.code));
|
|
30
|
+
return Result.ok(responseData.cms.updateEntryRevision.data);
|
|
59
31
|
});
|
|
60
|
-
|
|
61
|
-
|
|
32
|
+
function updateEntryRevision(config, fetchFn, params) {
|
|
33
|
+
return _impl(config, fetchFn, params);
|
|
62
34
|
}
|
|
35
|
+
export { updateEntryRevision };
|
|
63
36
|
|
|
64
37
|
//# sourceMappingURL=updateEntryRevision.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"methods/cms/updateEntryRevision.js","sources":["../../../src/methods/cms/updateEntryRevision.ts"],"sourcesContent":["import type { WebinyConfig } from \"../../types.js\";\nimport { Result } from \"../../Result.js\";\nimport type { HttpError, NetworkError, ValidationError } from \"../../errors.js\";\nimport type { CmsEntryValues, CmsIdentity } from \"./cmsTypes.js\";\nimport { transformFieldErrors } from \"../../utils/transformFieldErrors.js\";\nimport { createMethod } from \"../../utils/createMethod.js\";\nimport { updateEntryRevisionSchema } from \"./schemas.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.js\";\n\n/**\n * Update entry revision data.\n */\nexport interface UpdateCmsEntryData<TValues extends CmsEntryValues = CmsEntryValues> {\n /**\n * Revision-level meta fields.\n */\n revisionCreatedOn?: Date | string | null;\n revisionModifiedOn?: Date | string | null;\n revisionSavedOn?: Date | string | null;\n revisionDeletedOn?: Date | string | null;\n revisionRestoredOn?: Date | string | null;\n revisionFirstPublishedOn?: Date | string | null;\n revisionLastPublishedOn?: Date | string | null;\n revisionModifiedBy?: CmsIdentity | null;\n revisionCreatedBy?: CmsIdentity | null;\n revisionSavedBy?: CmsIdentity | null;\n revisionDeletedBy?: CmsIdentity | null;\n revisionRestoredBy?: CmsIdentity | null;\n revisionFirstPublishedBy?: CmsIdentity | null;\n revisionLastPublishedBy?: CmsIdentity | null;\n\n /**\n * Entry-level meta fields.\n */\n createdOn?: Date | string | null;\n modifiedOn?: Date | string | null;\n savedOn?: Date | string | null;\n deletedOn?: Date | string | null;\n restoredOn?: Date | string | null;\n firstPublishedOn?: Date | string | null;\n lastPublishedOn?: Date | string | null;\n createdBy?: CmsIdentity | null;\n modifiedBy?: CmsIdentity | null;\n savedBy?: CmsIdentity | null;\n deletedBy?: CmsIdentity | null;\n restoredBy?: CmsIdentity | null;\n firstPublishedBy?: CmsIdentity | null;\n lastPublishedBy?: CmsIdentity | null;\n\n location?: {\n folderId?: string | null;\n };\n\n values?: Partial<TValues>;\n}\n\nexport interface UpdateEntryRevisionParams<TValues extends CmsEntryValues = CmsEntryValues> {\n modelId: string;\n revisionId: string;\n data: UpdateCmsEntryData<TValues>;\n fields: string[];\n}\n\n/**1`\n * Updates an existing entry revision in the CMS.\n *\n * @template TValues - Type of the entry data object returned (typically contains id and entryId, or additional fields if specified)\n * @param config - SDK configuration\n * @param fetchFn - Fetch function to use for HTTP requests\n * @param params - Parameters for updating the entry revision\n * @param params.modelId - The model ID for the entry\n * @param params.revisionId - The revision ID of the entry to update (e.g., \"123#0001\")\n * @param params.data - The updated entry data\n * @param params.fields - Fields to include in the response. Use \"values.\" prefix for entry values (e.g., \"values.author.name\") or specify top-level fields like \"createdOn\"\n * @returns Result containing the updated entry data or an error\n */\n\nconst _impl = createMethod(\n updateEntryRevisionSchema,\n async (config, fetchFn, { modelId, revisionId, data, fields }) => {\n const query = `\n mutation UpdateEntryRevision($modelId: ID!, $revisionId: ID!, $data: JSON!, $fields: [String!]!) {\n cms {\n updateEntryRevision(modelId: $modelId, revisionId: $revisionId, data: $data, fields: $fields) {\n data\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, {\n modelId,\n revisionId,\n data,\n fields\n });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.cms.updateEntryRevision.error) {\n return Result.fail(\n new ApiError(\n transformFieldErrors(\n responseData.cms.updateEntryRevision.error.message,\n fields\n ),\n responseData.cms.updateEntryRevision.error.code\n )\n );\n }\n\n return Result.ok(responseData.cms.updateEntryRevision.data);\n }\n);\n\nexport function updateEntryRevision<TValues extends CmsEntryValues = CmsEntryValues>(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: UpdateEntryRevisionParams<TValues>\n): Promise<\n Result<UpdateCmsEntryData<TValues>, HttpError | ApiError | NetworkError | ValidationError>\n> {\n return _impl(config, fetchFn, params) as Promise<\n Result<UpdateCmsEntryData<TValues>, HttpError | ApiError | NetworkError | ValidationError>\n >;\n}\n"],"names":["_impl","createMethod","updateEntryRevisionSchema","config","fetchFn","modelId","revisionId","data","fields","query","result","executeGraphQL","Result","responseData","ApiError","transformFieldErrors","updateEntryRevision","params"],"mappings":";;;;;;AA8EA,MAAMA,QAAQC,aACVC,2BACA,OAAOC,QAAQC,SAAS,EAAEC,OAAO,EAAEC,UAAU,EAAEC,IAAI,EAAEC,MAAM,EAAE;IACzD,MAAMC,QAAQ,CAAC;;;;;;;;;;;;IAYnB,CAAC;IAEG,MAAMC,SAAS,MAAMC,eAAeR,QAAQC,SAASK,OAAO;QACxDJ;QACAC;QACAC;QACAC;IACJ;IAEA,IAAIE,OAAO,MAAM,IACb,OAAOE,OAAO,IAAI,CAACF,OAAO,KAAK;IAGnC,MAAMG,eAAeH,OAAO,KAAK;IAEjC,IAAIG,aAAa,GAAG,CAAC,mBAAmB,CAAC,KAAK,EAC1C,OAAOD,OAAO,IAAI,CACd,IAAIE,SACAC,qBACIF,aAAa,GAAG,CAAC,mBAAmB,CAAC,KAAK,CAAC,OAAO,EAClDL,SAEJK,aAAa,GAAG,CAAC,mBAAmB,CAAC,KAAK,CAAC,IAAI;IAK3D,OAAOD,OAAO,EAAE,CAACC,aAAa,GAAG,CAAC,mBAAmB,CAAC,IAAI;AAC9D;AAGG,SAASG,oBACZb,MAAoB,EACpBC,OAAqB,EACrBa,MAA0C;IAI1C,OAAOjB,MAAMG,QAAQC,SAASa;AAGlC"}
|
|
@@ -1,46 +1,43 @@
|
|
|
1
1
|
import { Result } from "../Result.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
2
|
+
import { ApiError, HttpError, NetworkError } from "../errors.js";
|
|
3
|
+
async function executeGraphQL(config, fetchFn, query, variables = {}) {
|
|
4
|
+
const url = `${config.endpoint}/graphql`;
|
|
5
|
+
let response;
|
|
6
|
+
try {
|
|
7
|
+
const body = JSON.stringify({
|
|
8
|
+
query,
|
|
9
|
+
variables
|
|
10
|
+
});
|
|
11
|
+
const headers = {
|
|
12
|
+
"Content-Type": "application/json",
|
|
13
|
+
"x-tenant": config.tenant ?? "root",
|
|
14
|
+
...config.headers
|
|
15
|
+
};
|
|
16
|
+
if (config.token && !headers.Authorization) {
|
|
17
|
+
const token = "function" == typeof config.token ? await config.token() : config.token;
|
|
18
|
+
headers.Authorization = `Bearer ${token}`;
|
|
19
|
+
}
|
|
20
|
+
response = await fetchFn(url, {
|
|
21
|
+
method: "POST",
|
|
22
|
+
headers,
|
|
23
|
+
body
|
|
24
|
+
});
|
|
25
|
+
} catch (error) {
|
|
26
|
+
return Result.fail(new NetworkError(error instanceof Error ? error.message : "Network request failed"));
|
|
27
|
+
}
|
|
28
|
+
if (!response.ok) return Result.fail(new HttpError(response.status, `HTTP error! status: ${response.status}`));
|
|
29
|
+
let result;
|
|
30
|
+
try {
|
|
31
|
+
result = await response.json();
|
|
32
|
+
} catch {
|
|
33
|
+
return Result.fail(new NetworkError("Failed to parse response JSON"));
|
|
34
|
+
}
|
|
35
|
+
if (result.errors) {
|
|
36
|
+
const error = result.errors[0];
|
|
37
|
+
return Result.fail(new ApiError(error?.message || "GraphQL error", error?.code));
|
|
21
38
|
}
|
|
22
|
-
|
|
23
|
-
method: "POST",
|
|
24
|
-
headers,
|
|
25
|
-
body
|
|
26
|
-
});
|
|
27
|
-
} catch (error) {
|
|
28
|
-
return Result.fail(new NetworkError(error instanceof Error ? error.message : "Network request failed"));
|
|
29
|
-
}
|
|
30
|
-
if (!response.ok) {
|
|
31
|
-
return Result.fail(new HttpError(response.status, `HTTP error! status: ${response.status}`));
|
|
32
|
-
}
|
|
33
|
-
let result;
|
|
34
|
-
try {
|
|
35
|
-
result = await response.json();
|
|
36
|
-
} catch {
|
|
37
|
-
return Result.fail(new NetworkError("Failed to parse response JSON"));
|
|
38
|
-
}
|
|
39
|
-
if (result.errors) {
|
|
40
|
-
const error = result.errors[0];
|
|
41
|
-
return Result.fail(new ApiError(error?.message || "GraphQL error", error?.code));
|
|
42
|
-
}
|
|
43
|
-
return Result.ok(result.data);
|
|
39
|
+
return Result.ok(result.data);
|
|
44
40
|
}
|
|
41
|
+
export { executeGraphQL };
|
|
45
42
|
|
|
46
43
|
//# sourceMappingURL=executeGraphQL.js.map
|