@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
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const getWebhookSchema: z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
}, z.core.$strip>;
|
|
5
|
+
export declare const listWebhooksSchema: z.ZodObject<{
|
|
6
|
+
where: z.ZodOptional<z.ZodObject<{
|
|
7
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
+
}, z.core.$strip>>;
|
|
9
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
10
|
+
after: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export declare const createWebhookSchema: z.ZodObject<{
|
|
13
|
+
name: z.ZodString;
|
|
14
|
+
endpointUrl: z.ZodString;
|
|
15
|
+
events: z.ZodArray<z.ZodString>;
|
|
16
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
17
|
+
description: z.ZodOptional<z.ZodString>;
|
|
18
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
export declare const updateWebhookSchema: z.ZodObject<{
|
|
21
|
+
id: z.ZodString;
|
|
22
|
+
name: z.ZodOptional<z.ZodString>;
|
|
23
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
24
|
+
endpointUrl: z.ZodOptional<z.ZodString>;
|
|
25
|
+
description: z.ZodOptional<z.ZodString>;
|
|
26
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
27
|
+
events: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
export declare const deleteWebhookSchema: z.ZodObject<{
|
|
30
|
+
id: z.ZodString;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
export declare const getWebhookDeliverySchema: z.ZodObject<{
|
|
33
|
+
id: z.ZodString;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
export declare const listWebhookDeliveriesSchema: z.ZodObject<{
|
|
36
|
+
webhookId: z.ZodString;
|
|
37
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
38
|
+
after: z.ZodOptional<z.ZodString>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
export declare const resendWebhookDeliverySchema: z.ZodObject<{
|
|
41
|
+
id: z.ZodString;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
export declare const triggerWebhookSchema: z.ZodObject<{
|
|
44
|
+
id: z.ZodString;
|
|
45
|
+
payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
46
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const id = z.string().min(1, "id is required");
|
|
3
|
+
const getWebhookSchema = z.object({
|
|
4
|
+
id: id
|
|
5
|
+
});
|
|
6
|
+
const listWebhooksSchema = z.object({
|
|
7
|
+
where: z.object({
|
|
8
|
+
enabled: z.boolean().optional()
|
|
9
|
+
}).optional(),
|
|
10
|
+
limit: z.number().int().positive().optional(),
|
|
11
|
+
after: z.string().optional()
|
|
12
|
+
});
|
|
13
|
+
const createWebhookSchema = z.object({
|
|
14
|
+
name: z.string().min(1, "name is required"),
|
|
15
|
+
endpointUrl: z.string().url("endpointUrl must be a valid URL"),
|
|
16
|
+
events: z.array(z.string().min(1)).min(1, "events must contain at least one entry"),
|
|
17
|
+
slug: z.string().optional(),
|
|
18
|
+
description: z.string().optional(),
|
|
19
|
+
enabled: z.boolean().optional()
|
|
20
|
+
});
|
|
21
|
+
const updateWebhookSchema = z.object({
|
|
22
|
+
id: id,
|
|
23
|
+
name: z.string().min(1).optional(),
|
|
24
|
+
slug: z.string().optional(),
|
|
25
|
+
endpointUrl: z.string().url("endpointUrl must be a valid URL").optional(),
|
|
26
|
+
description: z.string().optional(),
|
|
27
|
+
enabled: z.boolean().optional(),
|
|
28
|
+
events: z.array(z.string().min(1)).optional()
|
|
29
|
+
});
|
|
30
|
+
const deleteWebhookSchema = z.object({
|
|
31
|
+
id: id
|
|
32
|
+
});
|
|
33
|
+
const getWebhookDeliverySchema = z.object({
|
|
34
|
+
id: id
|
|
35
|
+
});
|
|
36
|
+
const listWebhookDeliveriesSchema = z.object({
|
|
37
|
+
webhookId: z.string().min(1, "webhookId is required"),
|
|
38
|
+
limit: z.number().int().positive().optional(),
|
|
39
|
+
after: z.string().optional()
|
|
40
|
+
});
|
|
41
|
+
const resendWebhookDeliverySchema = z.object({
|
|
42
|
+
id: id
|
|
43
|
+
});
|
|
44
|
+
const triggerWebhookSchema = z.object({
|
|
45
|
+
id: id,
|
|
46
|
+
payload: z.record(z.string(), z.unknown())
|
|
47
|
+
});
|
|
48
|
+
export { createWebhookSchema, deleteWebhookSchema, getWebhookDeliverySchema, getWebhookSchema, listWebhookDeliveriesSchema, listWebhooksSchema, resendWebhookDeliverySchema, triggerWebhookSchema, updateWebhookSchema };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"methods/webhooks/schemas.js","sources":["../../../src/methods/webhooks/schemas.ts"],"sourcesContent":["import { z } from \"zod\";\n\nconst id = z.string().min(1, \"id is required\");\n\nexport const getWebhookSchema = z.object({\n id\n});\n\nexport const listWebhooksSchema = z.object({\n where: z\n .object({\n enabled: z.boolean().optional()\n })\n .optional(),\n limit: z.number().int().positive().optional(),\n after: z.string().optional()\n});\n\nexport const createWebhookSchema = z.object({\n name: z.string().min(1, \"name is required\"),\n endpointUrl: z.string().url(\"endpointUrl must be a valid URL\"),\n events: z.array(z.string().min(1)).min(1, \"events must contain at least one entry\"),\n slug: z.string().optional(),\n description: z.string().optional(),\n enabled: z.boolean().optional()\n});\n\nexport const updateWebhookSchema = z.object({\n id,\n name: z.string().min(1).optional(),\n slug: z.string().optional(),\n endpointUrl: z.string().url(\"endpointUrl must be a valid URL\").optional(),\n description: z.string().optional(),\n enabled: z.boolean().optional(),\n events: z.array(z.string().min(1)).optional()\n});\n\nexport const deleteWebhookSchema = z.object({\n id\n});\n\nexport const getWebhookDeliverySchema = z.object({\n id\n});\n\nexport const listWebhookDeliveriesSchema = z.object({\n webhookId: z.string().min(1, \"webhookId is required\"),\n limit: z.number().int().positive().optional(),\n after: z.string().optional()\n});\n\nexport const resendWebhookDeliverySchema = z.object({\n id\n});\n\nexport const triggerWebhookSchema = z.object({\n id,\n payload: z.record(z.string(), z.unknown())\n});\n"],"names":["id","z","getWebhookSchema","listWebhooksSchema","createWebhookSchema","updateWebhookSchema","deleteWebhookSchema","getWebhookDeliverySchema","listWebhookDeliveriesSchema","resendWebhookDeliverySchema","triggerWebhookSchema"],"mappings":";AAEA,MAAMA,KAAKC,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG;AAEtB,MAAMC,mBAAmBD,EAAE,MAAM,CAAC;IACrCD,IAAAA;AACJ;AAEO,MAAMG,qBAAqBF,EAAE,MAAM,CAAC;IACvC,OAAOA,EAAAA,MACI,CAAC;QACJ,SAASA,EAAE,OAAO,GAAG,QAAQ;IACjC,GACC,QAAQ;IACb,OAAOA,EAAE,MAAM,GAAG,GAAG,GAAG,QAAQ,GAAG,QAAQ;IAC3C,OAAOA,EAAE,MAAM,GAAG,QAAQ;AAC9B;AAEO,MAAMG,sBAAsBH,EAAE,MAAM,CAAC;IACxC,MAAMA,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG;IACxB,aAAaA,EAAE,MAAM,GAAG,GAAG,CAAC;IAC5B,QAAQA,EAAE,KAAK,CAACA,EAAE,MAAM,GAAG,GAAG,CAAC,IAAI,GAAG,CAAC,GAAG;IAC1C,MAAMA,EAAE,MAAM,GAAG,QAAQ;IACzB,aAAaA,EAAE,MAAM,GAAG,QAAQ;IAChC,SAASA,EAAE,OAAO,GAAG,QAAQ;AACjC;AAEO,MAAMI,sBAAsBJ,EAAE,MAAM,CAAC;IACxCD,IAAAA;IACA,MAAMC,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG,QAAQ;IAChC,MAAMA,EAAE,MAAM,GAAG,QAAQ;IACzB,aAAaA,EAAE,MAAM,GAAG,GAAG,CAAC,mCAAmC,QAAQ;IACvE,aAAaA,EAAE,MAAM,GAAG,QAAQ;IAChC,SAASA,EAAE,OAAO,GAAG,QAAQ;IAC7B,QAAQA,EAAE,KAAK,CAACA,EAAE,MAAM,GAAG,GAAG,CAAC,IAAI,QAAQ;AAC/C;AAEO,MAAMK,sBAAsBL,EAAE,MAAM,CAAC;IACxCD,IAAAA;AACJ;AAEO,MAAMO,2BAA2BN,EAAE,MAAM,CAAC;IAC7CD,IAAAA;AACJ;AAEO,MAAMQ,8BAA8BP,EAAE,MAAM,CAAC;IAChD,WAAWA,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG;IAC7B,OAAOA,EAAE,MAAM,GAAG,GAAG,GAAG,QAAQ,GAAG,QAAQ;IAC3C,OAAOA,EAAE,MAAM,GAAG,QAAQ;AAC9B;AAEO,MAAMQ,8BAA8BR,EAAE,MAAM,CAAC;IAChDD,IAAAA;AACJ;AAEO,MAAMU,uBAAuBT,EAAE,MAAM,CAAC;IACzCD,IAAAA;IACA,SAASC,EAAE,MAAM,CAACA,EAAE,MAAM,IAAIA,EAAE,OAAO;AAC3C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Result } from "../../Result.js";
|
|
2
|
+
import type { WebhookDelivery } from "./webhooksTypes.js";
|
|
3
|
+
import { ApiError } from "../../errors.js";
|
|
4
|
+
export interface TriggerWebhookParams {
|
|
5
|
+
id: string;
|
|
6
|
+
payload: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
export declare const triggerWebhook: (config: import("../../types.js").WebinyConfig, fetchFn: typeof fetch, params: unknown) => Promise<Result<WebhookDelivery, import("../../errors.js").HttpError | ApiError | import("../../errors.js").NetworkError | import("../../errors.js").ValidationError>>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Result } from "../../Result.js";
|
|
2
|
+
import { createMethod } from "../../utils/createMethod.js";
|
|
3
|
+
import { triggerWebhookSchema } from "./schemas.js";
|
|
4
|
+
import { executeGraphQL } from "../executeGraphQL.js";
|
|
5
|
+
import { ApiError } from "../../errors.js";
|
|
6
|
+
const triggerWebhook = createMethod(triggerWebhookSchema, async (config, fetchFn, { id, payload })=>{
|
|
7
|
+
const query = `
|
|
8
|
+
mutation TriggerWebhook($id: ID!, $payload: JSON!) {
|
|
9
|
+
webhooks {
|
|
10
|
+
triggerWebhook(id: $id, payload: $payload) {
|
|
11
|
+
data {
|
|
12
|
+
id
|
|
13
|
+
webhookId
|
|
14
|
+
backgroundTaskId
|
|
15
|
+
eventType
|
|
16
|
+
status
|
|
17
|
+
payload
|
|
18
|
+
requestHeaders
|
|
19
|
+
responseTime
|
|
20
|
+
responseStatus
|
|
21
|
+
responseBody
|
|
22
|
+
expiresAt
|
|
23
|
+
createdOn
|
|
24
|
+
}
|
|
25
|
+
error {
|
|
26
|
+
message
|
|
27
|
+
code
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
const result = await executeGraphQL(config, fetchFn, query, {
|
|
34
|
+
id,
|
|
35
|
+
payload
|
|
36
|
+
});
|
|
37
|
+
if (result.isFail()) return Result.fail(result.error);
|
|
38
|
+
const responseData = result.value;
|
|
39
|
+
if (responseData.webhooks.triggerWebhook.error) return Result.fail(new ApiError(responseData.webhooks.triggerWebhook.error.message, responseData.webhooks.triggerWebhook.error.code));
|
|
40
|
+
return Result.ok(responseData.webhooks.triggerWebhook.data);
|
|
41
|
+
});
|
|
42
|
+
export { triggerWebhook };
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=triggerWebhook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"methods/webhooks/triggerWebhook.js","sources":["../../../src/methods/webhooks/triggerWebhook.ts"],"sourcesContent":["import { Result } from \"../../Result.js\";\nimport type { WebhookDelivery } from \"./webhooksTypes.js\";\nimport { createMethod } from \"../../utils/createMethod.js\";\nimport { triggerWebhookSchema } from \"./schemas.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.js\";\n\nexport interface TriggerWebhookParams {\n id: string;\n payload: Record<string, unknown>;\n}\n\nexport const triggerWebhook = createMethod(\n triggerWebhookSchema,\n async (config, fetchFn, { id, payload }) => {\n const query = `\n mutation TriggerWebhook($id: ID!, $payload: JSON!) {\n webhooks {\n triggerWebhook(id: $id, payload: $payload) {\n data {\n id\n webhookId\n backgroundTaskId\n eventType\n status\n payload\n requestHeaders\n responseTime\n responseStatus\n responseBody\n expiresAt\n createdOn\n }\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, { id, payload });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.webhooks.triggerWebhook.error) {\n return Result.fail(\n new ApiError(\n responseData.webhooks.triggerWebhook.error.message,\n responseData.webhooks.triggerWebhook.error.code\n )\n );\n }\n\n return Result.ok(responseData.webhooks.triggerWebhook.data as WebhookDelivery);\n }\n);\n"],"names":["triggerWebhook","createMethod","triggerWebhookSchema","config","fetchFn","id","payload","query","result","executeGraphQL","Result","responseData","ApiError"],"mappings":";;;;;AAYO,MAAMA,iBAAiBC,aAC1BC,sBACA,OAAOC,QAAQC,SAAS,EAAEC,EAAE,EAAEC,OAAO,EAAE;IACnC,MAAMC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;IAyBnB,CAAC;IAEG,MAAMC,SAAS,MAAMC,eAAeN,QAAQC,SAASG,OAAO;QAAEF;QAAIC;IAAQ;IAE1E,IAAIE,OAAO,MAAM,IACb,OAAOE,OAAO,IAAI,CAACF,OAAO,KAAK;IAGnC,MAAMG,eAAeH,OAAO,KAAK;IAEjC,IAAIG,aAAa,QAAQ,CAAC,cAAc,CAAC,KAAK,EAC1C,OAAOD,OAAO,IAAI,CACd,IAAIE,SACAD,aAAa,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,OAAO,EAClDA,aAAa,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI;IAK3D,OAAOD,OAAO,EAAE,CAACC,aAAa,QAAQ,CAAC,cAAc,CAAC,IAAI;AAC9D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Result } from "../../Result.js";
|
|
2
|
+
import type { Webhook } from "./webhooksTypes.js";
|
|
3
|
+
import { ApiError } from "../../errors.js";
|
|
4
|
+
export interface UpdateWebhookParams {
|
|
5
|
+
id: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
slug?: string;
|
|
8
|
+
endpointUrl?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
enabled?: boolean;
|
|
11
|
+
events?: string[];
|
|
12
|
+
}
|
|
13
|
+
export declare const updateWebhook: (config: import("../../types.js").WebinyConfig, fetchFn: typeof fetch, params: unknown) => Promise<Result<Webhook, import("../../errors.js").HttpError | ApiError | import("../../errors.js").NetworkError | import("../../errors.js").ValidationError>>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Result } from "../../Result.js";
|
|
2
|
+
import { createMethod } from "../../utils/createMethod.js";
|
|
3
|
+
import { updateWebhookSchema } from "./schemas.js";
|
|
4
|
+
import { executeGraphQL } from "../executeGraphQL.js";
|
|
5
|
+
import { ApiError } from "../../errors.js";
|
|
6
|
+
const updateWebhook = createMethod(updateWebhookSchema, async (config, fetchFn, { id, ...input })=>{
|
|
7
|
+
const query = `
|
|
8
|
+
mutation UpdateWebhook($id: ID!, $input: UpdateWebhookInput!) {
|
|
9
|
+
webhooks {
|
|
10
|
+
updateWebhook(id: $id, input: $input) {
|
|
11
|
+
data {
|
|
12
|
+
id
|
|
13
|
+
name
|
|
14
|
+
slug
|
|
15
|
+
endpointUrl
|
|
16
|
+
description
|
|
17
|
+
enabled
|
|
18
|
+
events
|
|
19
|
+
signingSecret
|
|
20
|
+
createdOn
|
|
21
|
+
modifiedOn
|
|
22
|
+
}
|
|
23
|
+
error {
|
|
24
|
+
message
|
|
25
|
+
code
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
const result = await executeGraphQL(config, fetchFn, query, {
|
|
32
|
+
id,
|
|
33
|
+
input
|
|
34
|
+
});
|
|
35
|
+
if (result.isFail()) return Result.fail(result.error);
|
|
36
|
+
const responseData = result.value;
|
|
37
|
+
if (responseData.webhooks.updateWebhook.error) return Result.fail(new ApiError(responseData.webhooks.updateWebhook.error.message, responseData.webhooks.updateWebhook.error.code));
|
|
38
|
+
return Result.ok(responseData.webhooks.updateWebhook.data);
|
|
39
|
+
});
|
|
40
|
+
export { updateWebhook };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=updateWebhook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"methods/webhooks/updateWebhook.js","sources":["../../../src/methods/webhooks/updateWebhook.ts"],"sourcesContent":["import { Result } from \"../../Result.js\";\nimport type { Webhook } from \"./webhooksTypes.js\";\nimport { createMethod } from \"../../utils/createMethod.js\";\nimport { updateWebhookSchema } from \"./schemas.js\";\nimport { executeGraphQL } from \"../executeGraphQL.js\";\nimport { ApiError } from \"../../errors.js\";\n\nexport interface UpdateWebhookParams {\n id: string;\n name?: string;\n slug?: string;\n endpointUrl?: string;\n description?: string;\n enabled?: boolean;\n events?: string[];\n}\n\nexport const updateWebhook = createMethod(\n updateWebhookSchema,\n async (config, fetchFn, { id, ...input }) => {\n const query = `\n mutation UpdateWebhook($id: ID!, $input: UpdateWebhookInput!) {\n webhooks {\n updateWebhook(id: $id, input: $input) {\n data {\n id\n name\n slug\n endpointUrl\n description\n enabled\n events\n signingSecret\n createdOn\n modifiedOn\n }\n error {\n message\n code\n }\n }\n }\n }\n `;\n\n const result = await executeGraphQL(config, fetchFn, query, { id, input });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const responseData = result.value;\n\n if (responseData.webhooks.updateWebhook.error) {\n return Result.fail(\n new ApiError(\n responseData.webhooks.updateWebhook.error.message,\n responseData.webhooks.updateWebhook.error.code\n )\n );\n }\n\n return Result.ok(responseData.webhooks.updateWebhook.data as Webhook);\n }\n);\n"],"names":["updateWebhook","createMethod","updateWebhookSchema","config","fetchFn","id","input","query","result","executeGraphQL","Result","responseData","ApiError"],"mappings":";;;;;AAiBO,MAAMA,gBAAgBC,aACzBC,qBACA,OAAOC,QAAQC,SAAS,EAAEC,EAAE,EAAE,GAAGC,OAAO;IACpC,MAAMC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;IAuBnB,CAAC;IAEG,MAAMC,SAAS,MAAMC,eAAeN,QAAQC,SAASG,OAAO;QAAEF;QAAIC;IAAM;IAExE,IAAIE,OAAO,MAAM,IACb,OAAOE,OAAO,IAAI,CAACF,OAAO,KAAK;IAGnC,MAAMG,eAAeH,OAAO,KAAK;IAEjC,IAAIG,aAAa,QAAQ,CAAC,aAAa,CAAC,KAAK,EACzC,OAAOD,OAAO,IAAI,CACd,IAAIE,SACAD,aAAa,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,OAAO,EACjDA,aAAa,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI;IAK1D,OAAOD,OAAO,EAAE,CAACC,aAAa,QAAQ,CAAC,aAAa,CAAC,IAAI;AAC7D"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface Webhook {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
slug: string;
|
|
5
|
+
endpointUrl: string;
|
|
6
|
+
description: string | null;
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
events: string[];
|
|
9
|
+
signingSecret: string;
|
|
10
|
+
createdOn: string | null;
|
|
11
|
+
modifiedOn: string | null;
|
|
12
|
+
}
|
|
13
|
+
export interface WebhookDelivery {
|
|
14
|
+
id: string;
|
|
15
|
+
webhookId: string;
|
|
16
|
+
backgroundTaskId: string | null;
|
|
17
|
+
eventType: string;
|
|
18
|
+
status: string;
|
|
19
|
+
payload: unknown;
|
|
20
|
+
requestHeaders: unknown;
|
|
21
|
+
responseTime: number | null;
|
|
22
|
+
responseStatus: number | null;
|
|
23
|
+
responseBody: string | null;
|
|
24
|
+
expiresAt: string | null;
|
|
25
|
+
createdOn: string | null;
|
|
26
|
+
}
|
|
27
|
+
export interface WebhookEvent {
|
|
28
|
+
app: string;
|
|
29
|
+
entity: string;
|
|
30
|
+
eventName: string;
|
|
31
|
+
label: string;
|
|
32
|
+
}
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/sdk",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.0-beta.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,18 +12,18 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"p-map": "7.0.4",
|
|
14
14
|
"p-retry": "8.0.0",
|
|
15
|
-
"zod": "4.3
|
|
15
|
+
"zod": "4.4.3"
|
|
16
16
|
},
|
|
17
17
|
"author": "Webiny",
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@webiny/build-tools": "6.
|
|
20
|
+
"@webiny/build-tools": "6.4.0-beta.1",
|
|
21
21
|
"typescript": "6.0.3",
|
|
22
|
-
"vitest": "4.1.
|
|
22
|
+
"vitest": "4.1.6"
|
|
23
23
|
},
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"access": "public",
|
|
26
26
|
"directory": "dist"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "73237b8243693038c072bae1c0b783387448cbbe"
|
|
29
29
|
}
|
package/types.js
CHANGED
package/utils/createMethod.js
CHANGED
|
@@ -1,27 +1,9 @@
|
|
|
1
1
|
import { parseParams } from "./validateParams.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* The handler receives the already-validated params object. Runtime type safety is
|
|
9
|
-
* guaranteed by the Zod schema; TypeScript inference covers TResult and TError from
|
|
10
|
-
* the handler's return type.
|
|
11
|
-
*
|
|
12
|
-
* Use this for methods whose params can be fully described by a Zod schema (scalars,
|
|
13
|
-
* plain objects, arrays of primitives). Do NOT use it for methods whose params include
|
|
14
|
-
* runtime-only types that Zod cannot validate — e.g. File, Buffer, Blob, AbortSignal,
|
|
15
|
-
* callback functions. Those methods stay as plain async functions.
|
|
16
|
-
*/
|
|
17
|
-
export const createMethod = (schema, handler) => {
|
|
18
|
-
return (config, fetchFn, params) => {
|
|
19
|
-
const parsed = parseParams(schema, params);
|
|
20
|
-
if (!parsed.ok) {
|
|
21
|
-
return Promise.resolve(parsed.result);
|
|
22
|
-
}
|
|
23
|
-
return handler(config, fetchFn, parsed.data);
|
|
24
|
-
};
|
|
25
|
-
};
|
|
2
|
+
const createMethod = (schema, handler)=>(config, fetchFn, params)=>{
|
|
3
|
+
const parsed = parseParams(schema, params);
|
|
4
|
+
if (!parsed.ok) return Promise.resolve(parsed.result);
|
|
5
|
+
return handler(config, fetchFn, parsed.data);
|
|
6
|
+
};
|
|
7
|
+
export { createMethod };
|
|
26
8
|
|
|
27
9
|
//# sourceMappingURL=createMethod.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/createMethod.js","sources":["../../src/utils/createMethod.ts"],"sourcesContent":["import type { ZodType } from \"zod\";\nimport type { WebinyConfig } from \"../types.js\";\nimport type { Result } from \"../Result.js\";\nimport type { ValidationError } from \"../errors.js\";\nimport { parseParams } from \"./validateParams.js\";\n\n/**\n * Creates an SDK method that validates params against a Zod schema before running\n * the handler. If validation fails a ValidationError is returned immediately, with\n * no network request made.\n *\n * The handler receives the already-validated params object. Runtime type safety is\n * guaranteed by the Zod schema; TypeScript inference covers TResult and TError from\n * the handler's return type.\n *\n * Use this for methods whose params can be fully described by a Zod schema (scalars,\n * plain objects, arrays of primitives). Do NOT use it for methods whose params include\n * runtime-only types that Zod cannot validate — e.g. File, Buffer, Blob, AbortSignal,\n * callback functions. Those methods stay as plain async functions.\n */\nexport const createMethod = <TResult, TError>(\n schema: ZodType,\n handler: (\n config: WebinyConfig,\n fetchFn: typeof fetch,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n params: any\n ) => Promise<Result<TResult, TError>>\n): ((\n config: WebinyConfig,\n fetchFn: typeof fetch,\n params: unknown\n) => Promise<Result<TResult, TError | ValidationError>>) => {\n return (config, fetchFn, params) => {\n const parsed = parseParams(schema, params);\n if (!parsed.ok) {\n return Promise.resolve(parsed.result);\n }\n return handler(config, fetchFn, parsed.data) as Promise<\n Result<TResult, TError | ValidationError>\n >;\n };\n};\n"],"names":["createMethod","schema","handler","config","fetchFn","params","parsed","parseParams","Promise"],"mappings":";AAoBO,MAAMA,eAAe,CACxBC,QACAC,UAWO,CAACC,QAAQC,SAASC;QACrB,MAAMC,SAASC,YAAYN,QAAQI;QACnC,IAAI,CAACC,OAAO,EAAE,EACV,OAAOE,QAAQ,OAAO,CAACF,OAAO,MAAM;QAExC,OAAOJ,QAAQC,QAAQC,SAASE,OAAO,IAAI;IAG/C"}
|
package/utils/platform.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const isBrowser = "u" > typeof window;
|
|
2
|
+
const isNode = "u" > typeof process && !isBrowser;
|
|
3
|
+
export { isBrowser, isNode };
|
|
3
4
|
|
|
4
5
|
//# sourceMappingURL=platform.js.map
|
package/utils/platform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/platform.js","sources":["../../src/utils/platform.ts"],"sourcesContent":["export const isBrowser = typeof window !== \"undefined\";\nexport const isNode = typeof process !== \"undefined\" && !isBrowser;\n"],"names":["isBrowser","window","isNode","process"],"mappings":"AAAO,MAAMA,YAAY,AAAkB,MAAlB,OAAOC;AACzB,MAAMC,SAAS,AAAmB,MAAnB,OAAOC,WAA2B,CAACH"}
|
|
@@ -1,36 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export const transformFieldErrors = (message, fields) => {
|
|
14
|
-
let result = message;
|
|
15
|
-
|
|
16
|
-
// "Cannot query field "X" on type "Y"." — field does not exist in the selection
|
|
17
|
-
result = result.replace(/Cannot query field "([^"]+)" on type [^.]+\./g, (_match, fieldName) => {
|
|
18
|
-
const fullPath = fields.find(f => f.split(".").includes(fieldName));
|
|
19
|
-
return fullPath ? `Unknown field: "${fullPath}" — "${fieldName}" does not exist.` : _match;
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
// 'Field "X" of type "Y" must have a selection of subfields.' — object used as a leaf
|
|
23
|
-
result = result.replace(/Field "([^"]+)" of type "[^"]+" must have a selection of subfields[^.]*\./g, (_match, fieldName) => {
|
|
24
|
-
const fullPath = fields.find(f => f.split(".").includes(fieldName));
|
|
25
|
-
return fullPath ? `Field "${fullPath}" is an object type and requires sub-field selection.` : _match;
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
// 'Variable "$where" got invalid value ... Field "X" is not defined by type "Y".' — unknown where filter key or operator
|
|
29
|
-
result = result.replace(/Variable "\$where" got invalid value.*?Field "([^"]+)" is not defined by type "[^"]+"\./gs, (_match, fieldName) => `Unknown filter field: "${fieldName}".`);
|
|
30
|
-
return result;
|
|
1
|
+
const transformFieldErrors = (message, fields)=>{
|
|
2
|
+
let result = message;
|
|
3
|
+
result = result.replace(/Cannot query field "([^"]+)" on type [^.]+\./g, (_match, fieldName)=>{
|
|
4
|
+
const fullPath = fields.find((f)=>f.split(".").includes(fieldName));
|
|
5
|
+
return fullPath ? `Unknown field: "${fullPath}" — "${fieldName}" does not exist.` : _match;
|
|
6
|
+
});
|
|
7
|
+
result = result.replace(/Field "([^"]+)" of type "[^"]+" must have a selection of subfields[^.]*\./g, (_match, fieldName)=>{
|
|
8
|
+
const fullPath = fields.find((f)=>f.split(".").includes(fieldName));
|
|
9
|
+
return fullPath ? `Field "${fullPath}" is an object type and requires sub-field selection.` : _match;
|
|
10
|
+
});
|
|
11
|
+
result = result.replace(/Variable "\$where" got invalid value.*?Field "([^"]+)" is not defined by type "[^"]+"\./gs, (_match, fieldName)=>`Unknown filter field: "${fieldName}".`);
|
|
12
|
+
return result;
|
|
31
13
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
export const transformFieldError = (message, fields) => transformFieldErrors(message, fields);
|
|
14
|
+
const transformFieldError = (message, fields)=>transformFieldErrors(message, fields);
|
|
15
|
+
export { transformFieldError, transformFieldErrors };
|
|
35
16
|
|
|
36
17
|
//# sourceMappingURL=transformFieldErrors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/transformFieldErrors.js","sources":["../../src/utils/transformFieldErrors.ts"],"sourcesContent":["/**\n * Transforms GraphQL field-selection and where-variable error messages into\n * user-friendly equivalents that avoid exposing internal GraphQL type names\n * (e.g. \"FmFile\", \"FmFileListWhereInput\").\n *\n * Uses global regex replaces rather than string splitting so that error messages\n * containing \"; \" internally (e.g. where-variable errors) are handled correctly\n * alongside multiple errors that are joined with \"; \".\n *\n * The regex patterns target error message formats defined by the GraphQL\n * specification, so they are stable across spec-compliant server implementations.\n */\nexport const transformFieldErrors = (message: string, fields: string[]): string => {\n let result = message;\n\n // \"Cannot query field \"X\" on type \"Y\".\" — field does not exist in the selection\n result = result.replace(\n /Cannot query field \"([^\"]+)\" on type [^.]+\\./g,\n (_match, fieldName) => {\n const fullPath = fields.find(f => f.split(\".\").includes(fieldName));\n return fullPath\n ? `Unknown field: \"${fullPath}\" — \"${fieldName}\" does not exist.`\n : _match;\n }\n );\n\n // 'Field \"X\" of type \"Y\" must have a selection of subfields.' — object used as a leaf\n result = result.replace(\n /Field \"([^\"]+)\" of type \"[^\"]+\" must have a selection of subfields[^.]*\\./g,\n (_match, fieldName) => {\n const fullPath = fields.find(f => f.split(\".\").includes(fieldName));\n return fullPath\n ? `Field \"${fullPath}\" is an object type and requires sub-field selection.`\n : _match;\n }\n );\n\n // 'Variable \"$where\" got invalid value ... Field \"X\" is not defined by type \"Y\".' — unknown where filter key or operator\n result = result.replace(\n /Variable \"\\$where\" got invalid value.*?Field \"([^\"]+)\" is not defined by type \"[^\"]+\"\\./gs,\n (_match, fieldName) => `Unknown filter field: \"${fieldName}\".`\n );\n\n return result;\n};\n\n/** Single-message variant used by FileManager methods. */\nexport const transformFieldError = (message: string, fields: string[]): string =>\n transformFieldErrors(message, fields);\n"],"names":["transformFieldErrors","message","fields","result","_match","fieldName","fullPath","f","transformFieldError"],"mappings":"AAYO,MAAMA,uBAAuB,CAACC,SAAiBC;IAClD,IAAIC,SAASF;IAGbE,SAASA,OAAO,OAAO,CACnB,iDACA,CAACC,QAAQC;QACL,MAAMC,WAAWJ,OAAO,IAAI,CAACK,CAAAA,IAAKA,EAAE,KAAK,CAAC,KAAK,QAAQ,CAACF;QACxD,OAAOC,WACD,CAAC,gBAAgB,EAAEA,SAAS,KAAK,EAAED,UAAU,iBAAiB,CAAC,GAC/DD;IACV;IAIJD,SAASA,OAAO,OAAO,CACnB,8EACA,CAACC,QAAQC;QACL,MAAMC,WAAWJ,OAAO,IAAI,CAACK,CAAAA,IAAKA,EAAE,KAAK,CAAC,KAAK,QAAQ,CAACF;QACxD,OAAOC,WACD,CAAC,OAAO,EAAEA,SAAS,qDAAqD,CAAC,GACzEF;IACV;IAIJD,SAASA,OAAO,OAAO,CACnB,6FACA,CAACC,QAAQC,YAAc,CAAC,uBAAuB,EAAEA,UAAU,EAAE,CAAC;IAGlE,OAAOF;AACX;AAGO,MAAMK,sBAAsB,CAACP,SAAiBC,SACjDF,qBAAqBC,SAASC"}
|
package/utils/validateParams.js
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
import { Result } from "../Result.js";
|
|
2
2
|
import { ValidationError } from "../errors.js";
|
|
3
|
-
const formatZodError = error
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
const formatZodError = (error)=>error.issues.map((issue)=>{
|
|
4
|
+
const path = issue.path.join(".");
|
|
5
|
+
return path ? `"${path}": ${issue.message}` : issue.message;
|
|
6
|
+
}).join("; ");
|
|
7
|
+
const parseParams = (schema, params)=>{
|
|
8
|
+
const parsed = schema.safeParse(params);
|
|
9
|
+
if (!parsed.success) return {
|
|
10
|
+
ok: false,
|
|
11
|
+
result: Result.fail(new ValidationError(formatZodError(parsed.error)))
|
|
12
|
+
};
|
|
12
13
|
return {
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
ok: true,
|
|
15
|
+
data: parsed.data
|
|
15
16
|
};
|
|
16
|
-
}
|
|
17
|
-
return {
|
|
18
|
-
ok: true,
|
|
19
|
-
data: parsed.data
|
|
20
|
-
};
|
|
21
17
|
};
|
|
18
|
+
export { parseParams };
|
|
22
19
|
|
|
23
20
|
//# sourceMappingURL=validateParams.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/validateParams.js","sources":["../../src/utils/validateParams.ts"],"sourcesContent":["import type { ZodType, ZodError } from \"zod\";\nimport { Result } from \"../Result.js\";\nimport { ValidationError } from \"../errors.js\";\n\nconst formatZodError = (error: ZodError): string => {\n return error.issues\n .map(issue => {\n const path = issue.path.join(\".\");\n return path ? `\"${path}\": ${issue.message}` : issue.message;\n })\n .join(\"; \");\n};\n\nexport const parseParams = <T>(\n schema: ZodType<T>,\n params: unknown\n):\n | { ok: true; data: T }\n | { ok: false; result: ReturnType<typeof Result.fail<ValidationError>> } => {\n const parsed = schema.safeParse(params);\n if (!parsed.success) {\n return {\n ok: false,\n result: Result.fail(new ValidationError(formatZodError(parsed.error)))\n };\n }\n return { ok: true, data: parsed.data };\n};\n"],"names":["formatZodError","error","issue","path","parseParams","schema","params","parsed","Result","ValidationError"],"mappings":";;AAIA,MAAMA,iBAAiB,CAACC,QACbA,MAAM,MAAM,CACd,GAAG,CAACC,CAAAA;QACD,MAAMC,OAAOD,MAAM,IAAI,CAAC,IAAI,CAAC;QAC7B,OAAOC,OAAO,CAAC,CAAC,EAAEA,KAAK,GAAG,EAAED,MAAM,OAAO,EAAE,GAAGA,MAAM,OAAO;IAC/D,GACC,IAAI,CAAC;AAGP,MAAME,cAAc,CACvBC,QACAC;IAIA,MAAMC,SAASF,OAAO,SAAS,CAACC;IAChC,IAAI,CAACC,OAAO,OAAO,EACf,OAAO;QACH,IAAI;QACJ,QAAQC,OAAO,IAAI,CAAC,IAAIC,gBAAgBT,eAAeO,OAAO,KAAK;IACvE;IAEJ,OAAO;QAAE,IAAI;QAAM,MAAMA,OAAO,IAAI;IAAC;AACzC"}
|
package/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Result","HttpError","ApiError","NetworkError","ValidationError"],"sources":["index.ts"],"sourcesContent":["export * from \"./Webiny.js\";\nexport * from \"./CmsSdk.js\";\nexport * from \"./TenantManagerSdk.js\";\nexport * from \"./FileManagerSdk.js\";\nexport * from \"./LanguagesSdk.js\";\nexport * from \"./TasksSdk.js\";\nexport * from \"./types.js\";\nexport { Result } from \"./Result.js\";\nexport { HttpError, ApiError, NetworkError, ValidationError } from \"./errors.js\";\n\n// Export shared CMS types.\nexport type {\n CmsEntryValues,\n CmsEntryStatus,\n CmsIdentity,\n IEntryState,\n CmsEntryData\n} from \"./methods/cms/cmsTypes.js\";\n\n// Export types from methods.\nexport type { CreateCmsEntryData, CreateEntryParams } from \"./methods/cms/createEntry.js\";\n\nexport type {\n UpdateCmsEntryData,\n UpdateEntryRevisionParams\n} from \"./methods/cms/updateEntryRevision.js\";\n\nexport type { GetEntryParams, GetEntryWhere } from \"./methods/cms/getEntry.js\";\n\nexport type { ListEntriesParams, ListEntriesResult } from \"./methods/cms/listEntries.js\";\n\nexport type { DeleteEntryRevisionParams } from \"./methods/cms/deleteEntryRevision.js\";\n\nexport type { PublishEntryRevisionParams } from \"./methods/cms/publishEntryRevision.js\";\n\nexport type { UnpublishEntryRevisionParams } from \"./methods/cms/unpublishEntryRevision.js\";\n\n// Export TenantManager types.\nexport type { CreateTenantInput } from \"./methods/tenantManager/tenantManagerTypes.js\";\n\n// Export types from tenantManager methods.\nexport type { CreateTenantParams } from \"./methods/tenantManager/createTenant.js\";\n\nexport type { InstallTenantParams } from \"./methods/tenantManager/installTenant.js\";\n\nexport type { DisableTenantParams } from \"./methods/tenantManager/disableTenant.js\";\n\nexport type { EnableTenantParams } from \"./methods/tenantManager/enableTenant.js\";\n\n// Export FileManager types.\nexport type {\n FmIdentity,\n FmLocation,\n FmFile,\n FmTag,\n FmListMeta,\n FmLocationInput,\n FmLocationWhereInput,\n FmFileListWhereInput,\n FmFileListSorter,\n FmTagsListWhereInput,\n UploadProgress,\n PresignedPostPayload,\n PresignedPostPayloadResponse,\n BatchUploadStrategy\n} from \"./methods/fileManager/fileManagerTypes.js\";\n\n// Export types from fileManager methods.\nexport type { GetFileParams } from \"./methods/fileManager/getFile.js\";\n\nexport type { ListFilesParams, ListFilesResult } from \"./methods/fileManager/listFiles.js\";\n\nexport type { CreateFileData, CreateFileParams } from \"./methods/fileManager/createFile.js\";\n\nexport type { CreateFilesParams, CreateFilesResult } from \"./methods/fileManager/createFiles.js\";\n\nexport type { UpdateFileData, UpdateFileParams } from \"./methods/fileManager/updateFile.js\";\n\nexport type { DeleteFileParams } from \"./methods/fileManager/deleteFile.js\";\n\nexport type { ListTagsParams } from \"./methods/fileManager/listTags.js\";\n\nexport type { GetPresignedPostPayloadParams } from \"./methods/fileManager/getPresignedPostPayload.js\";\n\nexport type { GetPresignedPostPayloadsParams } from \"./methods/fileManager/getPresignedPostPayloads.js\";\n\nexport type {\n CreateMultiPartUploadParams,\n MultiPartUploadResponse\n} from \"./methods/fileManager/createMultiPartUpload.js\";\n\nexport type { CompleteMultiPartUploadParams } from \"./methods/fileManager/completeMultiPartUpload.js\";\n\n// Export Languages types.\nexport type { Language } from \"./methods/languages/listLanguages.js\";\n\n// Export Tasks types.\nexport type {\n TaskStatus,\n TaskDefinition,\n TaskRun,\n TaskLog,\n TaskLogItem\n} from \"./methods/tasks/taskTypes.js\";\n\n// Export types from tasks methods.\nexport type { ListLogsParams } from \"./methods/tasks/listLogs.js\";\n\nexport type { TriggerTaskParams } from \"./methods/tasks/triggerTask.js\";\n\nexport type { AbortTaskParams } from \"./methods/tasks/abortTask.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,MAAM;AACf,SAASC,SAAS,EAAEC,QAAQ,EAAEC,YAAY,EAAEC,eAAe;;AAE3D;;AASA;;AAkBA;;AAGA;;AASA;;AAkBA;;AA0BA;;AAGA;;AASA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["cmsTypes.ts"],"sourcesContent":["/**\n * Entry values type.\n */\nexport interface CmsEntryValues {\n [key: string]: any;\n}\n\n/**\n * Entry status type.\n */\nexport type CmsEntryStatus = \"published\" | \"unpublished\" | \"draft\";\n\n/**\n * CMS identity.\n */\nexport interface CmsIdentity {\n /**\n * ID of the user.\n */\n id: string;\n /**\n * Full name of the user.\n */\n displayName: string;\n /**\n * Type of the user (admin, user).\n */\n type: string;\n}\n\n/**\n * Entry state.\n */\nexport interface IEntryState {\n state: string;\n workflowId: string;\n stepId: string;\n stepName: string;\n}\n\n/**\n * CMS entry data returned from queries.\n */\nexport interface CmsEntryData<TValues extends CmsEntryValues = CmsEntryValues> {\n id?: string;\n entryId?: string;\n status?: CmsEntryStatus;\n\n /**\n * Entry meta object, accessible when requested via the \"meta.*\" field prefix\n * (e.g. fields: [\"meta.status\", \"meta.version\"]).\n * Corresponds to the ${ModelName}Meta GraphQL type on the Manage API.\n */\n meta: {\n status: CmsEntryStatus;\n modelId: string;\n version: number;\n locked: boolean;\n title: string;\n description: string;\n image: string;\n /** Advanced Publishing Workflow data. */\n data: Record<string, unknown>;\n };\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;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["taskTypes.ts"],"sourcesContent":["export type TaskStatus = \"pending\" | \"running\" | \"completed\" | \"failed\" | \"aborted\" | \"stopped\";\n\nexport interface TaskDefinition {\n id: string;\n title: string;\n description?: string;\n}\n\nexport interface TaskRun {\n id: string;\n startedOn?: string;\n finishedOn?: string;\n name?: string;\n definitionId: string;\n iterations?: number;\n parentId?: string;\n executionName?: string;\n eventResponse?: unknown;\n taskStatus: TaskStatus;\n input?: unknown;\n output?: unknown;\n}\n\nexport interface TaskLogItem {\n message: string;\n createdOn: string;\n type: string;\n data?: unknown;\n error?: unknown;\n}\n\nexport interface TaskLog {\n id: string;\n createdOn: string;\n executionName?: string;\n iteration?: number;\n items: TaskLogItem[];\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["tenantManagerTypes.ts"],"sourcesContent":["export interface CreateTenantInput {\n id?: string;\n name: string;\n description?: string;\n}\n"],"mappings":"","ignoreList":[]}
|
package/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["export type TokenProvider = string | (() => string | Promise<string>);\n\nexport interface WebinyConfig {\n token?: TokenProvider;\n endpoint: string;\n tenant?: string;\n headers?: Record<string, string>;\n fetch?: typeof fetch;\n}\n"],"mappings":"","ignoreList":[]}
|