@automate.ax/integration-contracts 0.147.0 → 0.148.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.
Files changed (39) hide show
  1. package/dist/close/events.d.ts +4 -4
  2. package/dist/close/schemas.d.ts +6 -6
  3. package/dist/google-drive/index.d.ts +3 -3
  4. package/dist/kit/api.d.ts +78 -0
  5. package/dist/kit/api.js +386 -0
  6. package/dist/kit/events.d.ts +437 -0
  7. package/dist/kit/events.js +285 -0
  8. package/dist/kit/index.d.ts +6 -0
  9. package/dist/kit/index.js +5 -0
  10. package/dist/kit/openapi-operations.generated.d.ts +5 -0
  11. package/dist/kit/openapi-operations.generated.js +5 -0
  12. package/dist/kit/openapi-types.generated.d.ts +9485 -0
  13. package/dist/kit/openapi-types.generated.js +1 -0
  14. package/dist/kit/operation-manifest.d.ts +657 -0
  15. package/dist/kit/operation-manifest.js +98 -0
  16. package/dist/kit/schemas.d.ts +42 -0
  17. package/dist/kit/schemas.js +43 -0
  18. package/dist/kit/types.d.ts +41 -0
  19. package/dist/kit/types.js +1 -0
  20. package/dist/notion/schemas.d.ts +108 -108
  21. package/dist/resend/action-schemas.d.ts +14 -14
  22. package/dist/tally/api.js +5 -2
  23. package/dist/tally/events.d.ts +12 -12
  24. package/dist/tally/openapi-schemas.generated.json +39 -5
  25. package/dist/tally/openapi-types.generated.d.ts +6 -5
  26. package/dist/triggers.d.ts +2 -1
  27. package/package.json +9 -2
  28. package/src/kit/api.ts +523 -0
  29. package/src/kit/events.ts +352 -0
  30. package/src/kit/index.ts +6 -0
  31. package/src/kit/openapi-operations.generated.ts +7 -0
  32. package/src/kit/openapi-types.generated.ts +9710 -0
  33. package/src/kit/operation-manifest.ts +771 -0
  34. package/src/kit/schemas.ts +93 -0
  35. package/src/kit/types.ts +87 -0
  36. package/src/tally/api.ts +4 -2
  37. package/src/tally/openapi-schemas.generated.json +39 -5
  38. package/src/tally/openapi-types.generated.ts +6 -5
  39. package/src/triggers.ts +2 -0
