@webiny/sdk 0.0.0-unstable.dbdf5d6258

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.
Files changed (51) hide show
  1. package/BaseError.d.ts +17 -0
  2. package/BaseError.js +10 -0
  3. package/BaseError.js.map +1 -0
  4. package/CmsSdk.d.ts +23 -0
  5. package/CmsSdk.js +36 -0
  6. package/CmsSdk.js.map +1 -0
  7. package/LICENSE +21 -0
  8. package/README.md +11 -0
  9. package/Result.d.ts +102 -0
  10. package/Result.js +143 -0
  11. package/Result.js.map +1 -0
  12. package/Webiny.d.ts +8 -0
  13. package/Webiny.js +11 -0
  14. package/Webiny.js.map +1 -0
  15. package/errors.d.ts +29 -0
  16. package/errors.js +43 -0
  17. package/errors.js.map +1 -0
  18. package/index.d.ts +13 -0
  19. package/index.js +11 -0
  20. package/index.js.map +1 -0
  21. package/methods/cms/cmsTypes.d.ts +82 -0
  22. package/methods/cms/cmsTypes.js +3 -0
  23. package/methods/cms/cmsTypes.js.map +1 -0
  24. package/methods/cms/createEntry.d.ts +67 -0
  25. package/methods/cms/createEntry.js +59 -0
  26. package/methods/cms/createEntry.js.map +1 -0
  27. package/methods/cms/deleteEntryRevision.d.ts +20 -0
  28. package/methods/cms/deleteEntryRevision.js +53 -0
  29. package/methods/cms/deleteEntryRevision.js.map +1 -0
  30. package/methods/cms/getEntry.d.ts +32 -0
  31. package/methods/cms/getEntry.js +60 -0
  32. package/methods/cms/getEntry.js.map +1 -0
  33. package/methods/cms/listEntries.d.ts +38 -0
  34. package/methods/cms/listEntries.js +90 -0
  35. package/methods/cms/listEntries.js.map +1 -0
  36. package/methods/cms/publishEntryRevision.d.ts +22 -0
  37. package/methods/cms/publishEntryRevision.js +54 -0
  38. package/methods/cms/publishEntryRevision.js.map +1 -0
  39. package/methods/cms/unpublishEntryRevision.d.ts +22 -0
  40. package/methods/cms/unpublishEntryRevision.js +54 -0
  41. package/methods/cms/unpublishEntryRevision.js.map +1 -0
  42. package/methods/cms/updateEntryRevision.d.ts +67 -0
  43. package/methods/cms/updateEntryRevision.js +62 -0
  44. package/methods/cms/updateEntryRevision.js.map +1 -0
  45. package/methods/executeGraphQL.d.ts +4 -0
  46. package/methods/executeGraphQL.js +40 -0
  47. package/methods/executeGraphQL.js.map +1 -0
  48. package/package.json +25 -0
  49. package/types.d.ts +6 -0
  50. package/types.js +3 -0
  51. package/types.js.map +1 -0
