@webiny/sdk 6.3.0 → 6.4.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/WebhooksSdk.d.ts +35 -0
- package/WebhooksSdk.js +49 -0
- package/WebhooksSdk.js.map +1 -0
- package/Webiny.d.ts +2 -0
- package/Webiny.js +29 -26
- package/Webiny.js.map +1 -1
- package/errors.js +31 -48
- package/errors.js.map +1 -1
- package/index.d.ts +11 -0
- package/index.js +2 -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/methods/webhooks/createWebhook.d.ts +12 -0
- package/methods/webhooks/createWebhook.js +41 -0
- package/methods/webhooks/createWebhook.js.map +1 -0
- package/methods/webhooks/deleteWebhook.d.ts +6 -0
- package/methods/webhooks/deleteWebhook.js +30 -0
- package/methods/webhooks/deleteWebhook.js.map +1 -0
- package/methods/webhooks/getWebhook.d.ts +7 -0
- package/methods/webhooks/getWebhook.js +41 -0
- package/methods/webhooks/getWebhook.js.map +1 -0
- package/methods/webhooks/getWebhookDelivery.d.ts +7 -0
- package/methods/webhooks/getWebhookDelivery.js +43 -0
- package/methods/webhooks/getWebhookDelivery.js.map +1 -0
- package/methods/webhooks/listAvailableWebhookEvents.d.ts +7 -0
- package/methods/webhooks/listAvailableWebhookEvents.js +31 -0
- package/methods/webhooks/listAvailableWebhookEvents.js.map +1 -0
- package/methods/webhooks/listWebhookDeliveries.d.ts +17 -0
- package/methods/webhooks/listWebhookDeliveries.js +53 -0
- package/methods/webhooks/listWebhookDeliveries.js.map +1 -0
- package/methods/webhooks/listWebhooks.d.ts +19 -0
- package/methods/webhooks/listWebhooks.js +51 -0
- package/methods/webhooks/listWebhooks.js.map +1 -0
- package/methods/webhooks/resendWebhookDelivery.d.ts +6 -0
- package/methods/webhooks/resendWebhookDelivery.js +30 -0
- package/methods/webhooks/resendWebhookDelivery.js.map +1 -0
- package/methods/webhooks/schemas.d.ts +46 -0
- package/methods/webhooks/schemas.js +50 -0
- package/methods/webhooks/schemas.js.map +1 -0
- package/methods/webhooks/triggerWebhook.d.ts +8 -0
- package/methods/webhooks/triggerWebhook.js +44 -0
- package/methods/webhooks/triggerWebhook.js.map +1 -0
- package/methods/webhooks/updateWebhook.d.ts +13 -0
- package/methods/webhooks/updateWebhook.js +42 -0
- package/methods/webhooks/updateWebhook.js.map +1 -0
- package/methods/webhooks/webhooksTypes.d.ts +32 -0
- package/methods/webhooks/webhooksTypes.js +0 -0
- 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
package/TenantManagerSdk.js
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import { createTenant
|
|
2
|
-
import { installTenant
|
|
3
|
-
import { disableTenant
|
|
4
|
-
import { enableTenant
|
|
5
|
-
import { getCurrentTenant
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import { createTenant } from "./methods/tenantManager/createTenant.js";
|
|
2
|
+
import { installTenant } from "./methods/tenantManager/installTenant.js";
|
|
3
|
+
import { disableTenant } from "./methods/tenantManager/disableTenant.js";
|
|
4
|
+
import { enableTenant } from "./methods/tenantManager/enableTenant.js";
|
|
5
|
+
import { getCurrentTenant } from "./methods/tenantManager/getCurrentTenant.js";
|
|
6
|
+
class TenantManagerSdk {
|
|
7
|
+
constructor(config){
|
|
8
|
+
this.config = config;
|
|
9
|
+
this.fetchFn = config.fetch || fetch;
|
|
10
|
+
}
|
|
11
|
+
async createTenant(params) {
|
|
12
|
+
return createTenant(this.config, this.fetchFn, params);
|
|
13
|
+
}
|
|
14
|
+
async installTenant(params) {
|
|
15
|
+
return installTenant(this.config, this.fetchFn, params);
|
|
16
|
+
}
|
|
17
|
+
async disableTenant(params) {
|
|
18
|
+
return disableTenant(this.config, this.fetchFn, params);
|
|
19
|
+
}
|
|
20
|
+
async enableTenant(params) {
|
|
21
|
+
return enableTenant(this.config, this.fetchFn, params);
|
|
22
|
+
}
|
|
23
|
+
async getCurrentTenant() {
|
|
24
|
+
return getCurrentTenant(this.config, this.fetchFn);
|
|
25
|
+
}
|
|
26
26
|
}
|
|
27
|
+
export { TenantManagerSdk };
|
|
27
28
|
|
|
28
29
|
//# sourceMappingURL=TenantManagerSdk.js.map
|
package/TenantManagerSdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"TenantManagerSdk.js","sources":["../src/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, ApiError, NetworkError, ValidationError } 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 | ApiError | NetworkError | ValidationError>> {\n return createTenantFn(this.config, this.fetchFn, params);\n }\n\n async installTenant(\n params: InstallTenantParams\n ): Promise<Result<boolean, HttpError | ApiError | NetworkError | ValidationError>> {\n return installTenantFn(this.config, this.fetchFn, params);\n }\n\n async disableTenant(\n params: DisableTenantParams\n ): Promise<Result<boolean, HttpError | ApiError | NetworkError | ValidationError>> {\n return disableTenantFn(this.config, this.fetchFn, params);\n }\n\n async enableTenant(\n params: EnableTenantParams\n ): Promise<Result<boolean, HttpError | ApiError | NetworkError | ValidationError>> {\n return enableTenantFn(this.config, this.fetchFn, params);\n }\n\n async getCurrentTenant(): Promise<Result<Tenant, HttpError | ApiError | NetworkError>> {\n return getCurrentTenantFn(this.config, this.fetchFn);\n }\n}\n"],"names":["TenantManagerSdk","config","fetch","params","createTenantFn","installTenantFn","disableTenantFn","enableTenantFn","getCurrentTenantFn"],"mappings":";;;;;AAcO,MAAMA;IAIT,YAAYC,MAAoB,CAAE;QAC9B,IAAI,CAAC,MAAM,GAAGA;QACd,IAAI,CAAC,OAAO,GAAGA,OAAO,KAAK,IAAIC;IACnC;IAEA,MAAM,aACFC,MAA0B,EACqD;QAC/E,OAAOC,aAAe,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAED;IACrD;IAEA,MAAM,cACFA,MAA2B,EACoD;QAC/E,OAAOE,cAAgB,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEF;IACtD;IAEA,MAAM,cACFA,MAA2B,EACoD;QAC/E,OAAOG,cAAgB,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEH;IACtD;IAEA,MAAM,aACFA,MAA0B,EACqD;QAC/E,OAAOI,aAAe,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEJ;IACrD;IAEA,MAAM,mBAAiF;QACnF,OAAOK,iBAAmB,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO;IACvD;AACJ"}
|
package/WebhooksSdk.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { WebinyConfig } from "./types.js";
|
|
2
|
+
import type { HttpError } from "./errors.js";
|
|
3
|
+
import type { ApiError } from "./errors.js";
|
|
4
|
+
import type { NetworkError } from "./errors.js";
|
|
5
|
+
import type { ValidationError } from "./errors.js";
|
|
6
|
+
import type { Result } from "./Result.js";
|
|
7
|
+
import type { Webhook } from "./methods/webhooks/webhooksTypes.js";
|
|
8
|
+
import type { WebhookDelivery } from "./methods/webhooks/webhooksTypes.js";
|
|
9
|
+
import type { WebhookEvent } from "./methods/webhooks/webhooksTypes.js";
|
|
10
|
+
import type { GetWebhookParams } from "./methods/webhooks/getWebhook.js";
|
|
11
|
+
import type { ListWebhooksParams } from "./methods/webhooks/listWebhooks.js";
|
|
12
|
+
import type { ListWebhooksResult } from "./methods/webhooks/listWebhooks.js";
|
|
13
|
+
import type { CreateWebhookParams } from "./methods/webhooks/createWebhook.js";
|
|
14
|
+
import type { UpdateWebhookParams } from "./methods/webhooks/updateWebhook.js";
|
|
15
|
+
import type { DeleteWebhookParams } from "./methods/webhooks/deleteWebhook.js";
|
|
16
|
+
import type { GetWebhookDeliveryParams } from "./methods/webhooks/getWebhookDelivery.js";
|
|
17
|
+
import type { ListWebhookDeliveriesParams } from "./methods/webhooks/listWebhookDeliveries.js";
|
|
18
|
+
import type { ListWebhookDeliveriesResult } from "./methods/webhooks/listWebhookDeliveries.js";
|
|
19
|
+
import type { ResendWebhookDeliveryParams } from "./methods/webhooks/resendWebhookDelivery.js";
|
|
20
|
+
import type { TriggerWebhookParams } from "./methods/webhooks/triggerWebhook.js";
|
|
21
|
+
export declare class WebhooksSdk {
|
|
22
|
+
private readonly config;
|
|
23
|
+
private readonly fetchFn;
|
|
24
|
+
constructor(config: WebinyConfig);
|
|
25
|
+
getWebhook(params: GetWebhookParams): Promise<Result<Webhook, HttpError | ApiError | NetworkError | ValidationError>>;
|
|
26
|
+
listWebhooks(params?: ListWebhooksParams): Promise<Result<ListWebhooksResult, HttpError | ApiError | NetworkError | ValidationError>>;
|
|
27
|
+
createWebhook(params: CreateWebhookParams): Promise<Result<Webhook, HttpError | ApiError | NetworkError | ValidationError>>;
|
|
28
|
+
updateWebhook(params: UpdateWebhookParams): Promise<Result<Webhook, HttpError | ApiError | NetworkError | ValidationError>>;
|
|
29
|
+
deleteWebhook(params: DeleteWebhookParams): Promise<Result<boolean, HttpError | ApiError | NetworkError | ValidationError>>;
|
|
30
|
+
getWebhookDelivery(params: GetWebhookDeliveryParams): Promise<Result<WebhookDelivery, HttpError | ApiError | NetworkError | ValidationError>>;
|
|
31
|
+
listWebhookDeliveries(params: ListWebhookDeliveriesParams): Promise<Result<ListWebhookDeliveriesResult, HttpError | ApiError | NetworkError | ValidationError>>;
|
|
32
|
+
resendWebhookDelivery(params: ResendWebhookDeliveryParams): Promise<Result<boolean, HttpError | ApiError | NetworkError | ValidationError>>;
|
|
33
|
+
listAvailableWebhookEvents(): Promise<Result<WebhookEvent[], HttpError | ApiError | NetworkError>>;
|
|
34
|
+
triggerWebhook(params: TriggerWebhookParams): Promise<Result<WebhookDelivery, HttpError | ApiError | NetworkError | ValidationError>>;
|
|
35
|
+
}
|
package/WebhooksSdk.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { getWebhook } from "./methods/webhooks/getWebhook.js";
|
|
2
|
+
import { listWebhooks } from "./methods/webhooks/listWebhooks.js";
|
|
3
|
+
import { createWebhook } from "./methods/webhooks/createWebhook.js";
|
|
4
|
+
import { updateWebhook } from "./methods/webhooks/updateWebhook.js";
|
|
5
|
+
import { deleteWebhook } from "./methods/webhooks/deleteWebhook.js";
|
|
6
|
+
import { getWebhookDelivery } from "./methods/webhooks/getWebhookDelivery.js";
|
|
7
|
+
import { listWebhookDeliveries } from "./methods/webhooks/listWebhookDeliveries.js";
|
|
8
|
+
import { resendWebhookDelivery } from "./methods/webhooks/resendWebhookDelivery.js";
|
|
9
|
+
import { listAvailableWebhookEvents } from "./methods/webhooks/listAvailableWebhookEvents.js";
|
|
10
|
+
import { triggerWebhook } from "./methods/webhooks/triggerWebhook.js";
|
|
11
|
+
class WebhooksSdk {
|
|
12
|
+
constructor(config){
|
|
13
|
+
this.config = config;
|
|
14
|
+
this.fetchFn = config.fetch || fetch;
|
|
15
|
+
}
|
|
16
|
+
async getWebhook(params) {
|
|
17
|
+
return getWebhook(this.config, this.fetchFn, params);
|
|
18
|
+
}
|
|
19
|
+
async listWebhooks(params) {
|
|
20
|
+
return listWebhooks(this.config, this.fetchFn, params ?? {});
|
|
21
|
+
}
|
|
22
|
+
async createWebhook(params) {
|
|
23
|
+
return createWebhook(this.config, this.fetchFn, params);
|
|
24
|
+
}
|
|
25
|
+
async updateWebhook(params) {
|
|
26
|
+
return updateWebhook(this.config, this.fetchFn, params);
|
|
27
|
+
}
|
|
28
|
+
async deleteWebhook(params) {
|
|
29
|
+
return deleteWebhook(this.config, this.fetchFn, params);
|
|
30
|
+
}
|
|
31
|
+
async getWebhookDelivery(params) {
|
|
32
|
+
return getWebhookDelivery(this.config, this.fetchFn, params);
|
|
33
|
+
}
|
|
34
|
+
async listWebhookDeliveries(params) {
|
|
35
|
+
return listWebhookDeliveries(this.config, this.fetchFn, params);
|
|
36
|
+
}
|
|
37
|
+
async resendWebhookDelivery(params) {
|
|
38
|
+
return resendWebhookDelivery(this.config, this.fetchFn, params);
|
|
39
|
+
}
|
|
40
|
+
async listAvailableWebhookEvents() {
|
|
41
|
+
return listAvailableWebhookEvents(this.config, this.fetchFn);
|
|
42
|
+
}
|
|
43
|
+
async triggerWebhook(params) {
|
|
44
|
+
return triggerWebhook(this.config, this.fetchFn, params);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export { WebhooksSdk };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=WebhooksSdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebhooksSdk.js","sources":["../src/WebhooksSdk.ts"],"sourcesContent":["import type { WebinyConfig } from \"./types.js\";\nimport type { HttpError } from \"./errors.js\";\nimport type { ApiError } from \"./errors.js\";\nimport type { NetworkError } from \"./errors.js\";\nimport type { ValidationError } from \"./errors.js\";\nimport type { Result } from \"./Result.js\";\nimport type { Webhook } from \"./methods/webhooks/webhooksTypes.js\";\nimport type { WebhookDelivery } from \"./methods/webhooks/webhooksTypes.js\";\nimport type { WebhookEvent } from \"./methods/webhooks/webhooksTypes.js\";\nimport type { GetWebhookParams } from \"./methods/webhooks/getWebhook.js\";\nimport type { ListWebhooksParams } from \"./methods/webhooks/listWebhooks.js\";\nimport type { ListWebhooksResult } from \"./methods/webhooks/listWebhooks.js\";\nimport type { CreateWebhookParams } from \"./methods/webhooks/createWebhook.js\";\nimport type { UpdateWebhookParams } from \"./methods/webhooks/updateWebhook.js\";\nimport type { DeleteWebhookParams } from \"./methods/webhooks/deleteWebhook.js\";\nimport type { GetWebhookDeliveryParams } from \"./methods/webhooks/getWebhookDelivery.js\";\nimport type { ListWebhookDeliveriesParams } from \"./methods/webhooks/listWebhookDeliveries.js\";\nimport type { ListWebhookDeliveriesResult } from \"./methods/webhooks/listWebhookDeliveries.js\";\nimport type { ResendWebhookDeliveryParams } from \"./methods/webhooks/resendWebhookDelivery.js\";\nimport type { TriggerWebhookParams } from \"./methods/webhooks/triggerWebhook.js\";\nimport { getWebhook as getWebhookFn } from \"./methods/webhooks/getWebhook.js\";\nimport { listWebhooks as listWebhooksFn } from \"./methods/webhooks/listWebhooks.js\";\nimport { createWebhook as createWebhookFn } from \"./methods/webhooks/createWebhook.js\";\nimport { updateWebhook as updateWebhookFn } from \"./methods/webhooks/updateWebhook.js\";\nimport { deleteWebhook as deleteWebhookFn } from \"./methods/webhooks/deleteWebhook.js\";\nimport { getWebhookDelivery as getWebhookDeliveryFn } from \"./methods/webhooks/getWebhookDelivery.js\";\nimport { listWebhookDeliveries as listWebhookDeliveriesFn } from \"./methods/webhooks/listWebhookDeliveries.js\";\nimport { resendWebhookDelivery as resendWebhookDeliveryFn } from \"./methods/webhooks/resendWebhookDelivery.js\";\nimport { listAvailableWebhookEvents as listAvailableWebhookEventsFn } from \"./methods/webhooks/listAvailableWebhookEvents.js\";\nimport { triggerWebhook as triggerWebhookFn } from \"./methods/webhooks/triggerWebhook.js\";\n\nexport class WebhooksSdk {\n private readonly config: WebinyConfig;\n private readonly fetchFn: typeof fetch;\n\n constructor(config: WebinyConfig) {\n this.config = config;\n this.fetchFn = config.fetch || fetch;\n }\n\n async getWebhook(\n params: GetWebhookParams\n ): Promise<Result<Webhook, HttpError | ApiError | NetworkError | ValidationError>> {\n return getWebhookFn(this.config, this.fetchFn, params);\n }\n\n async listWebhooks(\n params?: ListWebhooksParams\n ): Promise<Result<ListWebhooksResult, HttpError | ApiError | NetworkError | ValidationError>> {\n return listWebhooksFn(this.config, this.fetchFn, params ?? {});\n }\n\n async createWebhook(\n params: CreateWebhookParams\n ): Promise<Result<Webhook, HttpError | ApiError | NetworkError | ValidationError>> {\n return createWebhookFn(this.config, this.fetchFn, params);\n }\n\n async updateWebhook(\n params: UpdateWebhookParams\n ): Promise<Result<Webhook, HttpError | ApiError | NetworkError | ValidationError>> {\n return updateWebhookFn(this.config, this.fetchFn, params);\n }\n\n async deleteWebhook(\n params: DeleteWebhookParams\n ): Promise<Result<boolean, HttpError | ApiError | NetworkError | ValidationError>> {\n return deleteWebhookFn(this.config, this.fetchFn, params);\n }\n\n async getWebhookDelivery(\n params: GetWebhookDeliveryParams\n ): Promise<Result<WebhookDelivery, HttpError | ApiError | NetworkError | ValidationError>> {\n return getWebhookDeliveryFn(this.config, this.fetchFn, params);\n }\n\n async listWebhookDeliveries(\n params: ListWebhookDeliveriesParams\n ): Promise<\n Result<ListWebhookDeliveriesResult, HttpError | ApiError | NetworkError | ValidationError>\n > {\n return listWebhookDeliveriesFn(this.config, this.fetchFn, params);\n }\n\n async resendWebhookDelivery(\n params: ResendWebhookDeliveryParams\n ): Promise<Result<boolean, HttpError | ApiError | NetworkError | ValidationError>> {\n return resendWebhookDeliveryFn(this.config, this.fetchFn, params);\n }\n\n async listAvailableWebhookEvents(): Promise<\n Result<WebhookEvent[], HttpError | ApiError | NetworkError>\n > {\n return listAvailableWebhookEventsFn(this.config, this.fetchFn);\n }\n\n async triggerWebhook(\n params: TriggerWebhookParams\n ): Promise<Result<WebhookDelivery, HttpError | ApiError | NetworkError | ValidationError>> {\n return triggerWebhookFn(this.config, this.fetchFn, params);\n }\n}\n"],"names":["WebhooksSdk","config","fetch","params","getWebhookFn","listWebhooksFn","createWebhookFn","updateWebhookFn","deleteWebhookFn","getWebhookDeliveryFn","listWebhookDeliveriesFn","resendWebhookDeliveryFn","listAvailableWebhookEventsFn","triggerWebhookFn"],"mappings":";;;;;;;;;;AA+BO,MAAMA;IAIT,YAAYC,MAAoB,CAAE;QAC9B,IAAI,CAAC,MAAM,GAAGA;QACd,IAAI,CAAC,OAAO,GAAGA,OAAO,KAAK,IAAIC;IACnC;IAEA,MAAM,WACFC,MAAwB,EACuD;QAC/E,OAAOC,WAAa,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAED;IACnD;IAEA,MAAM,aACFA,MAA2B,EAC+D;QAC1F,OAAOE,aAAe,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEF,UAAU,CAAC;IAChE;IAEA,MAAM,cACFA,MAA2B,EACoD;QAC/E,OAAOG,cAAgB,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEH;IACtD;IAEA,MAAM,cACFA,MAA2B,EACoD;QAC/E,OAAOI,cAAgB,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEJ;IACtD;IAEA,MAAM,cACFA,MAA2B,EACoD;QAC/E,OAAOK,cAAgB,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEL;IACtD;IAEA,MAAM,mBACFA,MAAgC,EACuD;QACvF,OAAOM,mBAAqB,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEN;IAC3D;IAEA,MAAM,sBACFA,MAAmC,EAGrC;QACE,OAAOO,sBAAwB,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEP;IAC9D;IAEA,MAAM,sBACFA,MAAmC,EAC4C;QAC/E,OAAOQ,sBAAwB,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAER;IAC9D;IAEA,MAAM,6BAEJ;QACE,OAAOS,2BAA6B,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO;IACjE;IAEA,MAAM,eACFT,MAA4B,EAC2D;QACvF,OAAOU,eAAiB,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEV;IACvD;AACJ"}
|
package/Webiny.d.ts
CHANGED
|
@@ -4,12 +4,14 @@ import { TenantManagerSdk } from "./TenantManagerSdk.js";
|
|
|
4
4
|
import { FileManagerSdk } from "./FileManagerSdk.js";
|
|
5
5
|
import { LanguagesSdk } from "./LanguagesSdk.js";
|
|
6
6
|
import { TasksSdk } from "./TasksSdk.js";
|
|
7
|
+
import { WebhooksSdk } from "./WebhooksSdk.js";
|
|
7
8
|
export declare class Webiny {
|
|
8
9
|
readonly cms: CmsSdk;
|
|
9
10
|
readonly tenantManager: TenantManagerSdk;
|
|
10
11
|
readonly fileManager: FileManagerSdk;
|
|
11
12
|
readonly languages: LanguagesSdk;
|
|
12
13
|
readonly tasks: TasksSdk;
|
|
14
|
+
readonly webhooks: WebhooksSdk;
|
|
13
15
|
constructor(config: WebinyConfig);
|
|
14
16
|
}
|
|
15
17
|
export { Webiny as Sdk };
|
package/Webiny.js
CHANGED
|
@@ -3,32 +3,35 @@ import { TenantManagerSdk } from "./TenantManagerSdk.js";
|
|
|
3
3
|
import { FileManagerSdk } from "./FileManagerSdk.js";
|
|
4
4
|
import { LanguagesSdk } from "./LanguagesSdk.js";
|
|
5
5
|
import { TasksSdk } from "./TasksSdk.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
6
|
+
import { WebhooksSdk } from "./WebhooksSdk.js";
|
|
7
|
+
class Webiny {
|
|
8
|
+
constructor(config){
|
|
9
|
+
this.cms = new CmsSdk({
|
|
10
|
+
...config,
|
|
11
|
+
tenant: config.tenant || "root"
|
|
12
|
+
});
|
|
13
|
+
this.tenantManager = new TenantManagerSdk({
|
|
14
|
+
...config,
|
|
15
|
+
tenant: config.tenant || "root"
|
|
16
|
+
});
|
|
17
|
+
this.fileManager = new FileManagerSdk({
|
|
18
|
+
...config,
|
|
19
|
+
tenant: config.tenant || "root"
|
|
20
|
+
});
|
|
21
|
+
this.languages = new LanguagesSdk({
|
|
22
|
+
...config,
|
|
23
|
+
tenant: config.tenant || "root"
|
|
24
|
+
});
|
|
25
|
+
this.tasks = new TasksSdk({
|
|
26
|
+
...config,
|
|
27
|
+
tenant: config.tenant || "root"
|
|
28
|
+
});
|
|
29
|
+
this.webhooks = new WebhooksSdk({
|
|
30
|
+
...config,
|
|
31
|
+
tenant: config.tenant || "root"
|
|
32
|
+
});
|
|
33
|
+
}
|
|
29
34
|
}
|
|
30
|
-
|
|
31
|
-
// Backward compatibility exports.
|
|
32
|
-
export { Webiny as Sdk };
|
|
35
|
+
export { Webiny as Sdk, Webiny };
|
|
33
36
|
|
|
34
37
|
//# sourceMappingURL=Webiny.js.map
|
package/Webiny.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"Webiny.js","sources":["../src/Webiny.ts"],"sourcesContent":["import type { WebinyConfig } from \"./types.js\";\nimport { CmsSdk } from \"./CmsSdk.js\";\nimport { TenantManagerSdk } from \"./TenantManagerSdk.js\";\nimport { FileManagerSdk } from \"./FileManagerSdk.js\";\nimport { LanguagesSdk } from \"./LanguagesSdk.js\";\nimport { TasksSdk } from \"./TasksSdk.js\";\nimport { WebhooksSdk } from \"./WebhooksSdk.js\";\n\nexport class Webiny {\n public readonly cms: CmsSdk;\n public readonly tenantManager: TenantManagerSdk;\n public readonly fileManager: FileManagerSdk;\n public readonly languages: LanguagesSdk;\n public readonly tasks: TasksSdk;\n public readonly webhooks: WebhooksSdk;\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 this.languages = new LanguagesSdk({\n ...config,\n tenant: config.tenant || \"root\"\n });\n this.tasks = new TasksSdk({\n ...config,\n tenant: config.tenant || \"root\"\n });\n this.webhooks = new WebhooksSdk({\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"],"names":["Webiny","config","CmsSdk","TenantManagerSdk","FileManagerSdk","LanguagesSdk","TasksSdk","WebhooksSdk"],"mappings":";;;;;;AAQO,MAAMA;IAQT,YAAYC,MAAoB,CAAE;QAC9B,IAAI,CAAC,GAAG,GAAG,IAAIC,OAAO;YAClB,GAAGD,MAAM;YACT,QAAQA,OAAO,MAAM,IAAI;QAC7B;QACA,IAAI,CAAC,aAAa,GAAG,IAAIE,iBAAiB;YACtC,GAAGF,MAAM;YACT,QAAQA,OAAO,MAAM,IAAI;QAC7B;QACA,IAAI,CAAC,WAAW,GAAG,IAAIG,eAAe;YAClC,GAAGH,MAAM;YACT,QAAQA,OAAO,MAAM,IAAI;QAC7B;QACA,IAAI,CAAC,SAAS,GAAG,IAAII,aAAa;YAC9B,GAAGJ,MAAM;YACT,QAAQA,OAAO,MAAM,IAAI;QAC7B;QACA,IAAI,CAAC,KAAK,GAAG,IAAIK,SAAS;YACtB,GAAGL,MAAM;YACT,QAAQA,OAAO,MAAM,IAAI;QAC7B;QACA,IAAI,CAAC,QAAQ,GAAG,IAAIM,YAAY;YAC5B,GAAGN,MAAM;YACT,QAAQA,OAAO,MAAM,IAAI;QAC7B;IACJ;AACJ"}
|
package/errors.js
CHANGED
|
@@ -1,55 +1,38 @@
|
|
|
1
1
|
import { BaseError } from "./BaseError.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
status
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
}
|
|
2
|
+
class HttpError extends BaseError {
|
|
3
|
+
constructor(status, message){
|
|
4
|
+
super({
|
|
5
|
+
message,
|
|
6
|
+
data: {
|
|
7
|
+
status
|
|
8
|
+
}
|
|
9
|
+
}), this.code = "HTTP_ERROR";
|
|
10
|
+
}
|
|
15
11
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
code: errorCode
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
12
|
+
class ApiError extends BaseError {
|
|
13
|
+
constructor(message, errorCode){
|
|
14
|
+
super({
|
|
15
|
+
message,
|
|
16
|
+
data: {
|
|
17
|
+
code: errorCode
|
|
18
|
+
}
|
|
19
|
+
}), this.code = "API_ERROR";
|
|
20
|
+
}
|
|
29
21
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
constructor(message) {
|
|
37
|
-
super({
|
|
38
|
-
message
|
|
39
|
-
});
|
|
40
|
-
}
|
|
22
|
+
class NetworkError extends BaseError {
|
|
23
|
+
constructor(message){
|
|
24
|
+
super({
|
|
25
|
+
message
|
|
26
|
+
}), this.code = "NETWORK_ERROR";
|
|
27
|
+
}
|
|
41
28
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
constructor(message) {
|
|
49
|
-
super({
|
|
50
|
-
message
|
|
51
|
-
});
|
|
52
|
-
}
|
|
29
|
+
class ValidationError extends BaseError {
|
|
30
|
+
constructor(message){
|
|
31
|
+
super({
|
|
32
|
+
message
|
|
33
|
+
}), this.code = "VALIDATION_ERROR";
|
|
34
|
+
}
|
|
53
35
|
}
|
|
36
|
+
export { ApiError, HttpError, NetworkError, ValidationError };
|
|
54
37
|
|
|
55
38
|
//# sourceMappingURL=errors.js.map
|
package/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"errors.js","sources":["../src/errors.ts"],"sourcesContent":["import { BaseError } from \"./BaseError.js\";\n\ntype HttpErrorData = {\n status: number;\n};\n\n/**\n * HTTP error from the API.\n */\nexport class HttpError extends BaseError<HttpErrorData> {\n override readonly code = \"HTTP_ERROR\" as const;\n\n constructor(status: number, message: string) {\n super({\n message,\n data: { status }\n });\n }\n}\n\ntype ApiErrorData = {\n code?: string;\n};\n\n/**\n * GraphQL error from the API.\n */\nexport class ApiError extends BaseError<ApiErrorData> {\n override readonly code = \"API_ERROR\" as const;\n\n constructor(message: string, errorCode?: string) {\n super({\n message,\n data: { code: errorCode }\n });\n }\n}\n\n/**\n * Network error (fetch failed).\n */\nexport class NetworkError extends BaseError {\n override readonly code = \"NETWORK_ERROR\" as const;\n\n constructor(message: string) {\n super({\n message\n });\n }\n}\n\n/**\n * Input validation error — params failed schema validation before any network request was made.\n */\nexport class ValidationError extends BaseError {\n override readonly code = \"VALIDATION_ERROR\" as const;\n\n constructor(message: string) {\n super({ message });\n }\n}\n"],"names":["HttpError","BaseError","status","message","ApiError","errorCode","NetworkError","ValidationError"],"mappings":";AASO,MAAMA,kBAAkBC;IAG3B,YAAYC,MAAc,EAAEC,OAAe,CAAE;QACzC,KAAK,CAAC;YACFA;YACA,MAAM;gBAAED;YAAO;QACnB,SANc,IAAI,GAAG;IAOzB;AACJ;AASO,MAAME,iBAAiBH;IAG1B,YAAYE,OAAe,EAAEE,SAAkB,CAAE;QAC7C,KAAK,CAAC;YACFF;YACA,MAAM;gBAAE,MAAME;YAAU;QAC5B,SANc,IAAI,GAAG;IAOzB;AACJ;AAKO,MAAMC,qBAAqBL;IAG9B,YAAYE,OAAe,CAAE;QACzB,KAAK,CAAC;YACFA;QACJ,SALc,IAAI,GAAG;IAMzB;AACJ;AAKO,MAAMI,wBAAwBN;IAGjC,YAAYE,OAAe,CAAE;QACzB,KAAK,CAAC;YAAEA;QAAQ,SAHF,IAAI,GAAG;IAIzB;AACJ"}
|
package/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./TenantManagerSdk.js";
|
|
|
4
4
|
export * from "./FileManagerSdk.js";
|
|
5
5
|
export * from "./LanguagesSdk.js";
|
|
6
6
|
export * from "./TasksSdk.js";
|
|
7
|
+
export * from "./WebhooksSdk.js";
|
|
7
8
|
export * from "./types.js";
|
|
8
9
|
export { Result } from "./Result.js";
|
|
9
10
|
export { HttpError, ApiError, NetworkError, ValidationError } from "./errors.js";
|
|
@@ -37,3 +38,13 @@ export type { TaskStatus, TaskDefinition, TaskRun, TaskLog, TaskLogItem } from "
|
|
|
37
38
|
export type { ListLogsParams } from "./methods/tasks/listLogs.js";
|
|
38
39
|
export type { TriggerTaskParams } from "./methods/tasks/triggerTask.js";
|
|
39
40
|
export type { AbortTaskParams } from "./methods/tasks/abortTask.js";
|
|
41
|
+
export type { Webhook, WebhookDelivery, WebhookEvent } from "./methods/webhooks/webhooksTypes.js";
|
|
42
|
+
export type { GetWebhookParams } from "./methods/webhooks/getWebhook.js";
|
|
43
|
+
export type { ListWebhooksParams, ListWebhooksResult } from "./methods/webhooks/listWebhooks.js";
|
|
44
|
+
export type { CreateWebhookParams } from "./methods/webhooks/createWebhook.js";
|
|
45
|
+
export type { UpdateWebhookParams } from "./methods/webhooks/updateWebhook.js";
|
|
46
|
+
export type { DeleteWebhookParams } from "./methods/webhooks/deleteWebhook.js";
|
|
47
|
+
export type { GetWebhookDeliveryParams } from "./methods/webhooks/getWebhookDelivery.js";
|
|
48
|
+
export type { ListWebhookDeliveriesParams, ListWebhookDeliveriesResult } from "./methods/webhooks/listWebhookDeliveries.js";
|
|
49
|
+
export type { ResendWebhookDeliveryParams } from "./methods/webhooks/resendWebhookDelivery.js";
|
|
50
|
+
export type { TriggerWebhookParams } from "./methods/webhooks/triggerWebhook.js";
|
package/index.js
CHANGED
|
@@ -4,26 +4,7 @@ export * from "./TenantManagerSdk.js";
|
|
|
4
4
|
export * from "./FileManagerSdk.js";
|
|
5
5
|
export * from "./LanguagesSdk.js";
|
|
6
6
|
export * from "./TasksSdk.js";
|
|
7
|
+
export * from "./WebhooksSdk.js";
|
|
7
8
|
export * from "./types.js";
|
|
8
9
|
export { Result } from "./Result.js";
|
|
9
|
-
export {
|
|
10
|
-
|
|
11
|
-
// Export shared CMS types.
|
|
12
|
-
|
|
13
|
-
// Export types from methods.
|
|
14
|
-
|
|
15
|
-
// Export TenantManager types.
|
|
16
|
-
|
|
17
|
-
// Export types from tenantManager methods.
|
|
18
|
-
|
|
19
|
-
// Export FileManager types.
|
|
20
|
-
|
|
21
|
-
// Export types from fileManager methods.
|
|
22
|
-
|
|
23
|
-
// Export Languages types.
|
|
24
|
-
|
|
25
|
-
// Export Tasks types.
|
|
26
|
-
|
|
27
|
-
// Export types from tasks methods.
|
|
28
|
-
|
|
29
|
-
//# sourceMappingURL=index.js.map
|
|
10
|
+
export { ApiError, HttpError, NetworkError, ValidationError } from "./errors.js";
|
package/methods/cms/cmsTypes.js
CHANGED
|
@@ -4,30 +4,8 @@ import { createMethod } from "../../utils/createMethod.js";
|
|
|
4
4
|
import { createEntrySchema } from "./schemas.js";
|
|
5
5
|
import { executeGraphQL } from "../executeGraphQL.js";
|
|
6
6
|
import { ApiError } from "../../errors.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* Create entry data.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Creates a new entry 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 creating the entry
|
|
19
|
-
* @param params.modelId - The model ID for the entry
|
|
20
|
-
* @param params.data - The entry data to create
|
|
21
|
-
* @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"
|
|
22
|
-
* @returns Result containing the created entry data or an error
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
const _impl = createMethod(createEntrySchema, async (config, fetchFn, {
|
|
26
|
-
modelId,
|
|
27
|
-
data,
|
|
28
|
-
fields
|
|
29
|
-
}) => {
|
|
30
|
-
const query = `
|
|
7
|
+
const _impl = createMethod(createEntrySchema, async (config, fetchFn, { modelId, data, fields })=>{
|
|
8
|
+
const query = `
|
|
31
9
|
mutation CreateEntry($modelId: ID!, $data: JSON!, $fields: [String!]!) {
|
|
32
10
|
cms {
|
|
33
11
|
createEntry(modelId: $modelId, data: $data, fields: $fields) {
|
|
@@ -40,22 +18,19 @@ const _impl = createMethod(createEntrySchema, async (config, fetchFn, {
|
|
|
40
18
|
}
|
|
41
19
|
}
|
|
42
20
|
`;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (responseData.cms.createEntry.error) {
|
|
53
|
-
return Result.fail(new ApiError(transformFieldErrors(responseData.cms.createEntry.error.message, fields), responseData.cms.createEntry.error.code));
|
|
54
|
-
}
|
|
55
|
-
return Result.ok(responseData.cms.createEntry.data);
|
|
21
|
+
const result = await executeGraphQL(config, fetchFn, query, {
|
|
22
|
+
modelId,
|
|
23
|
+
data,
|
|
24
|
+
fields
|
|
25
|
+
});
|
|
26
|
+
if (result.isFail()) return Result.fail(result.error);
|
|
27
|
+
const responseData = result.value;
|
|
28
|
+
if (responseData.cms.createEntry.error) return Result.fail(new ApiError(transformFieldErrors(responseData.cms.createEntry.error.message, fields), responseData.cms.createEntry.error.code));
|
|
29
|
+
return Result.ok(responseData.cms.createEntry.data);
|
|
56
30
|
});
|
|
57
|
-
|
|
58
|
-
|
|
31
|
+
function createEntry(config, fetchFn, params) {
|
|
32
|
+
return _impl(config, fetchFn, params);
|
|
59
33
|
}
|
|
34
|
+
export { createEntry };
|
|
60
35
|
|
|
61
36
|
//# sourceMappingURL=createEntry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"methods/cms/createEntry.js","sources":["../../../src/methods/cms/createEntry.ts"],"sourcesContent":["import type { WebinyConfig } from \"../../types.js\";\nimport { Result } from \"../../Result.js\";\nimport type { HttpError, NetworkError, ValidationError } from \"../../errors.js\";\nimport type { CmsEntryValues, CmsEntryStatus, CmsIdentity } from \"./cmsTypes.js\";\nimport { transformFieldErrors } from \"../../utils/transformFieldErrors.js\";\nimport { createMethod } from \"../../utils/createMethod.js\";\nimport { createEntrySchema } from \"./schemas.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.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 */\n\nconst _impl = createMethod(\n createEntrySchema,\n async (config, fetchFn, { modelId, data, fields }) => {\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 return Result.fail(\n new ApiError(\n transformFieldErrors(responseData.cms.createEntry.error.message, fields),\n responseData.cms.createEntry.error.code\n )\n );\n }\n\n return Result.ok(responseData.cms.createEntry.data);\n }\n);\n\nexport function createEntry<TValues extends CmsEntryValues = CmsEntryValues>(\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: CreateEntryParams<TValues>\n): Promise<\n Result<CreateCmsEntryData<TValues>, HttpError | ApiError | NetworkError | ValidationError>\n> {\n return _impl(config, fetchFn, params) as Promise<\n Result<CreateCmsEntryData<TValues>, HttpError | ApiError | NetworkError | ValidationError>\n >;\n}\n"],"names":["_impl","createMethod","createEntrySchema","config","fetchFn","modelId","data","fields","query","result","executeGraphQL","Result","responseData","ApiError","transformFieldErrors","createEntry","params"],"mappings":";;;;;;AA+EA,MAAMA,QAAQC,aACVC,mBACA,OAAOC,QAAQC,SAAS,EAAEC,OAAO,EAAEC,IAAI,EAAEC,MAAM,EAAE;IAC7C,MAAMC,QAAQ,CAAC;;;;;;;;;;;;IAYnB,CAAC;IAEG,MAAMC,SAAS,MAAMC,eAAeP,QAAQC,SAASI,OAAO;QAAEH;QAASC;QAAMC;IAAO;IAEpF,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,EAAEL,SACjEK,aAAa,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI;IAKnD,OAAOD,OAAO,EAAE,CAACC,aAAa,GAAG,CAAC,WAAW,CAAC,IAAI;AACtD;AAGG,SAASG,YACZZ,MAAoB,EACpBC,OAAqB,EACrBY,MAAkC;IAIlC,OAAOhB,MAAMG,QAAQC,SAASY;AAGlC"}
|
|
@@ -3,23 +3,8 @@ import { createMethod } from "../../utils/createMethod.js";
|
|
|
3
3
|
import { deleteEntryRevisionSchema } from "./schemas.js";
|
|
4
4
|
import { executeGraphQL } from "../executeGraphQL.js";
|
|
5
5
|
import { ApiError } from "../../errors.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
* @param config - SDK configuration
|
|
10
|
-
* @param fetchFn - Fetch function to use for HTTP requests
|
|
11
|
-
* @param params - Parameters for deleting the entry revision
|
|
12
|
-
* @param params.modelId - The model ID of the entry to delete
|
|
13
|
-
* @param params.revisionId - The revision ID of the entry to delete (e.g., "123#0001")
|
|
14
|
-
* @param params.permanent - Whether to permanently delete the entry (default: false)
|
|
15
|
-
* @returns Result containing true if deletion succeeded or an error
|
|
16
|
-
*/
|
|
17
|
-
export const deleteEntryRevision = createMethod(deleteEntryRevisionSchema, async (config, fetchFn, {
|
|
18
|
-
modelId,
|
|
19
|
-
revisionId,
|
|
20
|
-
permanent = false
|
|
21
|
-
}) => {
|
|
22
|
-
const query = `
|
|
6
|
+
const deleteEntryRevision = createMethod(deleteEntryRevisionSchema, async (config, fetchFn, { modelId, revisionId, permanent = false })=>{
|
|
7
|
+
const query = `
|
|
23
8
|
mutation DeleteEntryRevision($modelId: ID!, $revisionId: ID!, $permanent: Boolean) {
|
|
24
9
|
cms {
|
|
25
10
|
deleteEntryRevision(modelId: $modelId, revisionId: $revisionId, permanent: $permanent) {
|
|
@@ -32,19 +17,16 @@ export const deleteEntryRevision = createMethod(deleteEntryRevisionSchema, async
|
|
|
32
17
|
}
|
|
33
18
|
}
|
|
34
19
|
`;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (data.cms.deleteEntryRevision.error) {
|
|
45
|
-
return Result.fail(new ApiError(data.cms.deleteEntryRevision.error.message, data.cms.deleteEntryRevision.error.code));
|
|
46
|
-
}
|
|
47
|
-
return Result.ok(data.cms.deleteEntryRevision.data);
|
|
20
|
+
const result = await executeGraphQL(config, fetchFn, query, {
|
|
21
|
+
modelId,
|
|
22
|
+
revisionId,
|
|
23
|
+
permanent
|
|
24
|
+
});
|
|
25
|
+
if (result.isFail()) return result;
|
|
26
|
+
const data = result.value;
|
|
27
|
+
if (data.cms.deleteEntryRevision.error) return Result.fail(new ApiError(data.cms.deleteEntryRevision.error.message, data.cms.deleteEntryRevision.error.code));
|
|
28
|
+
return Result.ok(data.cms.deleteEntryRevision.data);
|
|
48
29
|
});
|
|
30
|
+
export { deleteEntryRevision };
|
|
49
31
|
|
|
50
32
|
//# sourceMappingURL=deleteEntryRevision.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"methods/cms/deleteEntryRevision.js","sources":["../../../src/methods/cms/deleteEntryRevision.ts"],"sourcesContent":["import { Result } from \"../../Result.js\";\nimport { createMethod } from \"../../utils/createMethod.js\";\nimport { deleteEntryRevisionSchema } from \"./schemas.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } 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 const deleteEntryRevision = createMethod(\n deleteEntryRevisionSchema,\n async (config, fetchFn, { modelId, revisionId, permanent = false }) => {\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, {\n modelId,\n revisionId,\n permanent\n });\n\n if (result.isFail()) {\n return result;\n }\n\n const data = result.value;\n\n if (data.cms.deleteEntryRevision.error) {\n return Result.fail(\n new ApiError(\n data.cms.deleteEntryRevision.error.message,\n data.cms.deleteEntryRevision.error.code\n )\n );\n }\n\n return Result.ok(data.cms.deleteEntryRevision.data as boolean);\n }\n);\n"],"names":["deleteEntryRevision","createMethod","deleteEntryRevisionSchema","config","fetchFn","modelId","revisionId","permanent","query","result","executeGraphQL","data","Result","ApiError"],"mappings":";;;;;AAuBO,MAAMA,sBAAsBC,aAC/BC,2BACA,OAAOC,QAAQC,SAAS,EAAEC,OAAO,EAAEC,UAAU,EAAEC,YAAY,KAAK,EAAE;IAC9D,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,mBAAmB,CAAC,KAAK,EAClC,OAAOC,OAAO,IAAI,CACd,IAAIC,SACAF,KAAK,GAAG,CAAC,mBAAmB,CAAC,KAAK,CAAC,OAAO,EAC1CA,KAAK,GAAG,CAAC,mBAAmB,CAAC,KAAK,CAAC,IAAI;IAKnD,OAAOC,OAAO,EAAE,CAACD,KAAK,GAAG,CAAC,mBAAmB,CAAC,IAAI;AACtD"}
|