@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/dist/index.d.cts CHANGED
@@ -154,6 +154,14 @@ interface SeoImage {
154
154
  interface Seo {
155
155
  metaTitle: string | null;
156
156
  metaDescription: string | null;
157
+ /**
158
+ * Always an absolute URL, or null when the site has no URL or the record has
159
+ * no page (a document without a preview path is site-wide, such as a header
160
+ * and footer document). The record's own URL (the site URL plus its preview
161
+ * path, else `/{collectionKey}/{slug}` for an entry) unless an editor set
162
+ * one: a path set in Zap arrives resolved against the site URL, a full URL
163
+ * as typed.
164
+ */
157
165
  canonicalUrl: string | null;
158
166
  ogUrl: string | null;
159
167
  ogType: string | null;
@@ -307,6 +315,13 @@ interface SeoInput {
307
315
  ogType?: string | null;
308
316
  ogImageId?: string | null;
309
317
  ogImageAlt?: string | null;
318
+ /**
319
+ * Optional, SEO only. A path starting with `/` (stored as sent and resolved
320
+ * against the site URL on delivery, so it follows a change of address) or a
321
+ * full https URL (http only on localhost), kept as sent. `null` or `''`
322
+ * clears it, and delivery falls back to the record's own URL. Never changes
323
+ * the page Zap's preview opens.
324
+ */
310
325
  canonicalUrl?: string | null;
311
326
  twitterCard?: 'SUMMARY' | 'SUMMARY_LARGE_IMAGE';
312
327
  noIndex?: boolean;
@@ -992,8 +1007,15 @@ interface OnPageComment {
992
1007
  }
993
1008
  /** `onPage`: what the site's suggestion client needs on one page. */
994
1009
  interface OnPageComments {
1010
+ /**
1011
+ * The signed-in person: their own name and email, and `editorUrl`, the
1012
+ * absolute Zap editor URL of the entry or document this page is (an entry
1013
+ * first when several are), or null.
1014
+ */
995
1015
  viewer: {
996
1016
  name: string | null;
1017
+ email: string | null;
1018
+ editorUrl: string | null;
997
1019
  };
998
1020
  /** Whether the site lets people save straight to the draft. */
999
1021
  liveEditing: boolean;
@@ -1177,6 +1199,7 @@ interface VersionSeo {
1177
1199
  ogType: string | null;
1178
1200
  ogImageId: string | null;
1179
1201
  ogImageAlt: string | null;
1202
+ /** As stored: a path (`/blog/x`) or a full URL; null when unset. */
1180
1203
  canonicalUrl: string | null;
1181
1204
  twitterCard: string;
1182
1205
  noIndex: boolean;
@@ -2285,21 +2308,92 @@ interface WebhookMediaEventData {
2285
2308
  filename?: string;
2286
2309
  }>;
2287
2310
  }
2288
- /** The kind of content a {@link WebhookChange} is about. */
2289
- type WebhookEventType = 'item' | 'document' | 'media';
2311
+ /**
2312
+ * `data` of `zap.seo.updated`. Entry targets hang off their collection
2313
+ * (`collection` set, `key` the slug); document targets off the site
2314
+ * (`collection` null, `key` the document key). Never the SEO text.
2315
+ */
2316
+ interface WebhookSeoEventData {
2317
+ site: WebhookSiteRef;
2318
+ collection: WebhookCollectionRef | null;
2319
+ targets: Array<{
2320
+ kind: 'item' | 'document';
2321
+ id: string;
2322
+ key: string;
2323
+ url: ZapLink;
2324
+ }>;
2325
+ }
2326
+ /** `data` of the `zap.collection.*` events. */
2327
+ interface WebhookCollectionEventData {
2328
+ site: WebhookSiteRef;
2329
+ collection: WebhookCollectionRef & {
2330
+ name?: string;
2331
+ url: ZapLink;
2332
+ };
2333
+ /** On `zap.collection.updated`: the names of what changed. */
2334
+ changed?: string[];
2335
+ }
2336
+ /**
2337
+ * `data` of `zap.schema.field_changed`: one entry per field or section
2338
+ * change, on a collection (`collection_id`, `collection_key`) or a document
2339
+ * (`document_id`, `document_key`). The keys are the owner's key when the event
2340
+ * was emitted; payloads from before they were added carry the ids only.
2341
+ */
2342
+ interface WebhookSchemaEventData {
2343
+ site: WebhookSiteRef;
2344
+ changes: Array<{
2345
+ action: 'created' | 'updated' | 'deleted' | 'restored' | 'reordered';
2346
+ kind: 'field' | 'section';
2347
+ id: string | null;
2348
+ /** The field or section key. */
2349
+ key?: string | null;
2350
+ collection_id: string | null;
2351
+ /** The collection's key. Absent on older payloads. */
2352
+ collection_key?: string | null;
2353
+ document_id: string | null;
2354
+ /** The document's key. Absent on older payloads. */
2355
+ document_key?: string | null;
2356
+ }>;
2357
+ }
2358
+ /** `data` of the `zap.site.*` events (not the API-key ones). */
2359
+ interface WebhookSiteEventData {
2360
+ site: WebhookSiteRef & {
2361
+ name?: string;
2362
+ };
2363
+ /** On `zap.site.updated`: the names of the settings that changed. */
2364
+ changed?: string[];
2365
+ }
2366
+ /**
2367
+ * What a {@link WebhookChange} is about: an item, a document or a file, a
2368
+ * whole collection (its settings or its fields), or the whole site.
2369
+ */
2370
+ type WebhookEventType = 'item' | 'document' | 'media' | 'collection' | 'site';
2290
2371
  /** What happened to it: the verb of the event name. */
2291
- type WebhookAction = 'created' | 'updated' | 'draft_updated' | 'published' | 'unpublished' | 'deleted' | 'rolled_back' | 'uploaded';
2372
+ type WebhookAction = 'created' | 'updated' | 'draft_updated' | 'published' | 'unpublished' | 'deleted' | 'rolled_back' | 'uploaded' | 'field_changed';
2292
2373
  /**
2293
- * One changed item, document or file, flattened out of a payload by
2294
- * `webhookChanges` — the unit a site invalidates its cache by.
2374
+ * One changed item, document, file, collection or site, flattened out of a
2375
+ * payload by `webhookChanges`: the unit a site invalidates its cache by.
2376
+ *
2377
+ * - `item`: an entry; `resourceKey` is its slug, `collectionKey` its collection.
2378
+ * - `document`: `resourceKey` is the document key. Also from
2379
+ * `zap.schema.field_changed` on a document's fields (action `field_changed`).
2380
+ * - `media`: `resourceKey` is the file id.
2381
+ * - `collection`: everything in one collection; `resourceKey` and
2382
+ * `collectionKey` are the collection key. From `zap.collection.*`, and from
2383
+ * `zap.schema.field_changed` on a collection's fields (action
2384
+ * `field_changed`). An older schema payload without the key names the
2385
+ * collection by id: `resourceKey` is its id and `collectionKey` is absent.
2386
+ * - `site`: everything on the site; `id` and `resourceKey` are the site's id
2387
+ * and key. From `zap.site.updated`, and from an older
2388
+ * `zap.schema.field_changed` on a document's fields that has no document key.
2295
2389
  */
2296
2390
  interface WebhookChange {
2297
2391
  type: WebhookEventType;
2298
2392
  action: WebhookAction;
2299
2393
  id: string;
2300
- /** The item's slug, the document's key, or the file's id. */
2394
+ /** The item's slug, the document's key, the file's id, the collection's key (its id on an older schema payload), or the site's key. */
2301
2395
  resourceKey: string;
2302
- /** The item's collection. Items only. */
2396
+ /** The item's collection, or the collection itself. Items and collections only. */
2303
2397
  collectionKey?: string;
2304
2398
  siteKey: string;
2305
2399
  }
@@ -2399,11 +2493,24 @@ interface VerifyWebhookOptions {
2399
2493
  */
2400
2494
  declare function verifyWebhookSignature(payload: string, headers: WebhookHeaders, secret: string, options?: VerifyWebhookOptions): Promise<boolean>;
2401
2495
  /**
2402
- * Flattens a Zap content event into one {@link WebhookChange} per item,
2403
- * document or file it names — what a site walks to invalidate its cache.
2404
- * Every other event (`ping`, schema, site, SEO, assignment, comment
2405
- * events) yields an empty list.
2496
+ * Flattens a Zap event into the {@link WebhookChange}s a site invalidates its
2497
+ * cache by:
2498
+ *
2499
+ * - `zap.item.*`, `zap.document.*`, `zap.media.*`: one change per item,
2500
+ * document or file.
2501
+ * - `zap.seo.updated`: one `item` or `document` change (action `updated`) per
2502
+ * entry or document whose SEO changed.
2503
+ * - `zap.collection.*`: one `collection` change.
2504
+ * - `zap.schema.field_changed` (action `field_changed`): one `collection`
2505
+ * change per collection whose fields changed, and one `document` change per
2506
+ * document whose fields changed, each named by its key. An older payload
2507
+ * without the keys names a collection by id (`resourceKey` is the id, no
2508
+ * `collectionKey`) and widens a document's fields to one `site` change.
2509
+ * - `zap.site.updated`: one `site` change.
2510
+ *
2511
+ * Every other event yields an empty list: `ping`, drafts (`draft_updated`),
2512
+ * assignments, comments, API keys, and sites created or deleted.
2406
2513
  */
2407
2514
  declare function webhookChanges(payload: WebhookPayload): WebhookChange[];
2408
2515
 
2409
- export { type ApiErrorDetail, type ApiErrorPayload, type CacheAdapter, type CacheStrategy, type CachedFetchOptions, type ClientConfig, type ClientDefaults, type CollectionDetail, type CollectionFieldListResponse, CollectionFieldsResource, type CollectionListResponse, type CollectionSectionListResponse, CollectionSectionsResource, type CollectionSummary, CollectionsResource, type CommentAnchor, type CommentAnchorInput, type CommentAnchorKind, type CommentDomAnchor, type CommentDraftAnswer, type CommentFieldAnchorInput, type CommentListOptions, type CommentListResponse, type CommentPersonRef, type CommentProposedValue, type CommentProposedValueInput, type CommentRecord, type CommentRect, type CommentReplyAnswer, type CommentResolution, type CommentSource, type CommentSpotAnchor, type CommentStatus, type CommentTarget, type CommentThread, type CommentThreadAnswer, type CommentVersionRef, type CommentViewport, CommentsResource, type CommonRequestOptions, type ConfirmUploadInput, type CreateCollectionInput, type CreateCommentInput, type CreateDocumentFieldInput, type CreateDocumentInput, type CreateDraftInput, type CreateFieldInput, type CreateItemInput, type CreateSectionInput, type CreateUploadUrlInput, type CurrencyValue, type DeleteDocumentOptions, type DeleteItemOptions, type DeleteOptions, type DeliveryStatus, type DocumentDeleteResponse, type DocumentDetail, type DocumentFieldListResponse, DocumentFieldsResource, type DocumentGetOptions, type DocumentListEntry, type DocumentListOptions, type DocumentListResponse, type DocumentMeta, type DocumentMutationResponse, type DocumentSectionListResponse, DocumentSectionsResource, type DocumentSeo, DocumentSeoResource, type DocumentSeoResponse, DocumentValuesResource, type DocumentValuesResponse, type DocumentVersionDetail, type DocumentVersionSeo, type DocumentVersionSummary, type DocumentVersionValue, DocumentVersionsResource, DocumentsResource, EelZapClient, EelZapError, type EelZapErrorCode, EelZapNetworkError, type EnumValue, type FieldConstraints, type FieldInfo, type FieldOptionInput, type FieldType, type FilterOperatorMap, type FilterValue, type GalleryItemValue, type IdempotencyOptions, type ItemDeleteResponse, type ItemDetail, type ItemFilters, type ItemGetOptions, type ItemListOptions, type ItemListResponse, type ItemMeta, type ItemMutationResponse, ItemQueryBuilder, type ItemSeo, ItemSeoResource, type ItemSeoResponse, type ItemVersionDetail, type ItemVersionSeo, type ItemVersionSlug, type ItemVersionSummary, type ItemVersionValue, ItemVersionsResource, ItemsResource, type JsonObject, type MediaAccess, type MediaDetail, type MediaDetailResponse, type MediaFromUrlInput, type MediaListParams, type MediaListResponse, MediaResource, type MediaSort, type MediaType, type MediaUploadInput, type MediaUsage, type MediaValue, MemoryCacheAdapter, type OnPageComment, type OnPageCommentAnchor, type OnPageComments, type OnPageField, type Pagination, type PreviewOption, type PreviewTokenValidation, PreviewTokensResource, type QueryPrimitive, type ReplyCommentInput, type RetryEvent, type RetryOptions, type SaveCommentToDraftInput, type SectionInfo, type SectionMeta, type Seo, type SeoImage, type SeoInput, type SiteInfo, type SiteListEntry, SiteResource, SitesResource, type ThreadComment, type UpdateCollectionInput, type UpdateCommentInput, type UpdateDocumentDraftInput, type UpdateDocumentFieldInput, type UpdateDocumentInput, type UpdateFieldInput, type UpdateItemDraftInput, type UpdateItemInput, type UpdateMediaInput, type UpdateSectionInput, type UpdateSiteInput, type UploadFile, type UploadUrlResponse, type VerifyWebhookOptions, type VersionDetail, type VersionGalleryItem, type VersionListResponse, type VersionSeo, type VersionStatus, type VersionSummary, type VersionValue, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_TIMESTAMP_HEADER, WEBHOOK_TOLERANCE_SECONDS, type WebhookAction, type WebhookActor, type WebhookChange, type WebhookCollectionRef, type WebhookCommentCreatedData, type WebhookCommentData, type WebhookCommentRef, type WebhookCommentReopenedData, type WebhookCommentRepliedData, type WebhookCommentResolvedData, type WebhookCommentSource, type WebhookCommentTarget, type WebhookCommentUpdatedData, type WebhookDocumentEventData, type WebhookEventName, type WebhookEventType, type WebhookHeaders, type WebhookItemEventData, type WebhookMediaEventData, type WebhookPayload, type WebhookSiteRef, type WebhookSubject, cachedFetch, cleanStega, createClient, getMediaUrl, hasStega, isEelZapError, verifyWebhookSignature, webhookChanges };
2516
+ export { type ApiErrorDetail, type ApiErrorPayload, type CacheAdapter, type CacheStrategy, type CachedFetchOptions, type ClientConfig, type ClientDefaults, type CollectionDetail, type CollectionFieldListResponse, CollectionFieldsResource, type CollectionListResponse, type CollectionSectionListResponse, CollectionSectionsResource, type CollectionSummary, CollectionsResource, type CommentAnchor, type CommentAnchorInput, type CommentAnchorKind, type CommentDomAnchor, type CommentDraftAnswer, type CommentFieldAnchorInput, type CommentListOptions, type CommentListResponse, type CommentPersonRef, type CommentProposedValue, type CommentProposedValueInput, type CommentRecord, type CommentRect, type CommentReplyAnswer, type CommentResolution, type CommentSource, type CommentSpotAnchor, type CommentStatus, type CommentTarget, type CommentThread, type CommentThreadAnswer, type CommentVersionRef, type CommentViewport, CommentsResource, type CommonRequestOptions, type ConfirmUploadInput, type CreateCollectionInput, type CreateCommentInput, type CreateDocumentFieldInput, type CreateDocumentInput, type CreateDraftInput, type CreateFieldInput, type CreateItemInput, type CreateSectionInput, type CreateUploadUrlInput, type CurrencyValue, type DeleteDocumentOptions, type DeleteItemOptions, type DeleteOptions, type DeliveryStatus, type DocumentDeleteResponse, type DocumentDetail, type DocumentFieldListResponse, DocumentFieldsResource, type DocumentGetOptions, type DocumentListEntry, type DocumentListOptions, type DocumentListResponse, type DocumentMeta, type DocumentMutationResponse, type DocumentSectionListResponse, DocumentSectionsResource, type DocumentSeo, DocumentSeoResource, type DocumentSeoResponse, DocumentValuesResource, type DocumentValuesResponse, type DocumentVersionDetail, type DocumentVersionSeo, type DocumentVersionSummary, type DocumentVersionValue, DocumentVersionsResource, DocumentsResource, EelZapClient, EelZapError, type EelZapErrorCode, EelZapNetworkError, type EnumValue, type FieldConstraints, type FieldInfo, type FieldOptionInput, type FieldType, type FilterOperatorMap, type FilterValue, type GalleryItemValue, type IdempotencyOptions, type ItemDeleteResponse, type ItemDetail, type ItemFilters, type ItemGetOptions, type ItemListOptions, type ItemListResponse, type ItemMeta, type ItemMutationResponse, ItemQueryBuilder, type ItemSeo, ItemSeoResource, type ItemSeoResponse, type ItemVersionDetail, type ItemVersionSeo, type ItemVersionSlug, type ItemVersionSummary, type ItemVersionValue, ItemVersionsResource, ItemsResource, type JsonObject, type MediaAccess, type MediaDetail, type MediaDetailResponse, type MediaFromUrlInput, type MediaListParams, type MediaListResponse, MediaResource, type MediaSort, type MediaType, type MediaUploadInput, type MediaUsage, type MediaValue, MemoryCacheAdapter, type OnPageComment, type OnPageCommentAnchor, type OnPageComments, type OnPageField, type Pagination, type PreviewOption, type PreviewTokenValidation, PreviewTokensResource, type QueryPrimitive, type ReplyCommentInput, type RetryEvent, type RetryOptions, type SaveCommentToDraftInput, type SectionInfo, type SectionMeta, type Seo, type SeoImage, type SeoInput, type SiteInfo, type SiteListEntry, SiteResource, SitesResource, type ThreadComment, type UpdateCollectionInput, type UpdateCommentInput, type UpdateDocumentDraftInput, type UpdateDocumentFieldInput, type UpdateDocumentInput, type UpdateFieldInput, type UpdateItemDraftInput, type UpdateItemInput, type UpdateMediaInput, type UpdateSectionInput, type UpdateSiteInput, type UploadFile, type UploadUrlResponse, type VerifyWebhookOptions, type VersionDetail, type VersionGalleryItem, type VersionListResponse, type VersionSeo, type VersionStatus, type VersionSummary, type VersionValue, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_TIMESTAMP_HEADER, WEBHOOK_TOLERANCE_SECONDS, type WebhookAction, type WebhookActor, type WebhookChange, type WebhookCollectionEventData, type WebhookCollectionRef, type WebhookCommentCreatedData, type WebhookCommentData, type WebhookCommentRef, type WebhookCommentReopenedData, type WebhookCommentRepliedData, type WebhookCommentResolvedData, type WebhookCommentSource, type WebhookCommentTarget, type WebhookCommentUpdatedData, type WebhookDocumentEventData, type WebhookEventName, type WebhookEventType, type WebhookHeaders, type WebhookItemEventData, type WebhookMediaEventData, type WebhookPayload, type WebhookSchemaEventData, type WebhookSeoEventData, type WebhookSiteEventData, type WebhookSiteRef, type WebhookSubject, cachedFetch, cleanStega, createClient, getMediaUrl, hasStega, isEelZapError, verifyWebhookSignature, webhookChanges };
package/dist/index.d.ts CHANGED
@@ -154,6 +154,14 @@ interface SeoImage {
154
154
  interface Seo {
155
155
  metaTitle: string | null;
156
156
  metaDescription: string | null;
157
+ /**
158
+ * Always an absolute URL, or null when the site has no URL or the record has
159
+ * no page (a document without a preview path is site-wide, such as a header
160
+ * and footer document). The record's own URL (the site URL plus its preview
161
+ * path, else `/{collectionKey}/{slug}` for an entry) unless an editor set
162
+ * one: a path set in Zap arrives resolved against the site URL, a full URL
163
+ * as typed.
164
+ */
157
165
  canonicalUrl: string | null;
158
166
  ogUrl: string | null;
159
167
  ogType: string | null;
@@ -307,6 +315,13 @@ interface SeoInput {
307
315
  ogType?: string | null;
308
316
  ogImageId?: string | null;
309
317
  ogImageAlt?: string | null;
318
+ /**
319
+ * Optional, SEO only. A path starting with `/` (stored as sent and resolved
320
+ * against the site URL on delivery, so it follows a change of address) or a
321
+ * full https URL (http only on localhost), kept as sent. `null` or `''`
322
+ * clears it, and delivery falls back to the record's own URL. Never changes
323
+ * the page Zap's preview opens.
324
+ */
310
325
  canonicalUrl?: string | null;
311
326
  twitterCard?: 'SUMMARY' | 'SUMMARY_LARGE_IMAGE';
312
327
  noIndex?: boolean;
@@ -992,8 +1007,15 @@ interface OnPageComment {
992
1007
  }
993
1008
  /** `onPage`: what the site's suggestion client needs on one page. */
994
1009
  interface OnPageComments {
1010
+ /**
1011
+ * The signed-in person: their own name and email, and `editorUrl`, the
1012
+ * absolute Zap editor URL of the entry or document this page is (an entry
1013
+ * first when several are), or null.
1014
+ */
995
1015
  viewer: {
996
1016
  name: string | null;
1017
+ email: string | null;
1018
+ editorUrl: string | null;
997
1019
  };
998
1020
  /** Whether the site lets people save straight to the draft. */
999
1021
  liveEditing: boolean;
@@ -1177,6 +1199,7 @@ interface VersionSeo {
1177
1199
  ogType: string | null;
1178
1200
  ogImageId: string | null;
1179
1201
  ogImageAlt: string | null;
1202
+ /** As stored: a path (`/blog/x`) or a full URL; null when unset. */
1180
1203
  canonicalUrl: string | null;
1181
1204
  twitterCard: string;
1182
1205
  noIndex: boolean;
@@ -2285,21 +2308,92 @@ interface WebhookMediaEventData {
2285
2308
  filename?: string;
2286
2309
  }>;
2287
2310
  }
2288
- /** The kind of content a {@link WebhookChange} is about. */
2289
- type WebhookEventType = 'item' | 'document' | 'media';
2311
+ /**
2312
+ * `data` of `zap.seo.updated`. Entry targets hang off their collection
2313
+ * (`collection` set, `key` the slug); document targets off the site
2314
+ * (`collection` null, `key` the document key). Never the SEO text.
2315
+ */
2316
+ interface WebhookSeoEventData {
2317
+ site: WebhookSiteRef;
2318
+ collection: WebhookCollectionRef | null;
2319
+ targets: Array<{
2320
+ kind: 'item' | 'document';
2321
+ id: string;
2322
+ key: string;
2323
+ url: ZapLink;
2324
+ }>;
2325
+ }
2326
+ /** `data` of the `zap.collection.*` events. */
2327
+ interface WebhookCollectionEventData {
2328
+ site: WebhookSiteRef;
2329
+ collection: WebhookCollectionRef & {
2330
+ name?: string;
2331
+ url: ZapLink;
2332
+ };
2333
+ /** On `zap.collection.updated`: the names of what changed. */
2334
+ changed?: string[];
2335
+ }
2336
+ /**
2337
+ * `data` of `zap.schema.field_changed`: one entry per field or section
2338
+ * change, on a collection (`collection_id`, `collection_key`) or a document
2339
+ * (`document_id`, `document_key`). The keys are the owner's key when the event
2340
+ * was emitted; payloads from before they were added carry the ids only.
2341
+ */
2342
+ interface WebhookSchemaEventData {
2343
+ site: WebhookSiteRef;
2344
+ changes: Array<{
2345
+ action: 'created' | 'updated' | 'deleted' | 'restored' | 'reordered';
2346
+ kind: 'field' | 'section';
2347
+ id: string | null;
2348
+ /** The field or section key. */
2349
+ key?: string | null;
2350
+ collection_id: string | null;
2351
+ /** The collection's key. Absent on older payloads. */
2352
+ collection_key?: string | null;
2353
+ document_id: string | null;
2354
+ /** The document's key. Absent on older payloads. */
2355
+ document_key?: string | null;
2356
+ }>;
2357
+ }
2358
+ /** `data` of the `zap.site.*` events (not the API-key ones). */
2359
+ interface WebhookSiteEventData {
2360
+ site: WebhookSiteRef & {
2361
+ name?: string;
2362
+ };
2363
+ /** On `zap.site.updated`: the names of the settings that changed. */
2364
+ changed?: string[];
2365
+ }
2366
+ /**
2367
+ * What a {@link WebhookChange} is about: an item, a document or a file, a
2368
+ * whole collection (its settings or its fields), or the whole site.
2369
+ */
2370
+ type WebhookEventType = 'item' | 'document' | 'media' | 'collection' | 'site';
2290
2371
  /** What happened to it: the verb of the event name. */
2291
- type WebhookAction = 'created' | 'updated' | 'draft_updated' | 'published' | 'unpublished' | 'deleted' | 'rolled_back' | 'uploaded';
2372
+ type WebhookAction = 'created' | 'updated' | 'draft_updated' | 'published' | 'unpublished' | 'deleted' | 'rolled_back' | 'uploaded' | 'field_changed';
2292
2373
  /**
2293
- * One changed item, document or file, flattened out of a payload by
2294
- * `webhookChanges` — the unit a site invalidates its cache by.
2374
+ * One changed item, document, file, collection or site, flattened out of a
2375
+ * payload by `webhookChanges`: the unit a site invalidates its cache by.
2376
+ *
2377
+ * - `item`: an entry; `resourceKey` is its slug, `collectionKey` its collection.
2378
+ * - `document`: `resourceKey` is the document key. Also from
2379
+ * `zap.schema.field_changed` on a document's fields (action `field_changed`).
2380
+ * - `media`: `resourceKey` is the file id.
2381
+ * - `collection`: everything in one collection; `resourceKey` and
2382
+ * `collectionKey` are the collection key. From `zap.collection.*`, and from
2383
+ * `zap.schema.field_changed` on a collection's fields (action
2384
+ * `field_changed`). An older schema payload without the key names the
2385
+ * collection by id: `resourceKey` is its id and `collectionKey` is absent.
2386
+ * - `site`: everything on the site; `id` and `resourceKey` are the site's id
2387
+ * and key. From `zap.site.updated`, and from an older
2388
+ * `zap.schema.field_changed` on a document's fields that has no document key.
2295
2389
  */
2296
2390
  interface WebhookChange {
2297
2391
  type: WebhookEventType;
2298
2392
  action: WebhookAction;
2299
2393
  id: string;
2300
- /** The item's slug, the document's key, or the file's id. */
2394
+ /** The item's slug, the document's key, the file's id, the collection's key (its id on an older schema payload), or the site's key. */
2301
2395
  resourceKey: string;
2302
- /** The item's collection. Items only. */
2396
+ /** The item's collection, or the collection itself. Items and collections only. */
2303
2397
  collectionKey?: string;
2304
2398
  siteKey: string;
2305
2399
  }
@@ -2399,11 +2493,24 @@ interface VerifyWebhookOptions {
2399
2493
  */
2400
2494
  declare function verifyWebhookSignature(payload: string, headers: WebhookHeaders, secret: string, options?: VerifyWebhookOptions): Promise<boolean>;
2401
2495
  /**
2402
- * Flattens a Zap content event into one {@link WebhookChange} per item,
2403
- * document or file it names — what a site walks to invalidate its cache.
2404
- * Every other event (`ping`, schema, site, SEO, assignment, comment
2405
- * events) yields an empty list.
2496
+ * Flattens a Zap event into the {@link WebhookChange}s a site invalidates its
2497
+ * cache by:
2498
+ *
2499
+ * - `zap.item.*`, `zap.document.*`, `zap.media.*`: one change per item,
2500
+ * document or file.
2501
+ * - `zap.seo.updated`: one `item` or `document` change (action `updated`) per
2502
+ * entry or document whose SEO changed.
2503
+ * - `zap.collection.*`: one `collection` change.
2504
+ * - `zap.schema.field_changed` (action `field_changed`): one `collection`
2505
+ * change per collection whose fields changed, and one `document` change per
2506
+ * document whose fields changed, each named by its key. An older payload
2507
+ * without the keys names a collection by id (`resourceKey` is the id, no
2508
+ * `collectionKey`) and widens a document's fields to one `site` change.
2509
+ * - `zap.site.updated`: one `site` change.
2510
+ *
2511
+ * Every other event yields an empty list: `ping`, drafts (`draft_updated`),
2512
+ * assignments, comments, API keys, and sites created or deleted.
2406
2513
  */
2407
2514
  declare function webhookChanges(payload: WebhookPayload): WebhookChange[];
2408
2515
 
2409
- export { type ApiErrorDetail, type ApiErrorPayload, type CacheAdapter, type CacheStrategy, type CachedFetchOptions, type ClientConfig, type ClientDefaults, type CollectionDetail, type CollectionFieldListResponse, CollectionFieldsResource, type CollectionListResponse, type CollectionSectionListResponse, CollectionSectionsResource, type CollectionSummary, CollectionsResource, type CommentAnchor, type CommentAnchorInput, type CommentAnchorKind, type CommentDomAnchor, type CommentDraftAnswer, type CommentFieldAnchorInput, type CommentListOptions, type CommentListResponse, type CommentPersonRef, type CommentProposedValue, type CommentProposedValueInput, type CommentRecord, type CommentRect, type CommentReplyAnswer, type CommentResolution, type CommentSource, type CommentSpotAnchor, type CommentStatus, type CommentTarget, type CommentThread, type CommentThreadAnswer, type CommentVersionRef, type CommentViewport, CommentsResource, type CommonRequestOptions, type ConfirmUploadInput, type CreateCollectionInput, type CreateCommentInput, type CreateDocumentFieldInput, type CreateDocumentInput, type CreateDraftInput, type CreateFieldInput, type CreateItemInput, type CreateSectionInput, type CreateUploadUrlInput, type CurrencyValue, type DeleteDocumentOptions, type DeleteItemOptions, type DeleteOptions, type DeliveryStatus, type DocumentDeleteResponse, type DocumentDetail, type DocumentFieldListResponse, DocumentFieldsResource, type DocumentGetOptions, type DocumentListEntry, type DocumentListOptions, type DocumentListResponse, type DocumentMeta, type DocumentMutationResponse, type DocumentSectionListResponse, DocumentSectionsResource, type DocumentSeo, DocumentSeoResource, type DocumentSeoResponse, DocumentValuesResource, type DocumentValuesResponse, type DocumentVersionDetail, type DocumentVersionSeo, type DocumentVersionSummary, type DocumentVersionValue, DocumentVersionsResource, DocumentsResource, EelZapClient, EelZapError, type EelZapErrorCode, EelZapNetworkError, type EnumValue, type FieldConstraints, type FieldInfo, type FieldOptionInput, type FieldType, type FilterOperatorMap, type FilterValue, type GalleryItemValue, type IdempotencyOptions, type ItemDeleteResponse, type ItemDetail, type ItemFilters, type ItemGetOptions, type ItemListOptions, type ItemListResponse, type ItemMeta, type ItemMutationResponse, ItemQueryBuilder, type ItemSeo, ItemSeoResource, type ItemSeoResponse, type ItemVersionDetail, type ItemVersionSeo, type ItemVersionSlug, type ItemVersionSummary, type ItemVersionValue, ItemVersionsResource, ItemsResource, type JsonObject, type MediaAccess, type MediaDetail, type MediaDetailResponse, type MediaFromUrlInput, type MediaListParams, type MediaListResponse, MediaResource, type MediaSort, type MediaType, type MediaUploadInput, type MediaUsage, type MediaValue, MemoryCacheAdapter, type OnPageComment, type OnPageCommentAnchor, type OnPageComments, type OnPageField, type Pagination, type PreviewOption, type PreviewTokenValidation, PreviewTokensResource, type QueryPrimitive, type ReplyCommentInput, type RetryEvent, type RetryOptions, type SaveCommentToDraftInput, type SectionInfo, type SectionMeta, type Seo, type SeoImage, type SeoInput, type SiteInfo, type SiteListEntry, SiteResource, SitesResource, type ThreadComment, type UpdateCollectionInput, type UpdateCommentInput, type UpdateDocumentDraftInput, type UpdateDocumentFieldInput, type UpdateDocumentInput, type UpdateFieldInput, type UpdateItemDraftInput, type UpdateItemInput, type UpdateMediaInput, type UpdateSectionInput, type UpdateSiteInput, type UploadFile, type UploadUrlResponse, type VerifyWebhookOptions, type VersionDetail, type VersionGalleryItem, type VersionListResponse, type VersionSeo, type VersionStatus, type VersionSummary, type VersionValue, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_TIMESTAMP_HEADER, WEBHOOK_TOLERANCE_SECONDS, type WebhookAction, type WebhookActor, type WebhookChange, type WebhookCollectionRef, type WebhookCommentCreatedData, type WebhookCommentData, type WebhookCommentRef, type WebhookCommentReopenedData, type WebhookCommentRepliedData, type WebhookCommentResolvedData, type WebhookCommentSource, type WebhookCommentTarget, type WebhookCommentUpdatedData, type WebhookDocumentEventData, type WebhookEventName, type WebhookEventType, type WebhookHeaders, type WebhookItemEventData, type WebhookMediaEventData, type WebhookPayload, type WebhookSiteRef, type WebhookSubject, cachedFetch, cleanStega, createClient, getMediaUrl, hasStega, isEelZapError, verifyWebhookSignature, webhookChanges };
2516
+ export { type ApiErrorDetail, type ApiErrorPayload, type CacheAdapter, type CacheStrategy, type CachedFetchOptions, type ClientConfig, type ClientDefaults, type CollectionDetail, type CollectionFieldListResponse, CollectionFieldsResource, type CollectionListResponse, type CollectionSectionListResponse, CollectionSectionsResource, type CollectionSummary, CollectionsResource, type CommentAnchor, type CommentAnchorInput, type CommentAnchorKind, type CommentDomAnchor, type CommentDraftAnswer, type CommentFieldAnchorInput, type CommentListOptions, type CommentListResponse, type CommentPersonRef, type CommentProposedValue, type CommentProposedValueInput, type CommentRecord, type CommentRect, type CommentReplyAnswer, type CommentResolution, type CommentSource, type CommentSpotAnchor, type CommentStatus, type CommentTarget, type CommentThread, type CommentThreadAnswer, type CommentVersionRef, type CommentViewport, CommentsResource, type CommonRequestOptions, type ConfirmUploadInput, type CreateCollectionInput, type CreateCommentInput, type CreateDocumentFieldInput, type CreateDocumentInput, type CreateDraftInput, type CreateFieldInput, type CreateItemInput, type CreateSectionInput, type CreateUploadUrlInput, type CurrencyValue, type DeleteDocumentOptions, type DeleteItemOptions, type DeleteOptions, type DeliveryStatus, type DocumentDeleteResponse, type DocumentDetail, type DocumentFieldListResponse, DocumentFieldsResource, type DocumentGetOptions, type DocumentListEntry, type DocumentListOptions, type DocumentListResponse, type DocumentMeta, type DocumentMutationResponse, type DocumentSectionListResponse, DocumentSectionsResource, type DocumentSeo, DocumentSeoResource, type DocumentSeoResponse, DocumentValuesResource, type DocumentValuesResponse, type DocumentVersionDetail, type DocumentVersionSeo, type DocumentVersionSummary, type DocumentVersionValue, DocumentVersionsResource, DocumentsResource, EelZapClient, EelZapError, type EelZapErrorCode, EelZapNetworkError, type EnumValue, type FieldConstraints, type FieldInfo, type FieldOptionInput, type FieldType, type FilterOperatorMap, type FilterValue, type GalleryItemValue, type IdempotencyOptions, type ItemDeleteResponse, type ItemDetail, type ItemFilters, type ItemGetOptions, type ItemListOptions, type ItemListResponse, type ItemMeta, type ItemMutationResponse, ItemQueryBuilder, type ItemSeo, ItemSeoResource, type ItemSeoResponse, type ItemVersionDetail, type ItemVersionSeo, type ItemVersionSlug, type ItemVersionSummary, type ItemVersionValue, ItemVersionsResource, ItemsResource, type JsonObject, type MediaAccess, type MediaDetail, type MediaDetailResponse, type MediaFromUrlInput, type MediaListParams, type MediaListResponse, MediaResource, type MediaSort, type MediaType, type MediaUploadInput, type MediaUsage, type MediaValue, MemoryCacheAdapter, type OnPageComment, type OnPageCommentAnchor, type OnPageComments, type OnPageField, type Pagination, type PreviewOption, type PreviewTokenValidation, PreviewTokensResource, type QueryPrimitive, type ReplyCommentInput, type RetryEvent, type RetryOptions, type SaveCommentToDraftInput, type SectionInfo, type SectionMeta, type Seo, type SeoImage, type SeoInput, type SiteInfo, type SiteListEntry, SiteResource, SitesResource, type ThreadComment, type UpdateCollectionInput, type UpdateCommentInput, type UpdateDocumentDraftInput, type UpdateDocumentFieldInput, type UpdateDocumentInput, type UpdateFieldInput, type UpdateItemDraftInput, type UpdateItemInput, type UpdateMediaInput, type UpdateSectionInput, type UpdateSiteInput, type UploadFile, type UploadUrlResponse, type VerifyWebhookOptions, type VersionDetail, type VersionGalleryItem, type VersionListResponse, type VersionSeo, type VersionStatus, type VersionSummary, type VersionValue, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_TIMESTAMP_HEADER, WEBHOOK_TOLERANCE_SECONDS, type WebhookAction, type WebhookActor, type WebhookChange, type WebhookCollectionEventData, type WebhookCollectionRef, type WebhookCommentCreatedData, type WebhookCommentData, type WebhookCommentRef, type WebhookCommentReopenedData, type WebhookCommentRepliedData, type WebhookCommentResolvedData, type WebhookCommentSource, type WebhookCommentTarget, type WebhookCommentUpdatedData, type WebhookDocumentEventData, type WebhookEventName, type WebhookEventType, type WebhookHeaders, type WebhookItemEventData, type WebhookMediaEventData, type WebhookPayload, type WebhookSchemaEventData, type WebhookSeoEventData, type WebhookSiteEventData, type WebhookSiteRef, type WebhookSubject, cachedFetch, cleanStega, createClient, getMediaUrl, hasStega, isEelZapError, verifyWebhookSignature, webhookChanges };
package/dist/index.js CHANGED
@@ -1916,7 +1916,6 @@ async function verifyWebhookSignature(payload, headers, secret, options = {}) {
1916
1916
  var CHANGE_ACTIONS = /* @__PURE__ */ new Set([
1917
1917
  "created",
1918
1918
  "updated",
1919
- "draft_updated",
1920
1919
  "published",
1921
1920
  "unpublished",
1922
1921
  "deleted",
@@ -1924,6 +1923,21 @@ var CHANGE_ACTIONS = /* @__PURE__ */ new Set([
1924
1923
  "uploaded"
1925
1924
  ]);
1926
1925
  function webhookChanges(payload) {
1926
+ switch (payload.type) {
1927
+ case "zap.seo.updated":
1928
+ return seoChanges(payload.data);
1929
+ case "zap.collection.created":
1930
+ case "zap.collection.updated":
1931
+ case "zap.collection.deleted":
1932
+ return collectionChanges(
1933
+ payload.type.slice("zap.collection.".length),
1934
+ payload.data
1935
+ );
1936
+ case "zap.schema.field_changed":
1937
+ return schemaChanges(payload.data);
1938
+ case "zap.site.updated":
1939
+ return siteChanges("updated", payload.data);
1940
+ }
1927
1941
  const match = /^zap\.(item|document|media)\.([a-z_]+)$/.exec(payload.type);
1928
1942
  if (!match || !CHANGE_ACTIONS.has(match[2])) {
1929
1943
  return [];
@@ -1960,6 +1974,85 @@ function webhookChanges(payload) {
1960
1974
  siteKey: data.site.key
1961
1975
  }));
1962
1976
  }
1977
+ function seoChanges(data) {
1978
+ return (data.targets ?? []).map((target) => {
1979
+ if (target.kind === "item") {
1980
+ return {
1981
+ type: "item",
1982
+ action: "updated",
1983
+ id: target.id,
1984
+ resourceKey: target.key,
1985
+ ...data.collection ? { collectionKey: data.collection.key } : {},
1986
+ siteKey: data.site.key
1987
+ };
1988
+ }
1989
+ return {
1990
+ type: "document",
1991
+ action: "updated",
1992
+ id: target.id,
1993
+ resourceKey: target.key,
1994
+ siteKey: data.site.key
1995
+ };
1996
+ });
1997
+ }
1998
+ function collectionChanges(action, data) {
1999
+ if (!data.collection || !data.site) return [];
2000
+ return [
2001
+ {
2002
+ type: "collection",
2003
+ action,
2004
+ id: data.collection.id,
2005
+ resourceKey: data.collection.key,
2006
+ collectionKey: data.collection.key,
2007
+ siteKey: data.site.key
2008
+ }
2009
+ ];
2010
+ }
2011
+ function schemaChanges(data) {
2012
+ const changes = [];
2013
+ const seen = /* @__PURE__ */ new Set();
2014
+ for (const change of data.changes ?? []) {
2015
+ if (change.collection_id) {
2016
+ if (seen.has(`collection:${change.collection_id}`)) continue;
2017
+ seen.add(`collection:${change.collection_id}`);
2018
+ const key = change.collection_key;
2019
+ changes.push({
2020
+ type: "collection",
2021
+ action: "field_changed",
2022
+ id: change.collection_id,
2023
+ resourceKey: key ?? change.collection_id,
2024
+ ...key ? { collectionKey: key } : {},
2025
+ siteKey: data.site.key
2026
+ });
2027
+ } else if (change.document_id && change.document_key) {
2028
+ if (seen.has(`document:${change.document_id}`)) continue;
2029
+ seen.add(`document:${change.document_id}`);
2030
+ changes.push({
2031
+ type: "document",
2032
+ action: "field_changed",
2033
+ id: change.document_id,
2034
+ resourceKey: change.document_key,
2035
+ siteKey: data.site.key
2036
+ });
2037
+ } else if (change.document_id && !seen.has("site")) {
2038
+ seen.add("site");
2039
+ changes.push(...siteChanges("field_changed", data));
2040
+ }
2041
+ }
2042
+ return changes;
2043
+ }
2044
+ function siteChanges(action, data) {
2045
+ if (!data.site) return [];
2046
+ return [
2047
+ {
2048
+ type: "site",
2049
+ action,
2050
+ id: data.site.id,
2051
+ resourceKey: data.site.key,
2052
+ siteKey: data.site.key
2053
+ }
2054
+ ];
2055
+ }
1963
2056
  export {
1964
2057
  CollectionFieldsResource,
1965
2058
  CollectionSectionsResource,