@automate.ax/integration-contracts 0.144.2 → 0.145.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/dist/calcom/api.d.ts +90 -0
- package/dist/calcom/api.js +210 -0
- package/dist/calcom/events.d.ts +822 -0
- package/dist/calcom/events.js +414 -0
- package/dist/calcom/index.d.ts +4 -0
- package/dist/calcom/index.js +3 -0
- package/dist/calcom/openapi-schemas.generated.json +12129 -0
- package/dist/calcom/openapi-types.generated.d.ts +8374 -0
- package/dist/calcom/openapi-types.generated.js +1 -0
- package/dist/calcom/schemas.d.ts +27 -0
- package/dist/calcom/schemas.js +32 -0
- package/dist/close/events.d.ts +7 -7
- package/dist/close/schemas.d.ts +4 -4
- package/dist/google-calendar/event-schemas.d.ts +4 -4
- package/dist/google-calendar/index.d.ts +6 -6
- package/dist/google-calendar/schemas.d.ts +6 -6
- package/dist/google-forms/event-schemas.d.ts +1 -1
- package/dist/google-forms/google-forms.d.ts +2 -2
- package/dist/google-forms/index.d.ts +1 -1
- package/dist/google-forms/schemas.d.ts +5 -5
- package/dist/triggers.d.ts +2 -1
- package/package.json +9 -2
- package/src/calcom/api.ts +289 -0
- package/src/calcom/events.ts +502 -0
- package/src/calcom/index.ts +4 -0
- package/src/calcom/openapi-schemas.generated.json +12129 -0
- package/src/calcom/openapi-types.generated.ts +9436 -0
- package/src/calcom/schemas.ts +75 -0
- package/src/triggers.ts +2 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/* oxlint-disable typescript/no-unsafe-type-assertion -- Generated schema names index a frozen external contract. */
|
|
2
|
+
import { Validator } from "@cfworker/json-schema"
|
|
3
|
+
import type { Encodable } from "@automate.ax/codec"
|
|
4
|
+
import * as z from "zod"
|
|
5
|
+
import schemaData from "./openapi-schemas.generated.json" with { type: "json" }
|
|
6
|
+
import type { components } from "./openapi-types.generated"
|
|
7
|
+
|
|
8
|
+
type OpenApiSchemas = components["schemas"]
|
|
9
|
+
|
|
10
|
+
export type CalcomSchemaName = keyof OpenApiSchemas
|
|
11
|
+
|
|
12
|
+
type CalcomEncodable<TValue> = unknown extends TValue
|
|
13
|
+
? Encodable
|
|
14
|
+
: TValue extends null | undefined | boolean | number | string
|
|
15
|
+
? TValue
|
|
16
|
+
: TValue extends readonly (infer TItem)[]
|
|
17
|
+
? CalcomEncodable<TItem>[]
|
|
18
|
+
: TValue extends object
|
|
19
|
+
? keyof TValue extends never
|
|
20
|
+
? Record<string, Encodable>
|
|
21
|
+
: { [TKey in keyof TValue]: CalcomEncodable<TValue[TKey]> }
|
|
22
|
+
: never
|
|
23
|
+
|
|
24
|
+
/** Public JSON-safe value for one generated Cal.com component schema. */
|
|
25
|
+
export type CalcomSchemaValue<TName extends CalcomSchemaName> = CalcomEncodable<
|
|
26
|
+
OpenApiSchemas[TName]
|
|
27
|
+
>
|
|
28
|
+
|
|
29
|
+
/** Data carried by one successful Cal.com response envelope. */
|
|
30
|
+
export type CalcomResponseData<TName extends CalcomSchemaName> =
|
|
31
|
+
CalcomSchemaValue<TName> extends { data: infer TData } ? TData : never
|
|
32
|
+
|
|
33
|
+
const VALIDATOR = new Validator(
|
|
34
|
+
{
|
|
35
|
+
$defs: schemaData.definitions,
|
|
36
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
37
|
+
additionalProperties: false,
|
|
38
|
+
maxProperties: 1,
|
|
39
|
+
minProperties: 1,
|
|
40
|
+
properties: Object.fromEntries(
|
|
41
|
+
Object.keys(schemaData.definitions).map((name) => [
|
|
42
|
+
name,
|
|
43
|
+
{ $ref: `#/$defs/${name}` },
|
|
44
|
+
]),
|
|
45
|
+
),
|
|
46
|
+
type: "object",
|
|
47
|
+
},
|
|
48
|
+
"2020-12",
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Validates one value against a frozen Cal.com OpenAPI component schema.
|
|
53
|
+
*
|
|
54
|
+
* @param name OpenAPI component schema name.
|
|
55
|
+
*/
|
|
56
|
+
export function calcomSchema<TName extends CalcomSchemaName>(
|
|
57
|
+
name: TName,
|
|
58
|
+
): z.ZodType<CalcomSchemaValue<TName>> {
|
|
59
|
+
return z.custom<CalcomSchemaValue<TName>>(
|
|
60
|
+
(value) => VALIDATOR.validate({ [name]: value }).valid,
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Validates data after it has been removed from a Cal.com success envelope.
|
|
66
|
+
*
|
|
67
|
+
* @param name OpenAPI success-envelope component schema name.
|
|
68
|
+
*/
|
|
69
|
+
export function calcomResponseDataSchema<TName extends CalcomSchemaName>(
|
|
70
|
+
name: TName,
|
|
71
|
+
): z.ZodType<CalcomResponseData<TName>> {
|
|
72
|
+
return z.custom<CalcomResponseData<TName>>(
|
|
73
|
+
(data) => VALIDATOR.validate({ [name]: { data, status: "success" } }).valid,
|
|
74
|
+
)
|
|
75
|
+
}
|
package/src/triggers.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { axiomTriggerContracts } from "./axiom"
|
|
|
5
5
|
import type { automateTriggerContracts } from "./automate"
|
|
6
6
|
import type { asanaTriggerContracts } from "./asana"
|
|
7
7
|
import type { brevoTriggerContracts } from "./brevo"
|
|
8
|
+
import type { calcomTriggerContracts } from "./calcom"
|
|
8
9
|
import type { convexTriggerContracts } from "./convex"
|
|
9
10
|
import type { discordTriggerContracts } from "./discord"
|
|
10
11
|
import type { closeTriggerContracts } from "./close"
|
|
@@ -43,6 +44,7 @@ export type TriggerContractMap = typeof airtableTriggerContracts &
|
|
|
43
44
|
typeof automateTriggerContracts &
|
|
44
45
|
typeof asanaTriggerContracts &
|
|
45
46
|
typeof brevoTriggerContracts &
|
|
47
|
+
typeof calcomTriggerContracts &
|
|
46
48
|
typeof convexTriggerContracts &
|
|
47
49
|
typeof discordTriggerContracts &
|
|
48
50
|
typeof closeTriggerContracts &
|