@@ -0,0 +1,93 @@
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 { KIT_OPENAPI_DATA } from "./openapi-operations.generated"
5
+ import type { KitOperationKey } from "./operation-manifest"
6
+ import type { KitOperationInput, KitOperationOutput } from "./types"
7
+
8
+ export interface KitRuntimeParameter {
9
+ explode: boolean
10
+ name: string
11
+ providerName: string
12
+ style: string
13
+ }
14
+
15
+ /** Frozen runtime description of one public Kit operation. */
16
+ export interface KitRuntimeOperation {
17
+ bodyParameters: string[]
18
+ bodyWireSchema?: Record<string, unknown>
19
+ inputSchema: Record<string, unknown>
20
+ method: "DELETE" | "GET" | "PATCH" | "POST" | "PUT"
21
+ outputSchema: Record<string, unknown>
22
+ outputWireSchema: Record<string, unknown>
23
+ path: string
24
+ pathParameters: KitRuntimeParameter[]
25
+ queryParameters: KitRuntimeParameter[]
26
+ responseMode: "json" | "void"
27
+ }
28
+
29
+ /** Runtime Kit contract narrowed once from the opaque generated payload. */
30
+ const operationData = KIT_OPENAPI_DATA as {
31
+ definitions: Record<string, Record<string, unknown>>
32
+ operations: Record<string, unknown>
33
+ wireDefinitions: Record<string, Record<string, unknown>>
34
+ }
35
+ const OPERATIONS = operationData.operations as unknown as Record<
36
+ KitOperationKey,
37
+ KitRuntimeOperation
38
+ >
39
+ const VALIDATOR = new Validator(
40
+ {
41
+ $defs: operationData.definitions,
42
+ $schema: "https://json-schema.org/draft/2020-12/schema",
43
+ additionalProperties: false,
44
+ properties: Object.fromEntries(
45
+ Object.entries(OPERATIONS).flatMap(([key, operation]) => [
46
+ [`${key}:input`, operation.inputSchema],
47
+ [`${key}:output`, operation.outputSchema],
48
+ ]),
49
+ ),
50
+ type: "object",
51
+ },
52
+ "2020-12",
53
+ )
54
+
55
+ /**
56
+ * Returns the immutable runtime descriptor for one Kit operation.
57
+ *
58
+ * @param key Public operation name.
59
+ */
60
+ export function kitOperation<TKey extends KitOperationKey>(key: TKey) {
61
+ return OPERATIONS[key]
62
+ }
63
+
64
+ /**
65
+ * Validates flattened public input for one Kit operation.
66
+ *
67
+ * @param key Public operation name.
68
+ */
69
+ export function kitOperationInputSchema<TKey extends KitOperationKey>(
70
+ key: TKey,
71
+ ): z.ZodType<KitOperationInput<TKey>> {
72
+ return z.custom<KitOperationInput<TKey>>(
73
+ (value) => VALIDATOR.validate({ [`${key}:input`]: value }).valid,
74
+ { message: `Input does not match Kit operation ${key}.` },
75
+ )
76
+ }
77
+
78
+ /**
79
+ * Validates a public successful response for one Kit operation.
80
+ *
81
+ * @param key Public operation name.
82
+ */
83
+ export function kitOperationOutputSchema<TKey extends KitOperationKey>(
84
+ key: TKey,
85
+ ): z.ZodType<KitOperationOutput<TKey>> {
86
+ return z.custom<KitOperationOutput<TKey>>(
87
+ (value) => VALIDATOR.validate({ [`${key}:output`]: value }).valid,
88
+ { message: `Output does not match Kit operation ${key}.` },
89
+ )
90
+ }
91
+
92
+ /** Provider-native component schemas used for schema-guided key mapping. */
93
+ export const KIT_WIRE_DEFINITIONS = operationData.wireDefinitions
@@ -0,0 +1,87 @@
1
+ import type { Encodable } from "@automate.ax/codec"
2
+ import type { KitOperationMap } from "./openapi-types.generated"
3
+ import type { KitOperationKey } from "./operation-manifest"
4
+
5
+ type Operation<TKey extends KitOperationKey> =
6
+ TKey extends keyof KitOperationMap ? KitOperationMap[TKey] : never
7
+
8
+ /** Converts absent generated operation sections into intersection identities. */
9
+ type InputPart<TValue> = [NonNullable<TValue>] extends [never]
10
+ ? unknown
11
+ : NonNullable<TValue>
12
+
13
+ type Parameters<TOperation, TLocation extends string> = TOperation extends {
14
+ parameters?: infer TParameters
15
+ }
16
+ ? TLocation extends keyof NonNullable<TParameters>
17
+ ? InputPart<NonNullable<TParameters>[TLocation]>
18
+ : unknown
19
+ : unknown
20
+
21
+ /** Extracts the JSON request body from one generated operation. */
22
+ type JsonBody<TOperation> = TOperation extends { requestBody?: infer TBody }
23
+ ? [NonNullable<TBody>] extends [never]
24
+ ? unknown
25
+ : NonNullable<TBody> extends { content: infer TContent }
26
+ ? "application/json" extends keyof TContent
27
+ ? TContent["application/json"]
28
+ : unknown
29
+ : unknown
30
+ : unknown
31
+
32
+ /** Extracts the JSON response body from one generated response. */
33
+ type JsonResponse<TResponse> = TResponse extends { content: infer TContent }
34
+ ? "application/json" extends keyof TContent
35
+ ? TContent["application/json"]
36
+ : object
37
+ : object
38
+
39
+ /** Extracts the union of successful generated operation responses. */
40
+ type SuccessResponse<TOperation> = TOperation extends {
41
+ responses: infer TResponses
42
+ }
43
+ ? JsonResponse<
44
+ TResponses[Extract<keyof TResponses, 200 | 201 | 202 | 203 | 204>]
45
+ >
46
+ : never
47
+
48
+ /** Materializes an intersection as one readable object type. */
49
+ type Simplify<TValue> = { [TKey in keyof TValue]: TValue[TKey] } & {}
50
+
51
+ type EncodableValue<TValue> = unknown extends TValue
52
+ ? Encodable
53
+ : TValue extends undefined | null | boolean | number | string
54
+ ? TValue
55
+ : TValue extends readonly (infer TItem)[]
56
+ ? EncodableValue<TItem>[]
57
+ : TValue extends object
58
+ ? keyof TValue extends never
59
+ ? Record<string, Encodable>
60
+ : { [TKey in keyof TValue]: EncodableValue<TValue[TKey]> }
61
+ : never
62
+
63
+ /** Flattens one generated operation's path, query, and body fields. */
64
+ type RawKitOperationInput<TKey extends KitOperationKey> = Simplify<
65
+ Parameters<Operation<TKey>, "path"> &
66
+ Parameters<Operation<TKey>, "query"> &
67
+ JsonBody<Operation<TKey>>
68
+ >
69
+
70
+ /** Preserves operation unions and rejects fields on truly empty inputs. */
71
+ type PublicInput<TValue> = TValue extends unknown
72
+ ? keyof TValue extends never
73
+ ? Record<string, never>
74
+ : {
75
+ [TField in keyof TValue]: EncodableValue<TValue[TField]>
76
+ }
77
+ : never
78
+
79
+ /** Flattened camelCase input for one frozen Kit V4 operation. */
80
+ export type KitOperationInput<TKey extends KitOperationKey> = PublicInput<
81
+ RawKitOperationInput<TKey>
82
+ >
83
+
84
+ /** CamelCase successful response for one frozen Kit V4 operation. */
85
+ export type KitOperationOutput<TKey extends KitOperationKey> = EncodableValue<
86
+ SuccessResponse<Operation<TKey>>
87
+ >
package/src/tally/api.ts CHANGED
@@ -162,7 +162,7 @@ async function sendTallyRequest(
162
162
  redirect: "error",
163
163
  })
