@8ux-co/eelzap 0.10.0 → 0.10.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/CHANGELOG.md +63 -1
- package/README.md +68 -8
- package/dist/{chunk-QN53G5P7.js → chunk-6XHCA4U4.js} +25 -9
- package/dist/chunk-6XHCA4U4.js.map +1 -0
- package/dist/{chunk-VW4EH7NY.js → chunk-7CXQK2PR.js} +148 -80
- package/dist/chunk-7CXQK2PR.js.map +1 -0
- package/dist/{chunk-2IUU53QA.js → chunk-7ZPXZZUT.js} +171 -2
- package/dist/chunk-7ZPXZZUT.js.map +1 -0
- package/dist/index.cjs +94 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +119 -12
- package/dist/index.d.ts +119 -12
- package/dist/index.js +94 -1
- package/dist/index.js.map +1 -1
- package/dist/next.d.ts +6 -0
- package/dist/next.js.map +1 -1
- package/dist/preview.d.ts +55 -7
- package/dist/preview.js +95 -39
- package/dist/preview.js.map +1 -1
- package/dist/react.js +3 -3
- package/dist/react.js.map +1 -1
- package/dist/{signin-2QOSWZFK.js → signin-QT7YANBN.js} +14 -111
- package/dist/signin-QT7YANBN.js.map +1 -0
- package/dist/{suggest-5RHURHED.js → suggest-JZ63L3WP.js} +1001 -66
- package/dist/suggest-JZ63L3WP.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-2IUU53QA.js.map +0 -1
- package/dist/chunk-QN53G5P7.js.map +0 -1
- package/dist/chunk-VW4EH7NY.js.map +0 -1
- package/dist/signin-2QOSWZFK.js.map +0 -1
- package/dist/suggest-5RHURHED.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1972,7 +1972,6 @@ async function verifyWebhookSignature(payload, headers, secret, options = {}) {
|
|
|
1972
1972
|
var CHANGE_ACTIONS = /* @__PURE__ */ new Set([
|
|
1973
1973
|
"created",
|
|
1974
1974
|
"updated",
|
|
1975
|
-
"draft_updated",
|
|
1976
1975
|
"published",
|
|
1977
1976
|
"unpublished",
|
|
1978
1977
|
"deleted",
|
|
@@ -1980,6 +1979,21 @@ var CHANGE_ACTIONS = /* @__PURE__ */ new Set([
|
|
|
1980
1979
|
"uploaded"
|
|
1981
1980
|
]);
|
|
1982
1981
|
function webhookChanges(payload) {
|
|
1982
|
+
switch (payload.type) {
|
|
1983
|
+
case "zap.seo.updated":
|
|
1984
|
+
return seoChanges(payload.data);
|
|
1985
|
+
case "zap.collection.created":
|
|
1986
|
+
case "zap.collection.updated":
|
|
1987
|
+
case "zap.collection.deleted":
|
|
1988
|
+
return collectionChanges(
|
|
1989
|
+
payload.type.slice("zap.collection.".length),
|
|
1990
|
+
payload.data
|
|
1991
|
+
);
|
|
1992
|
+
case "zap.schema.field_changed":
|
|
1993
|
+
return schemaChanges(payload.data);
|
|
1994
|
+
case "zap.site.updated":
|
|
1995
|
+
return siteChanges("updated", payload.data);
|
|
1996
|
+
}
|
|
1983
1997
|
const match = /^zap\.(item|document|media)\.([a-z_]+)$/.exec(payload.type);
|
|
1984
1998
|
if (!match || !CHANGE_ACTIONS.has(match[2])) {
|
|
1985
1999
|
return [];
|
|
@@ -2016,6 +2030,85 @@ function webhookChanges(payload) {
|
|
|
2016
2030
|
siteKey: data.site.key
|
|
2017
2031
|
}));
|
|
2018
2032
|
}
|
|
2033
|
+
function seoChanges(data) {
|
|
2034
|
+
return (data.targets ?? []).map((target) => {
|
|
2035
|
+
if (target.kind === "item") {
|
|
2036
|
+
return {
|
|
2037
|
+
type: "item",
|
|
2038
|
+
action: "updated",
|
|
2039
|
+
id: target.id,
|
|
2040
|
+
resourceKey: target.key,
|
|
2041
|
+
...data.collection ? { collectionKey: data.collection.key } : {},
|
|
2042
|
+
siteKey: data.site.key
|
|
2043
|
+
};
|
|
2044
|
+
}
|
|
2045
|
+
return {
|
|
2046
|
+
type: "document",
|
|
2047
|
+
action: "updated",
|
|
2048
|
+
id: target.id,
|
|
2049
|
+
resourceKey: target.key,
|
|
2050
|
+
siteKey: data.site.key
|
|
2051
|
+
};
|
|
2052
|
+
});
|
|
2053
|
+
}
|
|
2054
|
+
function collectionChanges(action, data) {
|
|
2055
|
+
if (!data.collection || !data.site) return [];
|
|
2056
|
+
return [
|
|
2057
|
+
{
|
|
2058
|
+
type: "collection",
|
|
2059
|
+
action,
|
|
2060
|
+
id: data.collection.id,
|
|
2061
|
+
resourceKey: data.collection.key,
|
|
2062
|
+
collectionKey: data.collection.key,
|
|
2063
|
+
siteKey: data.site.key
|
|
2064
|
+
}
|
|
2065
|
+
];
|
|
2066
|
+
}
|
|
2067
|
+
function schemaChanges(data) {
|
|
2068
|
+
const changes = [];
|
|
2069
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2070
|
+
for (const change of data.changes ?? []) {
|
|
2071
|
+
if (change.collection_id) {
|
|
2072
|
+
if (seen.has(`collection:${change.collection_id}`)) continue;
|
|
2073
|
+
seen.add(`collection:${change.collection_id}`);
|
|
2074
|
+
const key = change.collection_key;
|
|
2075
|
+
changes.push({
|
|
2076
|
+
type: "collection",
|
|
2077
|
+
action: "field_changed",
|
|
2078
|
+
id: change.collection_id,
|
|
2079
|
+
resourceKey: key ?? change.collection_id,
|
|
2080
|
+
...key ? { collectionKey: key } : {},
|
|
2081
|
+
siteKey: data.site.key
|
|
2082
|
+
});
|
|
2083
|
+
} else if (change.document_id && change.document_key) {
|
|
2084
|
+
if (seen.has(`document:${change.document_id}`)) continue;
|
|
2085
|
+
seen.add(`document:${change.document_id}`);
|
|
2086
|
+
changes.push({
|
|
2087
|
+
type: "document",
|
|
2088
|
+
action: "field_changed",
|
|
2089
|
+
id: change.document_id,
|
|
2090
|
+
resourceKey: change.document_key,
|
|
2091
|
+
siteKey: data.site.key
|
|
2092
|
+
});
|
|
2093
|
+
} else if (change.document_id && !seen.has("site")) {
|
|
2094
|
+
seen.add("site");
|
|
2095
|
+
changes.push(...siteChanges("field_changed", data));
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
return changes;
|
|
2099
|
+
}
|
|
2100
|
+
function siteChanges(action, data) {
|
|
2101
|
+
if (!data.site) return [];
|
|
2102
|
+
return [
|
|
2103
|
+
{
|
|
2104
|
+
type: "site",
|
|
2105
|
+
action,
|
|
2106
|
+
id: data.site.id,
|
|
2107
|
+
resourceKey: data.site.key,
|
|
2108
|
+
siteKey: data.site.key
|
|
2109
|
+
}
|
|
2110
|
+
];
|
|
2111
|
+
}
|
|
2019
2112
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2020
2113
|
0 && (module.exports = {
|
|
2021
2114
|
CollectionFieldsResource,
|