@automate.ax/integration-contracts 0.145.2 → 0.146.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/highlevel/api.d.ts +43 -0
- package/dist/highlevel/api.js +236 -0
- package/dist/highlevel/events.d.ts +1148 -0
- package/dist/highlevel/events.js +303 -0
- package/dist/highlevel/index.d.ts +6 -0
- package/dist/highlevel/index.js +4 -0
- package/dist/highlevel/openapi-operations.generated.json +10122 -0
- package/dist/highlevel/openapi-types.generated.d.ts +9158 -0
- package/dist/highlevel/openapi-types.generated.js +1 -0
- package/dist/highlevel/operation-manifest.d.ts +608 -0
- package/dist/highlevel/operation-manifest.js +98 -0
- package/dist/highlevel/schemas.d.ts +41 -0
- package/dist/highlevel/schemas.js +39 -0
- package/dist/highlevel/types.d.ts +41 -0
- package/dist/highlevel/types.js +1 -0
- package/dist/resend/action-schemas.d.ts +2 -2
- package/dist/triggers.d.ts +2 -1
- package/package.json +9 -2
- package/src/highlevel/api.ts +294 -0
- package/src/highlevel/events.ts +355 -0
- package/src/highlevel/index.ts +6 -0
- package/src/highlevel/openapi-operations.generated.json +10122 -0
- package/src/highlevel/openapi-types.generated.ts +9928 -0
- package/src/highlevel/operation-manifest.ts +740 -0
- package/src/highlevel/schemas.ts +85 -0
- package/src/highlevel/types.ts +91 -0
- package/src/triggers.ts +2 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/* oxlint-disable typescript/no-unsafe-type-assertion -- Generated operation keys index a frozen external contract. */
|
|
2
|
+
import { Validator } from "@cfworker/json-schema"
|
|
3
|
+
import * as z from "zod"
|
|
4
|
+
import operationData from "./openapi-operations.generated.json" with { type: "json" }
|
|
5
|
+
import type { HighLevelOperationKey } from "./operation-manifest"
|
|
6
|
+
import type { HighLevelOperationInput, HighLevelOperationOutput } from "./types"
|
|
7
|
+
|
|
8
|
+
interface HighLevelRuntimeOperation {
|
|
9
|
+
apiVersion: string
|
|
10
|
+
bodyParameters: string[]
|
|
11
|
+
inputSchema: Record<string, unknown>
|
|
12
|
+
locationPlacements: ("body" | "path" | "query")[]
|
|
13
|
+
locationParameterNames: Partial<Record<"body" | "path" | "query", string>>
|
|
14
|
+
method: "DELETE" | "GET" | "PATCH" | "POST" | "PUT"
|
|
15
|
+
outputSchema: Record<string, unknown>
|
|
16
|
+
path: string
|
|
17
|
+
pathParameters: string[]
|
|
18
|
+
queryParameters: {
|
|
19
|
+
explode: boolean
|
|
20
|
+
name: string
|
|
21
|
+
providerName: string
|
|
22
|
+
style: string
|
|
23
|
+
}[]
|
|
24
|
+
responseMode: "binary" | "json"
|
|
25
|
+
requiredScope: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const OPERATIONS = operationData.operations as unknown as Record<
|
|
29
|
+
HighLevelOperationKey,
|
|
30
|
+
HighLevelRuntimeOperation
|
|
31
|
+
>
|
|
32
|
+
const VALIDATOR = new Validator(
|
|
33
|
+
{
|
|
34
|
+
$defs: operationData.definitions,
|
|
35
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
36
|
+
additionalProperties: false,
|
|
37
|
+
properties: Object.fromEntries(
|
|
38
|
+
Object.entries(OPERATIONS).flatMap(([key, operation]) => [
|
|
39
|
+
[`${key}:input`, operation.inputSchema],
|
|
40
|
+
[`${key}:output`, operation.outputSchema],
|
|
41
|
+
]),
|
|
42
|
+
),
|
|
43
|
+
type: "object",
|
|
44
|
+
},
|
|
45
|
+
"2020-12",
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Returns the immutable runtime descriptor for one HighLevel operation.
|
|
50
|
+
*
|
|
51
|
+
* @param key - Frozen operation key.
|
|
52
|
+
*/
|
|
53
|
+
export function highLevelOperation<TKey extends HighLevelOperationKey>(
|
|
54
|
+
key: TKey,
|
|
55
|
+
) {
|
|
56
|
+
return OPERATIONS[key]
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Validates flattened input for one frozen HighLevel operation.
|
|
61
|
+
*
|
|
62
|
+
* @param key - Frozen operation key.
|
|
63
|
+
*/
|
|
64
|
+
export function highLevelOperationInputSchema<
|
|
65
|
+
TKey extends HighLevelOperationKey,
|
|
66
|
+
>(key: TKey): z.ZodType<HighLevelOperationInput<TKey>> {
|
|
67
|
+
return z.custom<HighLevelOperationInput<TKey>>(
|
|
68
|
+
(value) => VALIDATOR.validate({ [`${key}:input`]: value }).valid,
|
|
69
|
+
{ message: `Input does not match HighLevel operation ${key}.` },
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Validates the documented success response for one HighLevel operation.
|
|
75
|
+
*
|
|
76
|
+
* @param key - Frozen operation key.
|
|
77
|
+
*/
|
|
78
|
+
export function highLevelOperationOutputSchema<
|
|
79
|
+
TKey extends HighLevelOperationKey,
|
|
80
|
+
>(key: TKey): z.ZodType<HighLevelOperationOutput<TKey>> {
|
|
81
|
+
return z.custom<HighLevelOperationOutput<TKey>>(
|
|
82
|
+
(value) => VALIDATOR.validate({ [`${key}:output`]: value }).valid,
|
|
83
|
+
{ message: `Output does not match HighLevel operation ${key}.` },
|
|
84
|
+
)
|
|
85
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { Encodable } from "@automate.ax/codec"
|
|
2
|
+
import type { HighLevelOperationMap } from "./openapi-types.generated"
|
|
3
|
+
import type { HighLevelOperationKey } from "./operation-manifest"
|
|
4
|
+
|
|
5
|
+
type Operation<TKey extends HighLevelOperationKey> =
|
|
6
|
+
TKey extends keyof HighLevelOperationMap ? HighLevelOperationMap[TKey] : never
|
|
7
|
+
|
|
8
|
+
type Parameters<TOperation, TLocation extends string> = TOperation extends {
|
|
9
|
+
parameters: infer TParameters
|
|
10
|
+
}
|
|
11
|
+
? TLocation extends keyof TParameters
|
|
12
|
+
? NonNullable<TParameters[TLocation]>
|
|
13
|
+
: object
|
|
14
|
+
: object
|
|
15
|
+
|
|
16
|
+
/** JSON request body from one generated OpenAPI operation. */
|
|
17
|
+
type JsonBody<TOperation> = TOperation extends { requestBody: infer TBody }
|
|
18
|
+
? NonNullable<TBody> extends { content: infer TContent }
|
|
19
|
+
? "application/json" extends keyof TContent
|
|
20
|
+
? TContent["application/json"]
|
|
21
|
+
: object
|
|
22
|
+
: object
|
|
23
|
+
: object
|
|
24
|
+
|
|
25
|
+
/** JSON payload from one generated response entry. */
|
|
26
|
+
type JsonResponse<TResponse> = TResponse extends { content: infer TContent }
|
|
27
|
+
? "application/json" extends keyof TContent
|
|
28
|
+
? TContent["application/json"]
|
|
29
|
+
: null
|
|
30
|
+
: null
|
|
31
|
+
|
|
32
|
+
/** First supported successful response for one operation. */
|
|
33
|
+
type SuccessResponse<TOperation> = TOperation extends {
|
|
34
|
+
responses: infer TResponses
|
|
35
|
+
}
|
|
36
|
+
? JsonResponse<
|
|
37
|
+
TResponses[Extract<
|
|
38
|
+
keyof TResponses,
|
|
39
|
+
200 | 201 | 202 | 203 | 204 | "default"
|
|
40
|
+
>]
|
|
41
|
+
>
|
|
42
|
+
: never
|
|
43
|
+
|
|
44
|
+
type SnakeToCamel<TValue extends string> =
|
|
45
|
+
TValue extends `${infer THead}_${infer TTail}`
|
|
46
|
+
? `${THead}${Capitalize<SnakeToCamel<TTail>>}`
|
|
47
|
+
: TValue
|
|
48
|
+
|
|
49
|
+
type PublicKeys<TValue> = TValue extends unknown
|
|
50
|
+
? {
|
|
51
|
+
[TKey in keyof TValue as TKey extends string
|
|
52
|
+
? SnakeToCamel<TKey>
|
|
53
|
+
: TKey]: TValue[TKey]
|
|
54
|
+
}
|
|
55
|
+
: never
|
|
56
|
+
|
|
57
|
+
type WithoutLocationId<TValue> = TValue extends unknown
|
|
58
|
+
? Omit<TValue, "locationId" | "location_id">
|
|
59
|
+
: never
|
|
60
|
+
|
|
61
|
+
/** Flattens intersections for public editor display. */
|
|
62
|
+
type Simplify<TValue> = { [TKey in keyof TValue]: TValue[TKey] } & {}
|
|
63
|
+
|
|
64
|
+
type EncodableValue<TValue> = unknown extends TValue
|
|
65
|
+
? Encodable
|
|
66
|
+
: TValue extends undefined | null | boolean | number | string
|
|
67
|
+
? TValue
|
|
68
|
+
: TValue extends readonly (infer TItem)[]
|
|
69
|
+
? EncodableValue<TItem>[]
|
|
70
|
+
: TValue extends object
|
|
71
|
+
? keyof TValue extends never
|
|
72
|
+
? Record<string, Encodable>
|
|
73
|
+
: { [TKey in keyof TValue]: EncodableValue<TValue[TKey]> }
|
|
74
|
+
: never
|
|
75
|
+
|
|
76
|
+
type HighLevelRawOperationInput<TKey extends HighLevelOperationKey> = Simplify<
|
|
77
|
+
PublicKeys<WithoutLocationId<Parameters<Operation<TKey>, "path">>> &
|
|
78
|
+
PublicKeys<WithoutLocationId<Parameters<Operation<TKey>, "query">>> &
|
|
79
|
+
PublicKeys<WithoutLocationId<JsonBody<Operation<TKey>>>>
|
|
80
|
+
>
|
|
81
|
+
|
|
82
|
+
/** Flattened, location-safe input for one frozen HighLevel operation. */
|
|
83
|
+
export type HighLevelOperationInput<TKey extends HighLevelOperationKey> = {
|
|
84
|
+
[TField in keyof HighLevelRawOperationInput<TKey>]: EncodableValue<
|
|
85
|
+
HighLevelRawOperationInput<TKey>[TField]
|
|
86
|
+
>
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Documented successful JSON response for one frozen HighLevel operation. */
|
|
90
|
+
export type HighLevelOperationOutput<TKey extends HighLevelOperationKey> =
|
|
91
|
+
EncodableValue<SuccessResponse<Operation<TKey>>>
|
package/src/triggers.ts
CHANGED
|
@@ -21,6 +21,7 @@ import type { googleMeetTriggerContracts } from "./google-meet"
|
|
|
21
21
|
import type { googleAdsTriggerContracts } from "./google-ads"
|
|
22
22
|
import type { googleSheetsTriggerContracts } from "./google-sheets"
|
|
23
23
|
import type { hubspotTriggerContracts } from "./hubspot"
|
|
24
|
+
import type { highLevelTriggerContracts } from "./highlevel"
|
|
24
25
|
import type { linearTriggerContracts } from "./linear"
|
|
25
26
|
import type { millionVerifierTriggerContracts } from "./millionverifier"
|
|
26
27
|
import type { metaAdsTriggerContracts } from "./meta-ads"
|
|
@@ -60,6 +61,7 @@ export type TriggerContractMap = typeof airtableTriggerContracts &
|
|
|
60
61
|
typeof googleAdsTriggerContracts &
|
|
61
62
|
typeof googleSheetsTriggerContracts &
|
|
62
63
|
typeof hubspotTriggerContracts &
|
|
64
|
+
typeof highLevelTriggerContracts &
|
|
63
65
|
typeof linearTriggerContracts &
|
|
64
66
|
typeof millionVerifierTriggerContracts &
|
|
65
67
|
typeof metaAdsTriggerContracts &
|