164
164
  const text = await response.text()
165
- const parsed = text ? parseJson(text) : undefined
165
+ const parsed = text ? parseJson(text, response.ok) : undefined
166
166
  if (!response.ok) {
167
167
  const body = encodableSchema.safeParse(parsed)
168
168
  throw new TallyApiError({
@@ -192,12 +192,14 @@ function isTraversalSegment(segment: string) {
192
192
  * Parses one JSON response or reports a provider contract failure.
193
193
  *
194
194
  * @param text Provider response text.
195
+ * @param requireJson Whether a successful response must contain valid JSON.
195
196
  * @throws When the provider response is not valid JSON.
196
197
  */
197
- function parseJson(text: string) {
198
+ function parseJson(text: string, requireJson: boolean) {
198
199
  try {
199
200
  return JSON.parse(text) as unknown
200
201
  } catch {
202
+ if (!requireJson) return text
201
203
  throw new Error("Tally API returned invalid JSON.")
202
204
  }
203
205
  }
@@ -366,7 +366,14 @@
366
366
  "type": "string"
367
367
  },
368
368
  "name": {
369
- "type": "string"
369
+ "anyOf": [
370
+ {
371
+ "type": "string"
372
+ },
373
+ {
374
+ "type": "null"
375
+ }
376
+ ]
370
377
  },
371
378
  "workspaceId": {
372
379
  "type": "string"
@@ -686,7 +693,14 @@
686
693
  "type": "string"
687
694
  },
688
695
  "name": {
689
- "type": "string"
696
+ "anyOf": [
697
+ {
698
+ "type": "string"
699
+ },
700
+ {
701
+ "type": "null"
702
+ }
703
+ ]
690
704
  },
691
705
  "index": {
692
706
  "type": "integer"
@@ -773,7 +787,7 @@
773
787
  "format": "uuid"
774
788
  },
775
789
  "type": {
776
- "$ref": "#/$defs/BlockType"
790
+ "$ref": "#/$defs/FieldType"
777
791
  },
778
792
  "blockGroupUuid": {
779
793
  "type": "string",
@@ -781,6 +795,9 @@
781
795
  },
782
796
  "title": {
783
797
  "type": "string"
798
+ },
799
+ "questionType": {
800
+ "$ref": "#/$defs/FieldQuestionType"
784
801
  }
785
802
  }
786
803
  },
@@ -4338,7 +4355,19 @@
4338
4355
  "type": "object",
4339
4356
  "properties": {
4340
4357
  "settings": {
4341
- "$ref": "#/$defs/FormSettings"
4358
+ "anyOf": [
4359
+ {
4360
+ "type": "object",
4361
+ "allOf": [
4362
+ {
4363
+ "$ref": "#/$defs/FormSettings"
4364
+ }
4365
+ ]
4366
+ },
4367
+ {
4368
+ "type": "null"
4369
+ }
4370
+ ]
4342
4371
  },
4343
4372
  "blocks": {
4344
4373
  "type": "array",
@@ -4595,7 +4624,12 @@
4595
4624
  "required": ["blocks"]
4596
4625
  },
4597
4626
  "PatchFormsFormIdBlocksResponse": {
4598
- "$ref": "#/$defs/Block"
4627
+ "type": "object",
4628
+ "allOf": [
4629
+ {
4630
+ "$ref": "#/$defs/Form"
4631
+ }
4632
+ ]
4599
4633
  },
4600
4634
  "GetFormsFormIdSubmissionsResponse": {
4601
4635
  "type": "object",
@@ -207,7 +207,7 @@ export interface components {
207
207
  }
208
208
  Form: {
209
209
  id: string
210
- name: string
210
+ name: string | null
211
211
  workspaceId: string
212
212
  status: components["schemas"]["FormStatus"]
213
213
  numberOfSubmissions: number
@@ -314,7 +314,7 @@ export interface components {
314
314
  }
315
315
  Workspace: {
316
316
  id: string
317
- name: string
317
+ name: string | null
318
318
  index: number
319
319
  members?: components["schemas"]["User"][]
320
320
  invites?: {
@@ -341,10 +341,11 @@ export interface components {
341
341
  QuestionField: {
342
342
  /** Format: uuid */
343
343
  uuid?: string
344
- type?: components["schemas"]["BlockType"]
344
+ type?: components["schemas"]["FieldType"]
345
345
  /** Format: uuid */
346
346
  blockGroupUuid?: string
347
347
  title?: string
348
+ questionType?: components["schemas"]["FieldQuestionType"]
348
349
  }
349
350
  Question: {
350
351
  id?: string
@@ -2357,7 +2358,7 @@ export interface components {
2357
2358
  }
2358
2359
  PostFormsResponse: components["schemas"]["Form"]
2359
2360
  GetFormsFormIdResponse: components["schemas"]["Form"] & {
2360
- settings?: components["schemas"]["FormSettings"]
2361
+ settings?: components["schemas"]["FormSettings"] | null
2361
2362
  blocks?: components["schemas"]["Block"][]
2362
2363
  }
2363
2364
  PatchFormsFormIdRequest: {
@@ -2441,7 +2442,7 @@ export interface components {
2441
2442
  blocks: components["schemas"]["Block"][]
2442
2443
  settings?: components["schemas"]["FormSettings"] | null
2443
2444
  }
2444
- PatchFormsFormIdBlocksResponse: components["schemas"]["Block"]
2445
+ PatchFormsFormIdBlocksResponse: components["schemas"]["Form"]
2445
2446
  GetFormsFormIdSubmissionsResponse: {
2446
2447
  /** Current page number */
2447
2448
  page?: number
package/src/triggers.ts CHANGED
@@ -22,6 +22,7 @@ import type { googleAdsTriggerContracts } from "./google-ads"
22
22
  import type { googleSheetsTriggerContracts } from "./google-sheets"
23
23
  import type { hubspotTriggerContracts } from "./hubspot"
24
24
  import type { highLevelTriggerContracts } from "./highlevel"
25
+ import type { kitTriggerContracts } from "./kit"
25
26
  import type { linearTriggerContracts } from "./linear"
26
27
  import type { millionVerifierTriggerContracts } from "./millionverifier"
27
28
  import type { metaAdsTriggerContracts } from "./meta-ads"
@@ -63,6 +64,7 @@ export type TriggerContractMap = typeof airtableTriggerContracts &
63
64
  typeof googleSheetsTriggerContracts &
64
65
  typeof hubspotTriggerContracts &
65
66
  typeof highLevelTriggerContracts &
67
+ typeof kitTriggerContracts &
66
68
  typeof linearTriggerContracts &
67
69
  typeof millionVerifierTriggerContracts &
68
70
  typeof metaAdsTriggerContracts &