@automate.ax/integration-contracts 0.150.0 → 0.150.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/kit/schemas.js +57 -0
- package/dist/kit/types.d.ts +7 -1
- package/package.json +2 -2
- package/src/kit/schemas.ts +64 -0
- package/src/kit/types.ts +15 -1
package/dist/kit/schemas.js
CHANGED
|
@@ -4,6 +4,13 @@ import * as z from "zod";
|
|
|
4
4
|
import { KIT_OPENAPI_DATA } from "./openapi-operations.generated";
|
|
5
5
|
/** Runtime Kit contract narrowed once from the opaque generated payload. */
|
|
6
6
|
const operationData = KIT_OPENAPI_DATA;
|
|
7
|
+
for (const operation of Object.values(operationData.operations)) {
|
|
8
|
+
if (typeof operation !== "object" || operation === null)
|
|
9
|
+
continue;
|
|
10
|
+
const record = operation;
|
|
11
|
+
normalizeObservedKitNulls(record.outputSchema);
|
|
12
|
+
normalizeObservedKitNulls(record.outputWireSchema);
|
|
13
|
+
}
|
|
7
14
|
const OPERATIONS = operationData.operations;
|
|
8
15
|
const VALIDATOR = new Validator({
|
|
9
16
|
$defs: operationData.definitions,
|
|
@@ -41,3 +48,53 @@ export function kitOperationOutputSchema(key) {
|
|
|
41
48
|
}
|
|
42
49
|
/** Provider-native component schemas used for schema-guided key mapping. */
|
|
43
50
|
export const KIT_WIRE_DEFINITIONS = operationData.wireDefinitions;
|
|
51
|
+
/**
|
|
52
|
+
* Accepts nullable fields observed in successful Kit responses but omitted from
|
|
53
|
+
* the provider's OpenAPI nullability metadata.
|
|
54
|
+
*
|
|
55
|
+
* @param value Generated operation metadata.
|
|
56
|
+
*/
|
|
57
|
+
function normalizeObservedKitNulls(value) {
|
|
58
|
+
if (Array.isArray(value)) {
|
|
59
|
+
for (const item of value)
|
|
60
|
+
normalizeObservedKitNulls(item);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (typeof value !== "object" || value === null)
|
|
64
|
+
return;
|
|
65
|
+
const record = value;
|
|
66
|
+
const properties = record.properties;
|
|
67
|
+
if (typeof properties === "object" && properties !== null) {
|
|
68
|
+
const propertyRecord = properties;
|
|
69
|
+
for (const name of [
|
|
70
|
+
"bio",
|
|
71
|
+
"byline",
|
|
72
|
+
"endCursor",
|
|
73
|
+
"end_cursor",
|
|
74
|
+
"startCursor",
|
|
75
|
+
"start_cursor",
|
|
76
|
+
]) {
|
|
77
|
+
const property = propertyRecord[name];
|
|
78
|
+
if (typeof property !== "object" ||
|
|
79
|
+
property === null ||
|
|
80
|
+
isNullableSchema(property)) {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
propertyRecord[name] = { anyOf: [property, { type: "null" }] };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
for (const child of Object.values(record))
|
|
87
|
+
normalizeObservedKitNulls(child);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Returns whether one JSON Schema fragment already accepts null.
|
|
91
|
+
*
|
|
92
|
+
* @param value JSON Schema fragment.
|
|
93
|
+
*/
|
|
94
|
+
function isNullableSchema(value) {
|
|
95
|
+
const anyOf = value.anyOf;
|
|
96
|
+
return (Array.isArray(anyOf) &&
|
|
97
|
+
anyOf.some((branch) => typeof branch === "object" &&
|
|
98
|
+
branch !== null &&
|
|
99
|
+
branch.type === "null"));
|
|
100
|
+
}
|
package/dist/kit/types.d.ts
CHANGED
|
@@ -28,6 +28,12 @@ type Simplify<TValue> = {
|
|
|
28
28
|
type EncodableValue<TValue> = unknown extends TValue ? Encodable : TValue extends undefined | null | boolean | number | string ? TValue : TValue extends readonly (infer TItem)[] ? EncodableValue<TItem>[] : TValue extends object ? keyof TValue extends never ? Record<string, Encodable> : {
|
|
29
29
|
[TKey in keyof TValue]: EncodableValue<TValue[TKey]>;
|
|
30
30
|
} : never;
|
|
31
|
+
/** Fields whose live Kit nullability is missing from its OpenAPI document. */
|
|
32
|
+
type ObservedNullableField = "bio" | "byline" | "endCursor" | "startCursor";
|
|
33
|
+
/** Adds nulls returned by Kit but omitted from its generated OpenAPI types. */
|
|
34
|
+
type NormalizeObservedKitNulls<TValue> = TValue extends readonly (infer TItem)[] ? NormalizeObservedKitNulls<TItem>[] : TValue extends object ? {
|
|
35
|
+
[TKey in keyof TValue]: NormalizeObservedKitNulls<TValue[TKey]> | (TKey extends ObservedNullableField ? null : never);
|
|
36
|
+
} : TValue;
|
|
31
37
|
/** Flattens one generated operation's path, query, and body fields. */
|
|
32
38
|
type RawKitOperationInput<TKey extends KitOperationKey> = Simplify<Parameters<Operation<TKey>, "path"> & Parameters<Operation<TKey>, "query"> & JsonBody<Operation<TKey>>>;
|
|
33
39
|
/** Preserves operation unions and rejects fields on truly empty inputs. */
|
|
@@ -37,5 +43,5 @@ type PublicInput<TValue> = TValue extends unknown ? keyof TValue extends never ?
|
|
|
37
43
|
/** Flattened camelCase input for one frozen Kit V4 operation. */
|
|
38
44
|
export type KitOperationInput<TKey extends KitOperationKey> = PublicInput<RawKitOperationInput<TKey>>;
|
|
39
45
|
/** CamelCase successful response for one frozen Kit V4 operation. */
|
|
40
|
-
export type KitOperationOutput<TKey extends KitOperationKey> = EncodableValue<SuccessResponse<Operation<TKey
|
|
46
|
+
export type KitOperationOutput<TKey extends KitOperationKey> = EncodableValue<NormalizeObservedKitNulls<SuccessResponse<Operation<TKey>>>>;
|
|
41
47
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automate.ax/integration-contracts",
|
|
3
|
-
"version": "0.150.
|
|
3
|
+
"version": "0.150.1",
|
|
4
4
|
"description": "Shared integration payload contracts and provider primitives for Automate.ax.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"@anthropic-ai/sdk": "0.123.0",
|
|
74
|
-
"@automate.ax/codec": "0.150.
|
|
74
|
+
"@automate.ax/codec": "0.150.1",
|
|
75
75
|
"@cfworker/json-schema": "^4.1.1",
|
|
76
76
|
"@googleapis/calendar": "^16.0.0",
|
|
77
77
|
"@googleapis/forms": "^6.0.1",
|
package/src/kit/schemas.ts
CHANGED
|
@@ -32,6 +32,12 @@ const operationData = KIT_OPENAPI_DATA as {
|
|
|
32
32
|
operations: Record<string, unknown>
|
|
33
33
|
wireDefinitions: Record<string, Record<string, unknown>>
|
|
34
34
|
}
|
|
35
|
+
for (const operation of Object.values(operationData.operations)) {
|
|
36
|
+
if (typeof operation !== "object" || operation === null) continue
|
|
37
|
+
const record = operation as Record<string, unknown>
|
|
38
|
+
normalizeObservedKitNulls(record.outputSchema)
|
|
39
|
+
normalizeObservedKitNulls(record.outputWireSchema)
|
|
40
|
+
}
|
|
35
41
|
const OPERATIONS = operationData.operations as unknown as Record<
|
|
36
42
|
KitOperationKey,
|
|
37
43
|
KitRuntimeOperation
|
|
@@ -91,3 +97,61 @@ export function kitOperationOutputSchema<TKey extends KitOperationKey>(
|
|
|
91
97
|
|
|
92
98
|
/** Provider-native component schemas used for schema-guided key mapping. */
|
|
93
99
|
export const KIT_WIRE_DEFINITIONS = operationData.wireDefinitions
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Accepts nullable fields observed in successful Kit responses but omitted from
|
|
103
|
+
* the provider's OpenAPI nullability metadata.
|
|
104
|
+
*
|
|
105
|
+
* @param value Generated operation metadata.
|
|
106
|
+
*/
|
|
107
|
+
function normalizeObservedKitNulls(value: unknown) {
|
|
108
|
+
if (Array.isArray(value)) {
|
|
109
|
+
for (const item of value) normalizeObservedKitNulls(item)
|
|
110
|
+
return
|
|
111
|
+
}
|
|
112
|
+
if (typeof value !== "object" || value === null) return
|
|
113
|
+
|
|
114
|
+
const record = value as Record<string, unknown>
|
|
115
|
+
const properties = record.properties
|
|
116
|
+
if (typeof properties === "object" && properties !== null) {
|
|
117
|
+
const propertyRecord = properties as Record<string, unknown>
|
|
118
|
+
for (const name of [
|
|
119
|
+
"bio",
|
|
120
|
+
"byline",
|
|
121
|
+
"endCursor",
|
|
122
|
+
"end_cursor",
|
|
123
|
+
"startCursor",
|
|
124
|
+
"start_cursor",
|
|
125
|
+
]) {
|
|
126
|
+
const property = propertyRecord[name]
|
|
127
|
+
if (
|
|
128
|
+
typeof property !== "object" ||
|
|
129
|
+
property === null ||
|
|
130
|
+
isNullableSchema(property)
|
|
131
|
+
) {
|
|
132
|
+
continue
|
|
133
|
+
}
|
|
134
|
+
propertyRecord[name] = { anyOf: [property, { type: "null" }] }
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
for (const child of Object.values(record)) normalizeObservedKitNulls(child)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Returns whether one JSON Schema fragment already accepts null.
|
|
143
|
+
*
|
|
144
|
+
* @param value JSON Schema fragment.
|
|
145
|
+
*/
|
|
146
|
+
function isNullableSchema(value: object) {
|
|
147
|
+
const anyOf = (value as { anyOf?: unknown }).anyOf
|
|
148
|
+
return (
|
|
149
|
+
Array.isArray(anyOf) &&
|
|
150
|
+
anyOf.some(
|
|
151
|
+
(branch) =>
|
|
152
|
+
typeof branch === "object" &&
|
|
153
|
+
branch !== null &&
|
|
154
|
+
(branch as { type?: unknown }).type === "null",
|
|
155
|
+
)
|
|
156
|
+
)
|
|
157
|
+
}
|
package/src/kit/types.ts
CHANGED
|
@@ -60,6 +60,20 @@ type EncodableValue<TValue> = unknown extends TValue
|
|
|
60
60
|
: { [TKey in keyof TValue]: EncodableValue<TValue[TKey]> }
|
|
61
61
|
: never
|
|
62
62
|
|
|
63
|
+
/** Fields whose live Kit nullability is missing from its OpenAPI document. */
|
|
64
|
+
type ObservedNullableField = "bio" | "byline" | "endCursor" | "startCursor"
|
|
65
|
+
|
|
66
|
+
/** Adds nulls returned by Kit but omitted from its generated OpenAPI types. */
|
|
67
|
+
type NormalizeObservedKitNulls<TValue> = TValue extends readonly (infer TItem)[]
|
|
68
|
+
? NormalizeObservedKitNulls<TItem>[]
|
|
69
|
+
: TValue extends object
|
|
70
|
+
? {
|
|
71
|
+
[TKey in keyof TValue]:
|
|
72
|
+
| NormalizeObservedKitNulls<TValue[TKey]>
|
|
73
|
+
| (TKey extends ObservedNullableField ? null : never)
|
|
74
|
+
}
|
|
75
|
+
: TValue
|
|
76
|
+
|
|
63
77
|
/** Flattens one generated operation's path, query, and body fields. */
|
|
64
78
|
type RawKitOperationInput<TKey extends KitOperationKey> = Simplify<
|
|
65
79
|
Parameters<Operation<TKey>, "path"> &
|
|
@@ -83,5 +97,5 @@ export type KitOperationInput<TKey extends KitOperationKey> = PublicInput<
|
|
|
83
97
|
|
|
84
98
|
/** CamelCase successful response for one frozen Kit V4 operation. */
|
|
85
99
|
export type KitOperationOutput<TKey extends KitOperationKey> = EncodableValue<
|
|
86
|
-
SuccessResponse<Operation<TKey
|
|
100
|
+
NormalizeObservedKitNulls<SuccessResponse<Operation<TKey>>>
|
|
87
101
|
>
|