@@ -0,0 +1,67 @@
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 { CmsEntryValues, CmsEntryStatus, CmsIdentity } from "./cmsTypes.js";
5
+ /**
6
+ * Create entry data.
7
+ */
8
+ export interface CreateCmsEntryData<TValues extends CmsEntryValues = CmsEntryValues> {
9
+ id?: string;
10
+ status?: CmsEntryStatus;
11
+ /**
12
+ * Entry-level meta fields.
13
+ */
14
+ createdOn?: Date | string;
15
+ modifiedOn?: Date | string | null;
16
+ savedOn?: Date | string;
17
+ deletedOn?: Date | string | null;
18
+ restoredOn?: Date | string | null;
19
+ createdBy?: CmsIdentity;
20
+ modifiedBy?: CmsIdentity;
21
+ savedBy?: CmsIdentity;
22
+ deletedBy?: CmsIdentity | null;
23
+ restoredBy?: CmsIdentity | null;
24
+ firstPublishedOn?: Date | string;
25
+ lastPublishedOn?: Date | string;
26
+ firstPublishedBy?: CmsIdentity;
27
+ lastPublishedBy?: CmsIdentity;
28
+ /**
29
+ * Revision-level meta fields.
30
+ */
31
+ revisionCreatedOn?: Date | string;
32
+ revisionModifiedOn?: Date | string | null;
33
+ revisionSavedOn?: Date | string;
34
+ revisionDeletedOn?: Date | string | null;
35
+ revisionRestoredOn?: Date | string | null;
36
+ revisionCreatedBy?: CmsIdentity;
37
+ revisionModifiedBy?: CmsIdentity | null;
38
+ revisionSavedBy?: CmsIdentity;
39
+ revisionDeletedBy?: CmsIdentity | null;
40
+ revisionRestoredBy?: CmsIdentity | null;
41
+ revisionFirstPublishedOn?: Date | string;
42
+ revisionLastPublishedOn?: Date | string;
43
+ revisionFirstPublishedBy?: CmsIdentity;
44
+ revisionLastPublishedBy?: CmsIdentity;
45
+ location?: {
46
+ folderId?: string | null;
47
+ };
48
+ values: TValues | undefined;
49
+ }
50
+ export interface CreateEntryParams<TValues extends CmsEntryValues = CmsEntryValues> {
51
+ modelId: string;
52
+ data: CreateCmsEntryData<TValues>;
53
+ fields: string[];
54
+ }
55
+ /**
56
+ * Creates a new entry in the CMS.
57
+ *
58
+ * @template TValues - Type of the entry data object returned (typically contains id and entryId, or additional fields if specified)
59
+ * @param config - SDK configuration
60
+ * @param fetchFn - Fetch function to use for HTTP requests
61
+ * @param params - Parameters for creating the entry
62
+ * @param params.modelId - The model ID for the entry
63
+ * @param params.data - The entry data to create
64
+ * @param params.fields - Fields to include in the response. Use "values." prefix for entry values (e.g., "values.author.name") or specify top-level fields like "createdOn"
65
+ * @returns Result containing the created entry data or an error
66
+ */
67
+ export declare function createEntry<TValues extends CmsEntryValues = CmsEntryValues>(config: WebinyConfig, fetchFn: typeof fetch, params: CreateEntryParams<TValues>): Promise<Result<CreateCmsEntryData<TValues>, HttpError | GraphQLError | NetworkError>>;
@@ -0,0 +1,59 @@
1
+ import { Result } from "../../Result.js";
2
+
3
+ /**
4
+ * Create entry data.
5
+ */
6
+
7
+ /**
8
+ * Creates a new entry in the CMS.
9
+ *
10
+ * @template TValues - Type of the entry data object returned (typically contains id and entryId, or additional fields if specified)
11
+ * @param config - SDK configuration
12
+ * @param fetchFn - Fetch function to use for HTTP requests
13
+ * @param params - Parameters for creating the entry
14
+ * @param params.modelId - The model ID for the entry
15
+ * @param params.data - The entry data to create
16
+ * @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"
17
+ * @returns Result containing the created entry data or an error
18
+ */
19
+ export async function createEntry(config, fetchFn, params) {
20
+ const {
21
+ modelId,
22
+ data,
23
+ fields
24
+ } = params;
25
+ const {
26
+ executeGraphQL
27
+ } = await import("../executeGraphQL.js");
28
+ const query = `
29
+ mutation CreateEntry($modelId: ID!, $data: JSON!, $fields: [String!]!) {
30
+ cms {
31
+ createEntry(modelId: $modelId, data: $data, fields: $fields) {
32
+ data
33
+ error {
34
+ message
35
+ code
36
+ }
37
+ }
38
+ }
39
+ }
40
+ `;
41
+ const result = await executeGraphQL(config, fetchFn, query, {
42
+ modelId,
43
+ data,
44
+ fields
45
+ });
46
+ if (result.isFail()) {
47
+ return Result.fail(result.error);
48
+ }
49
+ const responseData = result.value;
50
+ if (responseData.cms.createEntry.error) {
51
+ const {
52
+ GraphQLError
53
+ } = await import("../../errors.js");
54
+ return Result.fail(new GraphQLError(responseData.cms.createEntry.error.message, responseData.cms.createEntry.error.code));
55
+ }
56
+ return Result.ok(responseData.cms.createEntry.data);
57
+ }
58
+
59
+ //# sourceMappingURL=createEntry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Result","createEntry","config","fetchFn","params","modelId","data","fields","executeGraphQL","query","result","isFail","fail","error","responseData","value","cms","GraphQLError","message","code","ok"],"sources":["createEntry.ts"],"sourcesContent":["import type { WebinyConfig } from \"../../types.js\";\nimport { Result } from \"../../Result.js\";\nimport type { HttpError, GraphQLError, NetworkError } from \"../../errors.js\";\nimport type { CmsEntryValues, CmsEntryStatus, CmsIdentity } from \"./cmsTypes.js\";\n\n/**\n * Create entry data.\n */\nexport interface CreateCmsEntryData<TValues extends CmsEntryValues = CmsEntryValues> {\n id?: string;\n status?: CmsEntryStatus;\n\n /**\n * Entry-level meta fields.\n */\n createdOn?: Date | string;\n modifiedOn?: Date | string | null;\n savedOn?: Date | string;\n deletedOn?: Date | string | null;\n restoredOn?: Date | string | null;\n createdBy?: CmsIdentity;\n modifiedBy?: CmsIdentity;\n savedBy?: CmsIdentity;\n deletedBy?: CmsIdentity | null;\n restoredBy?: CmsIdentity | null;\n firstPublishedOn?: Date | string;\n lastPublishedOn?: Date | string;\n firstPublishedBy?: CmsIdentity;\n lastPublishedBy?: CmsIdentity;\n\n /**\n * Revision-level meta fields.\n */\n revisionCreatedOn?: Date | string;\n revisionModifiedOn?: Date | string | null;\n revisionSavedOn?: Date | string;\n revisionDeletedOn?: Date | string | null;\n revisionRestoredOn?: Date | string | null;\n revisionCreatedBy?: CmsIdentity;\n revisionModifiedBy?: CmsIdentity | null;\n revisionSavedBy?: CmsIdentity;\n revisionDeletedBy?: CmsIdentity | null;\n revisionRestoredBy?: CmsIdentity | null;\n revisionFirstPublishedOn?: Date | string;\n revisionLastPublishedOn?: Date | string;\n revisionFirstPublishedBy?: CmsIdentity;\n revisionLastPublishedBy?: CmsIdentity;\n\n location?: {\n folderId?: string | null;\n };\n\n values: TValues | undefined;\n}\n\nexport interface CreateEntryParams<TValues extends CmsEntryValues = CmsEntryValues> {\n modelId: string;\n data: CreateCmsEntryData<TValues>;\n fields: string[];\n}\n\n/**\n * Creates a new entry 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 creating the entry\n * @param params.modelId - The model ID for the entry\n * @param params.data - The entry data to create\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 created entry data or an error\n */\nexport async function createEntry<TValues extends CmsEntryValues = CmsEntryValues>(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: CreateEntryParams<TValues>\n): Promise<Result<CreateCmsEntryData<TValues>, HttpError | GraphQLError | NetworkError>> {\n const { modelId, data, fields } = params;\n\n const { executeGraphQL } = await import(\"../executeGraphQL.js\");\n\n const query = `\n mutation CreateEntry($modelId: ID!, $data: JSON!, $fields: [String!]!) {\n cms {\n createEntry(modelId: $modelId, 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, { modelId, data, fields });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.cms.createEntry.error) {\n const { GraphQLError } = await import(\"../../errors.js\");\n return Result.fail(\n new GraphQLError(\n responseData.cms.createEntry.error.message,\n responseData.cms.createEntry.error.code\n )\n );\n }\n\n return Result.ok(responseData.cms.createEntry.data);\n}\n"],"mappings":"AACA,SAASA,MAAM;;AAIf;AACA;AACA;;AAsDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,WAAWA,CAC7BC,MAAoB,EACpBC,OAAqB,EACrBC,MAAkC,EACmD;EACrF,MAAM;IAAEC,OAAO;IAAEC,IAAI;IAAEC;EAAO,CAAC,GAAGH,MAAM;EAExC,MAAM;IAAEI;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,CAACN,MAAM,EAAEC,OAAO,EAAEM,KAAK,EAAE;IAAEJ,OAAO;IAAEC,IAAI;IAAEC;EAAO,CAAC,CAAC;EAEtF,IAAIG,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;IACjB,OAAOX,MAAM,CAACY,IAAI,CAACF,MAAM,CAACG,KAAK,CAAC;EACpC;EAEA,MAAMC,YAAY,GAAGJ,MAAM,CAACK,KAAK;EAEjC,IAAID,YAAY,CAACE,GAAG,CAACf,WAAW,CAACY,KAAK,EAAE;IACpC,MAAM;MAAEI;IAAa,CAAC,GAAG,MAAM,MAAM,kBAAkB,CAAC;IACxD,OAAOjB,MAAM,CAACY,IAAI,CACd,IAAIK,YAAY,CACZH,YAAY,CAACE,GAAG,CAACf,WAAW,CAACY,KAAK,CAACK,OAAO,EAC1CJ,YAAY,CAACE,GAAG,CAACf,WAAW,CAACY,KAAK,CAACM,IACvC,CACJ,CAAC;EACL;EAEA,OAAOnB,MAAM,CAACoB,EAAE,CAACN,YAAY,CAACE,GAAG,CAACf,WAAW,CAACK,IAAI,CAAC;AACvD","ignoreList":[]}
@@ -0,0 +1,20 @@
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 DeleteEntryRevisionParams {
5
+ modelId: string;
6
+ revisionId: string;
7
+ permanent?: boolean;
8
+ }
9
+ /**
10
+ * Deletes an entry revision from the CMS.
11
+ *
12
+ * @param config - SDK configuration
13
+ * @param fetchFn - Fetch function to use for HTTP requests
14
+ * @param params - Parameters for deleting the entry revision
15
+ * @param params.modelId - The model ID of the entry to delete
16
+ * @param params.revisionId - The revision ID of the entry to delete (e.g., "123#0001")
17
+ * @param params.permanent - Whether to permanently delete the entry (default: false)
18
+ * @returns Result containing true if deletion succeeded or an error
19
+ */
20
+ export declare function deleteEntryRevision(config: WebinyConfig, fetchFn: typeof fetch, params: DeleteEntryRevisionParams): Promise<Result<boolean, HttpError | GraphQLError | NetworkError>>;
@@ -0,0 +1,53 @@
1
+ import { Result } from "../../Result.js";
2
+ /**
3
+ * Deletes an entry revision from the CMS.
4
+ *
5
+ * @param config - SDK configuration
6
+ * @param fetchFn - Fetch function to use for HTTP requests
7
+ * @param params - Parameters for deleting the entry revision
8
+ * @param params.modelId - The model ID of the entry to delete
9
+ * @param params.revisionId - The revision ID of the entry to delete (e.g., "123#0001")
10
+ * @param params.permanent - Whether to permanently delete the entry (default: false)
11
+ * @returns Result containing true if deletion succeeded or an error
12
+ */
13
+ export async function deleteEntryRevision(config, fetchFn, params) {
14
+ const {
15
+ modelId,
16
+ revisionId,
17
+ permanent = false
18
+ } = params;
19
+ const {
20
+ executeGraphQL
21
+ } = await import("../executeGraphQL.js");
22
+ const query = `
23
+ mutation DeleteEntryRevision($modelId: ID!, $revisionId: ID!, $permanent: Boolean) {
24
+ cms {
25
+ deleteEntryRevision(modelId: $modelId, revisionId: $revisionId, permanent: $permanent) {
26
+ data
27
+ error {
28
+ message
29
+ code
30
+ }
31
+ }
32
+ }
33
+ }
34
+ `;
35
+ const result = await executeGraphQL(config, fetchFn, query, {
36
+ modelId,
37
+ revisionId,
38
+ permanent
39
+ });
40
+ if (result.isFail()) {
41
+ return result;
42
+ }
43
+ const data = result.value;
44
+ if (data.cms.deleteEntryRevision.error) {
45
+ const {
46
+ GraphQLError
47
+ } = await import("../../errors.js");
48
+ return Result.fail(new GraphQLError(data.cms.deleteEntryRevision.error.message, data.cms.deleteEntryRevision.error.code));
49
+ }
50
+ return Result.ok(data.cms.deleteEntryRevision.data);
51
+ }
52
+
53
+ //# sourceMappingURL=deleteEntryRevision.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Result","deleteEntryRevision","config","fetchFn","params","modelId","revisionId","permanent","executeGraphQL","query","result","isFail","data","value","cms","error","GraphQLError","fail","message","code","ok"],"sources":["deleteEntryRevision.ts"],"sourcesContent":["import type { WebinyConfig } from \"../../types.js\";\nimport { Result } from \"../../Result.js\";\nimport type { HttpError, GraphQLError, NetworkError } from \"../../errors.js\";\n\nexport interface DeleteEntryRevisionParams {\n modelId: string;\n revisionId: string;\n permanent?: boolean;\n}\n\n/**\n * Deletes an entry revision from the CMS.\n *\n * @param config - SDK configuration\n * @param fetchFn - Fetch function to use for HTTP requests\n * @param params - Parameters for deleting the entry revision\n * @param params.modelId - The model ID of the entry to delete\n * @param params.revisionId - The revision ID of the entry to delete (e.g., \"123#0001\")\n * @param params.permanent - Whether to permanently delete the entry (default: false)\n * @returns Result containing true if deletion succeeded or an error\n */\nexport async function deleteEntryRevision(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: DeleteEntryRevisionParams\n): Promise<Result<boolean, HttpError | GraphQLError | NetworkError>> {\n const { modelId, revisionId, permanent = false } = params;\n\n const { executeGraphQL } = await import(\"../executeGraphQL.js\");\n\n const query = `\n mutation DeleteEntryRevision($modelId: ID!, $revisionId: ID!, $permanent: Boolean) {\n cms {\n deleteEntryRevision(modelId: $modelId, revisionId: $revisionId, permanent: $permanent) {\n data\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, { modelId, revisionId, permanent });\n\n if (result.isFail()) {\n return result;\n }\n\n const data = result.value;\n\n if (data.cms.deleteEntryRevision.error) {\n const { GraphQLError } = await import(\"../../errors.js\");\n return Result.fail(\n new GraphQLError(\n data.cms.deleteEntryRevision.error.message,\n data.cms.deleteEntryRevision.error.code\n )\n );\n }\n\n return Result.ok(data.cms.deleteEntryRevision.data);\n}\n"],"mappings":"AACA,SAASA,MAAM;AASf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,mBAAmBA,CACrCC,MAAoB,EACpBC,OAAqB,EACrBC,MAAiC,EACgC;EACjE,MAAM;IAAEC,OAAO;IAAEC,UAAU;IAAEC,SAAS,GAAG;EAAM,CAAC,GAAGH,MAAM;EAEzD,MAAM;IAAEI;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,CAACN,MAAM,EAAEC,OAAO,EAAEM,KAAK,EAAE;IAAEJ,OAAO;IAAEC,UAAU;IAAEC;EAAU,CAAC,CAAC;EAE/F,IAAIG,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;IACjB,OAAOD,MAAM;EACjB;EAEA,MAAME,IAAI,GAAGF,MAAM,CAACG,KAAK;EAEzB,IAAID,IAAI,CAACE,GAAG,CAACb,mBAAmB,CAACc,KAAK,EAAE;IACpC,MAAM;MAAEC;IAAa,CAAC,GAAG,MAAM,MAAM,kBAAkB,CAAC;IACxD,OAAOhB,MAAM,CAACiB,IAAI,CACd,IAAID,YAAY,CACZJ,IAAI,CAACE,GAAG,CAACb,mBAAmB,CAACc,KAAK,CAACG,OAAO,EAC1CN,IAAI,CAACE,GAAG,CAACb,mBAAmB,CAACc,KAAK,CAACI,IACvC,CACJ,CAAC;EACL;EAEA,OAAOnB,MAAM,CAACoB,EAAE,CAACR,IAAI,CAACE,GAAG,CAACb,mBAAmB,CAACW,IAAI,CAAC;AACvD","ignoreList":[]}
@@ -0,0 +1,32 @@
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 { CmsEntryValues, CmsEntryData } from "./cmsTypes.js";
5
+ export interface GetEntryWhere {
6
+ id?: string;
7
+ entryId?: string;
8
+ values?: Record<string, unknown>;
9
+ }
10
+ export interface GetEntryParams {
11
+ modelId: string;
12
+ where: GetEntryWhere;
13
+ fields: string[];
14
+ preview?: boolean;
15
+ }
16
+ /**
17
+ * Retrieves a single entry from the CMS.
18
+ *
19
+ * @template TValues - Type of the entry values object
20
+ * @param config - SDK configuration
21
+ * @param fetchFn - Fetch function to use for HTTP requests
22
+ * @param params - Parameters for retrieving the entry
23
+ * @param params.modelId - The model ID of the entry to retrieve
24
+ * @param params.where - Where conditions to filter the entry. Can filter by id, entryId, or values
25
+ * @param params.where.id - The revision ID (e.g., "123#0001")
26
+ * @param params.where.entryId - The entry ID (e.g., "123")
27
+ * @param params.where.values - Filter by entry values
28
+ * @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"
29
+ * @param params.preview - When true, uses preview API to access unpublished/draft content. When false (default), uses read API for published content only.
30
+ * @returns Result containing the entry data (or null if not found) or an error
31
+ */
32
+ export declare function getEntry<TValues extends CmsEntryValues = CmsEntryValues>(config: WebinyConfig, fetchFn: typeof fetch, params: GetEntryParams): Promise<Result<CmsEntryData<TValues> | null, HttpError | GraphQLError | NetworkError>>;
@@ -0,0 +1,60 @@
1
+ import { Result } from "../../Result.js";
2
+ /**
3
+ * Retrieves a single entry from the CMS.
4
+ *
5
+ * @template TValues - Type of the entry values object
6
+ * @param config - SDK configuration
7
+ * @param fetchFn - Fetch function to use for HTTP requests
8
+ * @param params - Parameters for retrieving the entry
9
+ * @param params.modelId - The model ID of the entry to retrieve
10
+ * @param params.where - Where conditions to filter the entry. Can filter by id, entryId, or values
11
+ * @param params.where.id - The revision ID (e.g., "123#0001")
12
+ * @param params.where.entryId - The entry ID (e.g., "123")
13
+ * @param params.where.values - Filter by entry values
14
+ * @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"
15
+ * @param params.preview - When true, uses preview API to access unpublished/draft content. When false (default), uses read API for published content only.
16
+ * @returns Result containing the entry data (or null if not found) or an error
17
+ */
18
+ export async function getEntry(config, fetchFn, params) {
19
+ const {
20
+ modelId,
21
+ where,
22
+ fields,
23
+ preview
24
+ } = params;
25
+ const {
26
+ executeGraphQL
27
+ } = await import("../executeGraphQL.js");
28
+ const query = `
29
+ query GetEntry($modelId: ID!, $where: JSON!, $fields: [String!]!, $preview: Boolean) {
30
+ cms {
31
+ getEntry(modelId: $modelId, where: $where, fields: $fields, preview: $preview) {
32
+ data
33
+ error {
34
+ message
35
+ code
36
+ }
37
+ }
38
+ }
39
+ }
40
+ `;
41
+ const result = await executeGraphQL(config, fetchFn, query, {
42
+ modelId,
43
+ where,
44
+ fields,
45
+ preview
46
+ });
47
+ if (result.isFail()) {
48
+ return Result.fail(result.error);
49
+ }
50
+ const responseData = result.value;
51
+ if (responseData.cms.getEntry.error) {
52
+ const {
53
+ GraphQLError
54
+ } = await import("../../errors.js");
55
+ return Result.fail(new GraphQLError(responseData.cms.getEntry.error.message, responseData.cms.getEntry.error.code));
56
+ }
57
+ return Result.ok(responseData.cms.getEntry.data);
58
+ }
59
+
60
+ //# sourceMappingURL=getEntry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Result","getEntry","config","fetchFn","params","modelId","where","fields","preview","executeGraphQL","query","result","isFail","fail","error","responseData","value","cms","GraphQLError","message","code","ok","data"],"sources":["getEntry.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 GetEntryWhere {\n id?: string;\n entryId?: string;\n values?: Record<string, unknown>;\n}\n\nexport interface GetEntryParams {\n modelId: string;\n where: GetEntryWhere;\n fields: string[];\n preview?: boolean;\n}\n\n/**\n * Retrieves a single entry from 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 retrieving the entry\n * @param params.modelId - The model ID of the entry to retrieve\n * @param params.where - Where conditions to filter the entry. Can filter by id, entryId, or values\n * @param params.where.id - The revision ID (e.g., \"123#0001\")\n * @param params.where.entryId - The entry ID (e.g., \"123\")\n * @param params.where.values - Filter by entry values\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 * @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 the entry data (or null if not found) or an error\n */\nexport async function getEntry<TValues extends CmsEntryValues = CmsEntryValues>(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: GetEntryParams\n): Promise<Result<CmsEntryData<TValues> | null, HttpError | GraphQLError | NetworkError>> {\n const { modelId, where, fields, preview } = params;\n\n const { executeGraphQL } = await import(\"../executeGraphQL.js\");\n\n const query = `\n query GetEntry($modelId: ID!, $where: JSON!, $fields: [String!]!, $preview: Boolean) {\n cms {\n getEntry(modelId: $modelId, where: $where, fields: $fields, preview: $preview) {\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 where,\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.getEntry.error) {\n const { GraphQLError } = await import(\"../../errors.js\");\n return Result.fail(\n new GraphQLError(\n responseData.cms.getEntry.error.message,\n responseData.cms.getEntry.error.code\n )\n );\n }\n\n return Result.ok(responseData.cms.getEntry.data);\n}\n"],"mappings":"AACA,SAASA,MAAM;AAiBf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,QAAQA,CAC1BC,MAAoB,EACpBC,OAAqB,EACrBC,MAAsB,EACgE;EACtF,MAAM;IAAEC,OAAO;IAAEC,KAAK;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGJ,MAAM;EAElD,MAAM;IAAEK;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,CAACP,MAAM,EAAEC,OAAO,EAAEO,KAAK,EAAE;IACxDL,OAAO;IACPC,KAAK;IACLC,MAAM;IACNC;EACJ,CAAC,CAAC;EAEF,IAAIG,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;IACjB,OAAOZ,MAAM,CAACa,IAAI,CAACF,MAAM,CAACG,KAAK,CAAC;EACpC;EAEA,MAAMC,YAAY,GAAGJ,MAAM,CAACK,KAAK;EAEjC,IAAID,YAAY,CAACE,GAAG,CAAChB,QAAQ,CAACa,KAAK,EAAE;IACjC,MAAM;MAAEI;IAAa,CAAC,GAAG,MAAM,MAAM,kBAAkB,CAAC;IACxD,OAAOlB,MAAM,CAACa,IAAI,CACd,IAAIK,YAAY,CACZH,YAAY,CAACE,GAAG,CAAChB,QAAQ,CAACa,KAAK,CAACK,OAAO,EACvCJ,YAAY,CAACE,GAAG,CAAChB,QAAQ,CAACa,KAAK,CAACM,IACpC,CACJ,CAAC;EACL;EAEA,OAAOpB,MAAM,CAACqB,EAAE,CAACN,YAAY,CAACE,GAAG,CAAChB,QAAQ,CAACqB,IAAI,CAAC;AACpD","ignoreList":[]}
@@ -0,0 +1,38 @@
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 { CmsEntryValues, CmsEntryData } from "./cmsTypes.js";
5
+ export interface ListEntriesParams {
6
+ modelId: string;
7
+ where?: Record<string, unknown>;
8
+ sort?: Record<string, "asc" | "desc">;
9
+ limit?: number;
10
+ after?: string;
11
+ fields: string[];
12
+ preview?: boolean;
13
+ }
14
+ export interface ListEntriesResult<TValues extends CmsEntryValues = CmsEntryValues> {
15
+ data: CmsEntryData<TValues>[];
16
+ meta: {
17
+ cursor: string | null;
18
+ hasMoreItems: boolean;
19
+ totalCount: number;
20
+ };
21
+ }
22
+ /**
23
+ * Lists entries from the CMS with filtering, sorting, and pagination support.
24
+ *
25
+ * @template TValues - Type of the entry data objects. Users should specify this to include all fields they're requesting (id, entryId, values, createdOn, etc.)
26
+ * @param config - SDK configuration
27
+ * @param fetchFn - Fetch function to use for HTTP requests
28
+ * @param params - Parameters for listing entries
29
+ * @param params.modelId - The model ID of entries to list
30
+ * @param params.where - Optional where conditions to filter entries
31
+ * @param params.sort - Optional sort configuration
32
+ * @param params.limit - Maximum number of entries to return (default: 10)
33
+ * @param params.after - Cursor for pagination
34
+ * @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
+ * @param params.preview - When true, uses preview API to access unpublished/draft content. When false (default), uses read API for published content only.
36
+ * @returns Result containing list of entries with pagination metadata or an error
37
+ */
38
+ export declare function listEntries<TValues extends CmsEntryValues = CmsEntryValues>(config: WebinyConfig, fetchFn: typeof fetch, params: ListEntriesParams): Promise<Result<ListEntriesResult<TValues>, HttpError | GraphQLError | NetworkError>>;
@@ -0,0 +1,90 @@
1
+ import { Result } from "../../Result.js";
2
+ /**
3
+ * Lists entries from the CMS with filtering, sorting, and pagination support.
4
+ *
5
+ * @template TValues - Type of the entry data objects. Users should specify this to include all fields they're requesting (id, entryId, values, createdOn, etc.)
6
+ * @param config - SDK configuration
7
+ * @param fetchFn - Fetch function to use for HTTP requests
8
+ * @param params - Parameters for listing entries
9
+ * @param params.modelId - The model ID of entries to list
10
+ * @param params.where - Optional where conditions to filter entries
11
+ * @param params.sort - Optional sort configuration
12
+ * @param params.limit - Maximum number of entries to return (default: 10)
13
+ * @param params.after - Cursor for pagination
14
+ * @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
+ * @param params.preview - When true, uses preview API to access unpublished/draft content. When false (default), uses read API for published content only.
16
+ * @returns Result containing list of entries with pagination metadata or an error
17
+ */
18
+ export async function listEntries(config, fetchFn, params) {
19
+ const {
20
+ modelId,
21
+ where,
22
+ sort,
23
+ limit = 10,
24
+ after,
25
+ fields,
26
+ preview
27
+ } = params;
28
+ const {
29
+ executeGraphQL
30
+ } = await import("../executeGraphQL.js");
31
+ const query = `
32
+ query ListEntries(
33
+ $modelId: ID!
34
+ $where: JSON
35
+ $sort: JSON
36
+ $limit: Int
37
+ $after: String
38
+ $fields: [String!]!
39
+ $preview: Boolean
40
+ ) {
41
+ cms {
42
+ listEntries(
43
+ modelId: $modelId
44
+ where: $where
45
+ sort: $sort
46
+ limit: $limit
47
+ after: $after
48
+ fields: $fields
49
+ preview: $preview
50
+ ) {
51
+ data
52
+ meta {
53
+ cursor
54
+ hasMoreItems
55
+ totalCount
56
+ }
57
+ error {
58
+ message
59
+ code
60
+ }
61
+ }
62
+ }
63
+ }
64
+ `;
65
+ const result = await executeGraphQL(config, fetchFn, query, {
66
+ modelId,
67
+ where,
68
+ sort,
69
+ limit,
70
+ after,
71
+ fields,
72
+ preview
73
+ });
74
+ if (result.isFail()) {
75
+ return Result.fail(result.error);
76
+ }
77
+ const responseData = result.value;
78
+ if (responseData.cms.listEntries.error) {
79
+ const {
80
+ GraphQLError
81
+ } = await import("../../errors.js");
82
+ return Result.fail(new GraphQLError(responseData.cms.listEntries.error.message, responseData.cms.listEntries.error.code));
83
+ }
84
+ return Result.ok({
85
+ data: responseData.cms.listEntries.data,
86
+ meta: responseData.cms.listEntries.meta
87
+ });
88
+ }
89
+
90
+ //# sourceMappingURL=listEntries.js.map
@@ -0,0 +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;AAuBf;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;EAAQ,CAAC,GAAGP,MAAM;EAE3E,MAAM;IAAEQ;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,KAAK;EAED,MAAMC,MAAM,GAAG,MAAMF,cAAc,CAACV,MAAM,EAAEC,OAAO,EAAEU,KAAK,EAAE;IACxDR,OAAO;IACPC,KAAK;IACLC,IAAI;IACJC,KAAK;IACLC,KAAK;IACLC,MAAM;IACNC;EACJ,CAAC,CAAC;EAEF,IAAIG,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;IACjB,OAAOf,MAAM,CAACgB,IAAI,CAACF,MAAM,CAACG,KAAK,CAAC;EACpC;EAEA,MAAMC,YAAY,GAAGJ,MAAM,CAACK,KAAK;EAEjC,IAAID,YAAY,CAACE,GAAG,CAACnB,WAAW,CAACgB,KAAK,EAAE;IACpC,MAAM;MAAEI;IAAa,CAAC,GAAG,MAAM,MAAM,kBAAkB,CAAC;IACxD,OAAOrB,MAAM,CAACgB,IAAI,CACd,IAAIK,YAAY,CACZH,YAAY,CAACE,GAAG,CAACnB,WAAW,CAACgB,KAAK,CAACK,OAAO,EAC1CJ,YAAY,CAACE,GAAG,CAACnB,WAAW,CAACgB,KAAK,CAACM,IACvC,CACJ,CAAC;EACL;EAEA,OAAOvB,MAAM,CAACwB,EAAE,CAAC;IACbC,IAAI,EAAEP,YAAY,CAACE,GAAG,CAACnB,WAAW,CAACwB,IAAI;IACvCC,IAAI,EAAER,YAAY,CAACE,GAAG,CAACnB,WAAW,CAACyB;EACvC,CAAC,CAAC;AACN","ignoreList":[]}
@@ -0,0 +1,22 @@
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 { CmsEntryValues, CmsEntryData } from "./cmsTypes.js";
5
+ export interface PublishEntryRevisionParams {
6
+ modelId: string;
7
+ revisionId: string;
8
+ fields: string[];
9
+ }
10
+ /**
11
+ * Publishes an entry revision in the CMS.
12
+ *
13
+ * @template TValues - Type of the entry values object
14
+ * @param config - SDK configuration
15
+ * @param fetchFn - Fetch function to use for HTTP requests
16
+ * @param params - Parameters for publishing the entry revision
17
+ * @param params.modelId - The model ID of the entry to publish
18
+ * @param params.revisionId - The revision ID of the entry to publish (e.g., "123#0001")
19
+ * @param params.fields - Fields to include in response. Use "values." prefix for entry values (e.g., "values.author.name")
20
+ * @returns Result containing the published entry data or an error
21
+ */
22
+ export declare function publishEntryRevision<TValues extends CmsEntryValues = CmsEntryValues>(config: WebinyConfig, fetchFn: typeof fetch, params: PublishEntryRevisionParams): Promise<Result<CmsEntryData<TValues>, HttpError | GraphQLError | NetworkError>>;
@@ -0,0 +1,54 @@
1
+ import { Result } from "../../Result.js";
2
+ /**
3
+ * Publishes an entry revision in the CMS.
4
+ *
5
+ * @template TValues - Type of the entry values object
6
+ * @param config - SDK configuration
7
+ * @param fetchFn - Fetch function to use for HTTP requests
8
+ * @param params - Parameters for publishing the entry revision
9
+ * @param params.modelId - The model ID of the entry to publish
10
+ * @param params.revisionId - The revision ID of the entry to publish (e.g., "123#0001")
11
+ * @param params.fields - Fields to include in response. Use "values." prefix for entry values (e.g., "values.author.name")
12
+ * @returns Result containing the published entry data or an error
13
+ */
14
+ export async function publishEntryRevision(config, fetchFn, params) {
15
+ const {
16
+ modelId,
17
+ revisionId,
18
+ fields
19
+ } = params;
20
+ const {
21
+ executeGraphQL
22
+ } = await import("../executeGraphQL.js");
23
+ const query = `
24
+ mutation PublishEntryRevision($modelId: ID!, $revisionId: ID!, $fields: [String!]!) {
25
+ cms {
26
+ publishEntryRevision(modelId: $modelId, revisionId: $revisionId, fields: $fields) {
27
+ data
28
+ error {
29
+ message
30
+ code
31
+ }
32
+ }
33
+ }
34
+ }
35
+ `;
36
+ const result = await executeGraphQL(config, fetchFn, query, {
37
+ modelId,
38
+ revisionId,
39
+ fields
40
+ });
41
+ if (result.isFail()) {
42
+ return Result.fail(result.error);
43
+ }
44
+ const responseData = result.value;
45
+ if (responseData.cms.publishEntryRevision.error) {
46
+ const {
47
+ GraphQLError
48
+ } = await import("../../errors.js");
49
+ return Result.fail(new GraphQLError(responseData.cms.publishEntryRevision.error.message, responseData.cms.publishEntryRevision.error.code));
50
+ }
51
+ return Result.ok(responseData.cms.publishEntryRevision.data);
52
+ }
53
+
54
+ //# sourceMappingURL=publishEntryRevision.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Result","publishEntryRevision","config","fetchFn","params","modelId","revisionId","fields","executeGraphQL","query","result","isFail","fail","error","responseData","value","cms","GraphQLError","message","code","ok","data"],"sources":["publishEntryRevision.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 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. Use \"values.\" prefix for entry values (e.g., \"values.author.name\")\n * @returns Result containing the published entry data or an error\n */\nexport async function publishEntryRevision<TValues extends CmsEntryValues = CmsEntryValues>(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: PublishEntryRevisionParams\n): Promise<Result<CmsEntryData<TValues>, HttpError | GraphQLError | NetworkError>> {\n const { modelId, revisionId, fields } = params;\n\n const { executeGraphQL } = await import(\"../executeGraphQL.js\");\n\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, { modelId, revisionId, fields });\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 const { GraphQLError } = await import(\"../../errors.js\");\n return Result.fail(\n new GraphQLError(\n responseData.cms.publishEntryRevision.error.message,\n responseData.cms.publishEntryRevision.error.code\n )\n );\n }\n\n return Result.ok(responseData.cms.publishEntryRevision.data);\n}\n"],"mappings":"AACA,SAASA,MAAM;AAUf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,oBAAoBA,CACtCC,MAAoB,EACpBC,OAAqB,EACrBC,MAAkC,EAC6C;EAC/E,MAAM;IAAEC,OAAO;IAAEC,UAAU;IAAEC;EAAO,CAAC,GAAGH,MAAM;EAE9C,MAAM;IAAEI;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,CAACN,MAAM,EAAEC,OAAO,EAAEM,KAAK,EAAE;IAAEJ,OAAO;IAAEC,UAAU;IAAEC;EAAO,CAAC,CAAC;EAE5F,IAAIG,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;IACjB,OAAOX,MAAM,CAACY,IAAI,CAACF,MAAM,CAACG,KAAK,CAAC;EACpC;EAEA,MAAMC,YAAY,GAAGJ,MAAM,CAACK,KAAK;EAEjC,IAAID,YAAY,CAACE,GAAG,CAACf,oBAAoB,CAACY,KAAK,EAAE;IAC7C,MAAM;MAAEI;IAAa,CAAC,GAAG,MAAM,MAAM,kBAAkB,CAAC;IACxD,OAAOjB,MAAM,CAACY,IAAI,CACd,IAAIK,YAAY,CACZH,YAAY,CAACE,GAAG,CAACf,oBAAoB,CAACY,KAAK,CAACK,OAAO,EACnDJ,YAAY,CAACE,GAAG,CAACf,oBAAoB,CAACY,KAAK,CAACM,IAChD,CACJ,CAAC;EACL;EAEA,OAAOnB,MAAM,CAACoB,EAAE,CAACN,YAAY,CAACE,GAAG,CAACf,oBAAoB,CAACoB,IAAI,CAAC;AAChE","ignoreList":[]}
@@ -0,0 +1,22 @@
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 { CmsEntryValues, CmsEntryData } from "./cmsTypes.js";
5
+ export interface UnpublishEntryRevisionParams {
6
+ modelId: string;
7
+ revisionId: string;
8
+ fields: string[];
9
+ }
10
+ /**
11
+ * Unpublishes an entry revision in the CMS.
12
+ *
13
+ * @template TValues - Type of the entry values object
14
+ * @param config - SDK configuration
15
+ * @param fetchFn - Fetch function to use for HTTP requests
16
+ * @param params - Parameters for unpublishing the entry revision
17
+ * @param params.modelId - The model ID of the entry to unpublish
18
+ * @param params.revisionId - The revision ID of the entry to unpublish (e.g., "123#0001")
19
+ * @param params.fields - Fields to include in response. Use "values." prefix for entry values (e.g., "values.author.name")
20
+ * @returns Result containing the unpublished entry data or an error
21
+ */
22
+ export declare function unpublishEntryRevision<TValues extends CmsEntryValues = CmsEntryValues>(config: WebinyConfig, fetchFn: typeof fetch, params: UnpublishEntryRevisionParams): Promise<Result<CmsEntryData<TValues>, HttpError | GraphQLError | NetworkError>>;
@@ -0,0 +1,54 @@
1
+ import { Result } from "../../Result.js";
2
+ /**
3
+ * Unpublishes an entry revision in the CMS.
4
+ *
5
+ * @template TValues - Type of the entry values object
6
+ * @param config - SDK configuration
7
+ * @param fetchFn - Fetch function to use for HTTP requests
8
+ * @param params - Parameters for unpublishing the entry revision
9
+ * @param params.modelId - The model ID of the entry to unpublish
10
+ * @param params.revisionId - The revision ID of the entry to unpublish (e.g., "123#0001")
11
+ * @param params.fields - Fields to include in response. Use "values." prefix for entry values (e.g., "values.author.name")
12
+ * @returns Result containing the unpublished entry data or an error
13
+ */
14
+ export async function unpublishEntryRevision(config, fetchFn, params) {
15
+ const {
16
+ modelId,
17
+ revisionId,
18
+ fields
19
+ } = params;
20
+ const {
21
+ executeGraphQL
22
+ } = await import("../executeGraphQL.js");
23
+ const query = `
24
+ mutation UnpublishEntryRevision($modelId: ID!, $revisionId: ID!, $fields: [String!]!) {
25
+ cms {
26
+ unpublishEntryRevision(modelId: $modelId, revisionId: $revisionId, fields: $fields) {
27
+ data
28
+ error {
29
+ message
30
+ code
31
+ }
32
+ }
33
+ }
34
+ }
35
+ `;
36
+ const result = await executeGraphQL(config, fetchFn, query, {
37
+ modelId,
38
+ revisionId,
39
+ fields
40
+ });
41
+ if (result.isFail()) {
42
+ return result;
43
+ }
44
+ const data = result.value;
45
+ if (data.cms.unpublishEntryRevision.error) {
46
+ const {
47
+ GraphQLError
48
+ } = await import("../../errors.js");
49
+ return Result.fail(new GraphQLError(data.cms.unpublishEntryRevision.error.message, data.cms.unpublishEntryRevision.error.code));
50
+ }
51
+ return Result.ok(data.cms.unpublishEntryRevision.data);
52
+ }
53
+
54
+ //# sourceMappingURL=unpublishEntryRevision.js.map