@capacms/sdk 1.0.0-next.10 → 1.0.0-next.11

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.
@@ -17,7 +17,8 @@
17
17
  * unpublished for a production key, or is in a model the key cannot read;
18
18
  * - a relation list is `{ items, pageInfo }`, expanded or not;
19
19
  * - media is `{ id, url, alt, type, width, height }`, never the upload's
20
- * own keys.
20
+ * own keys, plus an image's placeholders and its focal point and crop
21
+ * where the project has them (optional, absent otherwise).
21
22
  *
22
23
  * A select the compiler can read exactly, a literal passed as its type
23
24
  * (`list<Articles, typeof select>`), types what it names. One it cannot, a
@@ -50,7 +51,25 @@ export interface RelationItems<E> {
50
51
  next: string | null;
51
52
  };
52
53
  }
53
- /** An image, video or file as `/api/` returns it. */
54
+ /** An editor's focal point: fractions of the image from 0 to 1, `x` from the left and `y` from the top. */
55
+ export interface MediaFocalPoint {
56
+ x: number;
57
+ y: number;
58
+ }
59
+ /** An editor's crop: fractions of the image from 0 to 1. */
60
+ export interface MediaCrop {
61
+ x: number;
62
+ y: number;
63
+ width: number;
64
+ height: number;
65
+ }
66
+ /**
67
+ * An image, video or file as `/api/` returns it.
68
+ *
69
+ * The keys after `height` are optional: they are on every media value of a
70
+ * project that has them, and absent from one that does not. Where they are
71
+ * there, each is null for a video or other file and for an image without one.
72
+ */
54
73
  export interface EntryMedia {
55
74
  id: string;
56
75
  url: string | null;
@@ -58,6 +77,28 @@ export interface EntryMedia {
58
77
  type: string | null;
59
78
  width: number | null;
60
79
  height: number | null;
80
+ /**
81
+ * A tiny blurred copy of the image, 20 pixels on its long side, as a data
82
+ * URL, to show while it loads: next/image's `blurDataURL`
83
+ * (`imagePlaceholder` in `@capacms/sdk/image`). With image placeholders.
84
+ */
85
+ blurDataURL?: string | null;
86
+ /** The image's average colour, `#rrggbb`, to paint its space while it loads. With image placeholders. */
87
+ averageColor?: string | null;
88
+ /** The colour that covers the most of the image, `#rrggbb`: the first of `palette`. With image placeholders. */
89
+ dominantColor?: string | null;
90
+ /** Up to five `#rrggbb` colours, the image's main colour groups, largest first. With image placeholders. */
91
+ palette?: string[] | null;
92
+ /** A BlurHash of the image (https://blurha.sh), for a decoder on the page. With image placeholders. */
93
+ blurhash?: string | null;
94
+ /**
95
+ * The spot an editor marked as the one that matters most. Capa's CDN
96
+ * centres a crop to a shape on it, and `imageUrl` names it in that URL.
97
+ * With focal points and crops.
98
+ */
99
+ focalPoint?: MediaFocalPoint | null;
100
+ /** The part of the image an editor chose to show. A crop to a shape stays inside it. With focal points and crops. */
101
+ crop?: MediaCrop | null;
61
102
  }
62
103
  /**
63
104
  * Levels of entries left to type: the root entry and 4 below it, the API's 5
@@ -108,6 +108,12 @@ function relationList(schema, target, selection, value) {
108
108
  }
109
109
  return out;
110
110
  }
111
+ /**
112
+ * The keys REST adds after `height` where a project has them (an image's
113
+ * placeholders, its focal point and crop), in REST's order. The builder never
114
+ * selects them on its own; a selection that names them gets them back here.
115
+ */
116
+ const MEDIA_OPTIONAL_FIELDS = ["blurDataURL", "averageColor", "dominantColor", "palette", "blurhash", "focalPoint", "crop"];
111
117
  /** One media value with its keys in REST's order: `{ id, url, alt, type, width, height }`, as far as selected. */
112
118
  function mediaTree(value) {
113
119
  if (!isObject(value))
@@ -116,6 +122,9 @@ function mediaTree(value) {
116
122
  for (const key of plan_1.MEDIA_FIELDS)
117
123
  if (key in value)
118
124
  out[key] = value[key];
125
+ for (const key of MEDIA_OPTIONAL_FIELDS)
126
+ if (key in value)
127
+ out[key] = value[key];
119
128
  return out;
120
129
  }
121
130
  /** A relation GraphQL types as an id holds one when it is a non-empty string, as REST reads a stored reference. */
@@ -24,7 +24,7 @@ export type { CapaTreeLayout, TreeLayoutField, TreeLayoutModel } from "./graphql
24
24
  export { selectionToDocument } from "./graphql/typed";
25
25
  export type { ArgsInput, CapaField, Exact, ExactSelection, NodeOf, QueryResult, QuerySelection, RuntimeSelection, Selection, SelectionError, SelectionResult, TreeLayout, treeLayout, UntypedQuery, } from "./graphql/typed";
26
26
  export type { FlatResponse, Inflated } from "./inflate";
27
- export type { EntryFields, EntryMedia, EntryReference, FlatFields, IncludedFields, MissingEntry, RelationItems, } from "./entry-fields";
27
+ export type { EntryFields, EntryMedia, EntryReference, FlatFields, IncludedFields, MediaCrop, MediaFocalPoint, MissingEntry, RelationItems, } from "./entry-fields";
28
28
  export type { CapaAttrs, FieldAttrs, TaggableField } from "./attrs";
29
29
  export type { BuilderCallOptions, CallOptions, CapaNextClient, CapaNextConfig, EntriesResource, Entry, GraphQLClient, Filter, FilterOperator, FlatGetOptions, FlatListOptions, FlatPage, FlatSingle, Included, FilterScalar, FilterValue, GetOptions, ListOptions, Page, PageDetail, PageInfo, PageSummary, PagesListOptions, PagesResource, PreviewClaim, ResponseMeta, ResponseShape, Single, } from "./client";
30
30
  export type { ExpandedTargets, CapaRelation, CapaRelationList, RelationSelectOptions, Select, SelectItem, SelectSort, SortableSystemKey, SystemKey, } from "./select-types";
@@ -41,6 +41,12 @@ export interface WebhookEndpoint {
41
41
  enabled: boolean;
42
42
  /** Sends the published entry in `data` on `instance.published`. */
43
43
  includeData: boolean;
44
+ /**
45
+ * Also sends each language's saves, publishes and unpublishes, marked by
46
+ * `data.localeVersionId`. Present only for a project the locales flag
47
+ * serves; false unless someone turned it on.
48
+ */
49
+ localeEvents?: boolean;
44
50
  headers: Record<string, string>;
45
51
  consecutiveFailures: number;
46
52
  /** When the current failing streak started. Cleared by any success. */
@@ -154,6 +160,8 @@ export interface CreateWebhookEndpointInput {
154
160
  /** At least one. Exact types or `"<resource>.*"`. */
155
161
  events: string[];
156
162
  includeData?: boolean;
163
+ /** A language's events too. Read only for a project the locales flag serves; ignored elsewhere. */
164
+ localeEvents?: boolean;
157
165
  /** At most 10. Sent with every request; they cannot override a `Capa-*` header. */
158
166
  headers?: Record<string, string>;
159
167
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacms/sdk",
3
- "version": "1.0.0-next.10",
3
+ "version": "1.0.0-next.11",
4
4
  "description": "The TypeScript SDK for Capa's content API: REST and GraphQL reads typed from your models, Next.js caching and live preview, and codegen.",
5
5
  "license": "UNLICENSED",
6
6
  "homepage": "https://docs.capacms.com/api",
@@ -119,6 +119,6 @@
119
119
  "scripts": {
120
120
  "build": "node scripts/shared-image.js && tsc -p tsconfig.json && tsc -p tsconfig.esm.json && node scripts/esm-scope.js",
121
121
  "typecheck": "node scripts/shared-image.js && tsc -p tsconfig.json --noEmit && tsc -p tsconfig.esm.json --noEmit",
122
- "test": "pnpm run build && node --test test/comments.test.js test/codegen.test.js test/client.test.js test/next-client.test.js test/nextjs.test.js test/webhooks.test.js test/attrs.test.js test/overlay.test.js test/overlay-dom.test.js test/nextjs-overlay-refresh.test.js test/nextjs-overlay-bundle.test.js test/inflate.test.js test/field-names.test.js test/next-graphql.test.js test/graphql-codegen.test.js test/graphql-contract.test.js test/readme-snippets.test.js test/nextjs-app.test.js test/nextjs-preview-app.test.js test/package-json.test.js test/changelog.test.js test/published-docs.test.js test/builder-messages.test.js test/image.test.js test/nextjs-image-loader.test.js test/capa-cli-handoff.test.js && tsc -p test/types/tsconfig.consumer.json --noEmit && tsc -p test/types/tsconfig.nonstrict.json --noEmit && tsc -p test/types/tsconfig.next.json --noEmit"
122
+ "test": "pnpm run build && node --test test/comments.test.js test/codegen.test.js test/client.test.js test/next-client.test.js test/nextjs.test.js test/webhooks.test.js test/relations.test.js test/attrs.test.js test/overlay.test.js test/overlay-dom.test.js test/nextjs-overlay-refresh.test.js test/nextjs-overlay-bundle.test.js test/inflate.test.js test/field-names.test.js test/next-graphql.test.js test/graphql-codegen.test.js test/graphql-contract.test.js test/readme-snippets.test.js test/nextjs-app.test.js test/nextjs-preview-app.test.js test/package-json.test.js test/changelog.test.js test/published-docs.test.js test/builder-messages.test.js test/image.test.js test/nextjs-image-loader.test.js test/capa-cli-handoff.test.js && tsc -p test/types/tsconfig.consumer.json --noEmit && tsc -p test/types/tsconfig.nonstrict.json --noEmit && tsc -p test/types/tsconfig.next.json --noEmit"
123
123
  }
124
124
  }