@automate.ax/integration-contracts 0.103.2 → 0.105.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/close/events.d.ts +142 -2
- package/dist/close/events.js +35 -1
- package/dist/close/schemas.d.ts +60 -0
- package/dist/close/schemas.js +40 -0
- package/dist/notion/index.js +2 -2
- package/dist/notion/schemas.d.ts +2086 -4
- package/dist/notion/schemas.js +41 -2
- package/dist/slack/event-schemas.d.ts +583 -583
- package/dist/slack/index.d.ts +303 -303
- package/dist/slack/schemas.d.ts +1 -1
- package/dist/teams/schemas.d.ts +4 -4
- package/package.json +2 -2
- package/src/close/events.ts +45 -4
- package/src/close/schemas.ts +44 -0
- package/src/notion/index.ts +2 -2
- package/src/notion/schemas.ts +58 -4
package/dist/notion/schemas.js
CHANGED
|
@@ -138,19 +138,58 @@ const RAW_NOTION_EVENT_SCHEMA = z.discriminatedUnion("type", [
|
|
|
138
138
|
})),
|
|
139
139
|
]);
|
|
140
140
|
/** Exact current Notion webhook schema shared by ingress and triggers. */
|
|
141
|
-
export const NOTION_EVENT_SCHEMA = RAW_NOTION_EVENT_SCHEMA;
|
|
141
|
+
export const NOTION_EVENT_SCHEMA = RAW_NOTION_EVENT_SCHEMA.transform(camelCaseNotionEvent);
|
|
142
|
+
/** Validates an already-normalized Notion webhook event for trigger delivery. */
|
|
143
|
+
export const NOTION_PUBLIC_EVENT_SCHEMA = z.custom((value) => typeof value === "object" &&
|
|
144
|
+
value !== null &&
|
|
145
|
+
"type" in value &&
|
|
146
|
+
typeof value.type === "string");
|
|
142
147
|
/**
|
|
143
148
|
* Runtime schema for one semantic Notion webhook event.
|
|
144
149
|
*
|
|
145
150
|
* @param type - Official event discriminant to require.
|
|
146
151
|
*/
|
|
147
152
|
export function notionSemanticEventSchema(type) {
|
|
148
|
-
return z.custom((value) =>
|
|
153
|
+
return z.custom((value) => NOTION_PUBLIC_EVENT_SCHEMA.safeParse(value).success &&
|
|
149
154
|
typeof value === "object" &&
|
|
150
155
|
value !== null &&
|
|
151
156
|
"type" in value &&
|
|
152
157
|
value.type === type, { message: `Expected a Notion ${type} webhook event.` });
|
|
153
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Converts provider-native webhook fields before public trigger delivery.
|
|
161
|
+
*
|
|
162
|
+
* @param event - Validated provider webhook payload.
|
|
163
|
+
*/
|
|
164
|
+
function camelCaseNotionEvent(event) {
|
|
165
|
+
// REVIEW: the recursive transform preserves the raw schema's JSON structure
|
|
166
|
+
// while changing only property names.
|
|
167
|
+
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- Raw schema validation guarantees this result's shape.
|
|
168
|
+
return camelCaseNotionValue(event);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Recursively camel-cases object property names in a JSON-compatible value.
|
|
172
|
+
*
|
|
173
|
+
* @param value - Provider-native JSON value.
|
|
174
|
+
*/
|
|
175
|
+
function camelCaseNotionValue(value) {
|
|
176
|
+
if (Array.isArray(value))
|
|
177
|
+
return value.map(camelCaseNotionValue);
|
|
178
|
+
if (!isPlainRecord(value))
|
|
179
|
+
return value;
|
|
180
|
+
return Object.fromEntries(Object.entries(value).map(([key, nestedValue]) => [
|
|
181
|
+
key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase()),
|
|
182
|
+
camelCaseNotionValue(nestedValue),
|
|
183
|
+
]));
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Checks whether a value can have provider field names.
|
|
187
|
+
*
|
|
188
|
+
* @param value - Value to inspect.
|
|
189
|
+
*/
|
|
190
|
+
function isPlainRecord(value) {
|
|
191
|
+
return typeof value === "object" && value !== null;
|
|
192
|
+
}
|
|
154
193
|
/**
|
|
155
194
|
* Builds one provider webhook schema over the shared delivery envelope.
|
|
156
195
|
*
|