@cmssy/core 16.8.0 → 16.9.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/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # @cmssy/core
2
+
3
+ Framework-agnostic client for a [cmssy](https://cmssy.com) headless site. Builds
4
+ the delivery request, defines blocks and layouts, resolves media and locales, and
5
+ verifies webhooks. Everything the framework packages are built on.
6
+
7
+ ```bash
8
+ pnpm add @cmssy/core
9
+ ```
10
+
11
+ Most sites do not install this directly. Use
12
+ [`@cmssy/next`](https://www.npmjs.com/package/@cmssy/next) with
13
+ [`@cmssy/react`](https://www.npmjs.com/package/@cmssy/react), or
14
+ [`@cmssy/astro`](https://www.npmjs.com/package/@cmssy/astro) /
15
+ [`@cmssy/remix`](https://www.npmjs.com/package/@cmssy/remix), which pull this in.
16
+ Reach for `@cmssy/core` when you are wiring a framework we do not ship bindings
17
+ for.
18
+
19
+ ## Configure once
20
+
21
+ ```ts
22
+ import { defineCmssyConfig, createCmssyClient } from "@cmssy/core";
23
+
24
+ export const cmssy = defineCmssyConfig({
25
+ org: process.env.CMSSY_ORG_SLUG,
26
+ workspaceSlug: process.env.CMSSY_WORKSPACE_SLUG,
27
+ });
28
+
29
+ export const client = createCmssyClient(cmssy);
30
+ ```
31
+
32
+ `defineCmssyConfig` validates the required values and throws if one is missing.
33
+ Do not paper over a missing org or workspace slug with `?? ""` - an empty
34
+ segment builds a delivery URL like `/public//graphql` that fails far from the
35
+ cause.
36
+
37
+ ## What is in the box
38
+
39
+ `defineCmssyConfig`, `createCmssyClient`, `graphqlRequest` for the transport;
40
+ `fields` and `defineCmssyLayout` for block and layout definitions; `mediaUrl`,
41
+ `mediaUrls`, `mediaAlt` for media; `localizeHref`, `resolveCmssyLocale`,
42
+ `CMSSY_LOCALE_HEADER` for i18n; `applyCmssyCsp` and `verifyCmssyWebhook` for the
43
+ edges. Full signatures in
44
+ [docs/reference/sdk-api.md](https://github.com/cmssy-io/cmssy-sdk/blob/main/docs/reference/sdk-api.md).
45
+
46
+ ## Versioning: this package, not the API
47
+
48
+ **Pinning this package does not pin the API it talks to.** They are two separate
49
+ things and only one of them is in your lockfile.
50
+
51
+ - The **package version** covers this client: its exports, their signatures, its
52
+ behaviour. Normal semver - a major means your code may need changing.
53
+ - The **delivery API** is a hosted service. Its GraphQL schema can change on any
54
+ deploy, and it does so without a release here. A field removed from the schema
55
+ is gone for `@cmssy/core@16.9.0` exactly as it is for the next version.
56
+
57
+ So `"@cmssy/core": "16.9.0"` in your `package.json` is not a compatibility
58
+ guarantee against the server, and there is currently no API version you can pin
59
+ instead - the delivery endpoint has no version segment.
60
+
61
+ What protects you today:
62
+
63
+ - Every change to the schema runs against this SDK's own operations in CI before
64
+ it can merge, so the queries shipped here keep working.
65
+ - A breaking change cannot merge silently. It fails the gate, and shipping one
66
+ anyway requires an explicit, recorded approval.
67
+ - Fields we intend to remove are marked `@deprecated` in the schema first, which
68
+ shows up in your codegen output and your editor.
69
+
70
+ What does not exist yet, stated plainly rather than implied: there is no
71
+ guaranteed deprecation window, no minimum notice period, and no dated API
72
+ version to pin. If your own documents select fields beyond what this package
73
+ queries, validate them against the live schema in your own CI.
74
+
75
+ ## License
76
+
77
+ MIT
package/dist/index.cjs CHANGED
@@ -74,7 +74,7 @@ Set the listed environment variables (e.g. in .env.local) and restart the dev se
74
74
  }
75
75
 
76
76
  // src/version.ts
77
- var CMSSY_CORE_VERSION = "16.8.0" ;
77
+ var CMSSY_CORE_VERSION = "16.9.1" ;
78
78
  var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
79
79
 
80
80
  // src/data/http.ts
package/dist/index.d.cts CHANGED
@@ -26,7 +26,9 @@ interface RelationFieldOptions extends BaseFieldOptions {
26
26
  sort?: string;
27
27
  limit?: number;
28
28
  }
29
- type Only<O, Shape> = Shape & Record<Exclude<keyof O, keyof Shape>, never>;
29
+ type Only<O, Shape, Field extends string> = Shape & {
30
+ [Key in Exclude<keyof O, keyof Shape>]: `fields.${Field} has no option: ${Key & string}`;
31
+ };
30
32
  type OptionValue<O> = O extends {
31
33
  options: readonly (infer Option extends string)[];
32
34
  } ? Option : string;
@@ -50,28 +52,28 @@ type PageSelectorValue<O> = O extends {
50
52
  multiple: false;
51
53
  } ? PageRef | undefined : PageRef[];
52
54
  declare const fields: {
53
- text: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<string, Declared<O>>;
54
- textarea: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<string, Declared<O>>;
55
- richText: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<string, Declared<O>>;
56
- markdown: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<string, Declared<O>>;
57
- number: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<number, Declared<O>>;
58
- date: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<string, Declared<O>>;
59
- datetime: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<string, Declared<O>>;
60
- boolean: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<boolean, Declared<O>>;
61
- color: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<string, Declared<O>>;
62
- link: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<string, Declared<O>>;
63
- url: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<string, Declared<O>>;
64
- email: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<string, Declared<O>>;
65
- json: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<_cmssy_types.JsonValue, Declared<O>>;
66
- form: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<string, Declared<O>>;
67
- table: <const O extends Only<O, TableFieldOptions>>(opts?: O) => TypedField<FieldTypeValueMap["table"], Declared<O>>;
68
- select: <const O extends Only<O, ChoiceFieldOptions>>(opts: O) => TypedField<OptionValue<O>, Declared<O>>;
69
- radio: <const O extends Only<O, ChoiceFieldOptions>>(opts: O) => TypedField<OptionValue<O>, Declared<O>>;
70
- multiselect: <const O extends Only<O, ChoiceFieldOptions>>(opts: O) => TypedField<OptionValue<O>[], Declared<O>>;
71
- media: <const O extends Only<O, MediaFieldOptions>>(opts?: O) => TypedField<MediaValue<O>, Declared<O>>;
72
- pageSelector: <const O extends Only<O, PageSelectorFieldOptions>>(opts?: O) => TypedField<PageSelectorValue<O>, Declared<O>>;
73
- repeater: <const O extends Only<O, RepeaterFieldOptions>>(opts: O) => TypedField<RepeaterValue<O>, Declared<O>>;
74
- relation: <const O extends Only<O, RelationFieldOptions>>(opts: O) => TypedField<RelationValue<O>, Declared<O>>;
55
+ text: <const O extends Only<O, BaseFieldOptions, "text">>(opts?: O) => TypedField<string, Declared<O>>;
56
+ textarea: <const O extends Only<O, BaseFieldOptions, "textarea">>(opts?: O) => TypedField<string, Declared<O>>;
57
+ richText: <const O extends Only<O, BaseFieldOptions, "richText">>(opts?: O) => TypedField<string, Declared<O>>;
58
+ markdown: <const O extends Only<O, BaseFieldOptions, "markdown">>(opts?: O) => TypedField<string, Declared<O>>;
59
+ number: <const O extends Only<O, BaseFieldOptions, "number">>(opts?: O) => TypedField<number, Declared<O>>;
60
+ date: <const O extends Only<O, BaseFieldOptions, "date">>(opts?: O) => TypedField<string, Declared<O>>;
61
+ datetime: <const O extends Only<O, BaseFieldOptions, "datetime">>(opts?: O) => TypedField<string, Declared<O>>;
62
+ boolean: <const O extends Only<O, BaseFieldOptions, "boolean">>(opts?: O) => TypedField<boolean, Declared<O>>;
63
+ color: <const O extends Only<O, BaseFieldOptions, "color">>(opts?: O) => TypedField<string, Declared<O>>;
64
+ link: <const O extends Only<O, BaseFieldOptions, "link">>(opts?: O) => TypedField<string, Declared<O>>;
65
+ url: <const O extends Only<O, BaseFieldOptions, "url">>(opts?: O) => TypedField<string, Declared<O>>;
66
+ email: <const O extends Only<O, BaseFieldOptions, "email">>(opts?: O) => TypedField<string, Declared<O>>;
67
+ json: <const O extends Only<O, BaseFieldOptions, "json">>(opts?: O) => TypedField<_cmssy_types.JsonValue, Declared<O>>;
68
+ form: <const O extends Only<O, BaseFieldOptions, "form">>(opts?: O) => TypedField<string, Declared<O>>;
69
+ table: <const O extends Only<O, TableFieldOptions, "table">>(opts?: O) => TypedField<FieldTypeValueMap["table"], Declared<O>>;
70
+ select: <const O extends Only<O, ChoiceFieldOptions, "select">>(opts: O) => TypedField<OptionValue<O>, Declared<O>>;
71
+ radio: <const O extends Only<O, ChoiceFieldOptions, "radio">>(opts: O) => TypedField<OptionValue<O>, Declared<O>>;
72
+ multiselect: <const O extends Only<O, ChoiceFieldOptions, "multiselect">>(opts: O) => TypedField<OptionValue<O>[], Declared<O>>;
73
+ media: <const O extends Only<O, MediaFieldOptions, "media">>(opts?: O) => TypedField<MediaValue<O>, Declared<O>>;
74
+ pageSelector: <const O extends Only<O, PageSelectorFieldOptions, "pageSelector">>(opts?: O) => TypedField<PageSelectorValue<O>, Declared<O>>;
75
+ repeater: <const O extends Only<O, RepeaterFieldOptions, "repeater">>(opts: O) => TypedField<RepeaterValue<O>, Declared<O>>;
76
+ relation: <const O extends Only<O, RelationFieldOptions, "relation">>(opts: O) => TypedField<RelationValue<O>, Declared<O>>;
75
77
  };
76
78
 
77
79
  /**
package/dist/index.d.ts CHANGED
@@ -26,7 +26,9 @@ interface RelationFieldOptions extends BaseFieldOptions {
26
26
  sort?: string;
27
27
  limit?: number;
28
28
  }
29
- type Only<O, Shape> = Shape & Record<Exclude<keyof O, keyof Shape>, never>;
29
+ type Only<O, Shape, Field extends string> = Shape & {
30
+ [Key in Exclude<keyof O, keyof Shape>]: `fields.${Field} has no option: ${Key & string}`;
31
+ };
30
32
  type OptionValue<O> = O extends {
31
33
  options: readonly (infer Option extends string)[];
32
34
  } ? Option : string;
@@ -50,28 +52,28 @@ type PageSelectorValue<O> = O extends {
50
52
  multiple: false;
51
53
  } ? PageRef | undefined : PageRef[];
52
54
  declare const fields: {
53
- text: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<string, Declared<O>>;
54
- textarea: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<string, Declared<O>>;
55
- richText: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<string, Declared<O>>;
56
- markdown: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<string, Declared<O>>;
57
- number: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<number, Declared<O>>;
58
- date: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<string, Declared<O>>;
59
- datetime: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<string, Declared<O>>;
60
- boolean: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<boolean, Declared<O>>;
61
- color: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<string, Declared<O>>;
62
- link: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<string, Declared<O>>;
63
- url: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<string, Declared<O>>;
64
- email: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<string, Declared<O>>;
65
- json: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<_cmssy_types.JsonValue, Declared<O>>;
66
- form: <const O extends Only<O, BaseFieldOptions>>(opts?: O) => TypedField<string, Declared<O>>;
67
- table: <const O extends Only<O, TableFieldOptions>>(opts?: O) => TypedField<FieldTypeValueMap["table"], Declared<O>>;
68
- select: <const O extends Only<O, ChoiceFieldOptions>>(opts: O) => TypedField<OptionValue<O>, Declared<O>>;
69
- radio: <const O extends Only<O, ChoiceFieldOptions>>(opts: O) => TypedField<OptionValue<O>, Declared<O>>;
70
- multiselect: <const O extends Only<O, ChoiceFieldOptions>>(opts: O) => TypedField<OptionValue<O>[], Declared<O>>;
71
- media: <const O extends Only<O, MediaFieldOptions>>(opts?: O) => TypedField<MediaValue<O>, Declared<O>>;
72
- pageSelector: <const O extends Only<O, PageSelectorFieldOptions>>(opts?: O) => TypedField<PageSelectorValue<O>, Declared<O>>;
73
- repeater: <const O extends Only<O, RepeaterFieldOptions>>(opts: O) => TypedField<RepeaterValue<O>, Declared<O>>;
74
- relation: <const O extends Only<O, RelationFieldOptions>>(opts: O) => TypedField<RelationValue<O>, Declared<O>>;
55
+ text: <const O extends Only<O, BaseFieldOptions, "text">>(opts?: O) => TypedField<string, Declared<O>>;
56
+ textarea: <const O extends Only<O, BaseFieldOptions, "textarea">>(opts?: O) => TypedField<string, Declared<O>>;
57
+ richText: <const O extends Only<O, BaseFieldOptions, "richText">>(opts?: O) => TypedField<string, Declared<O>>;
58
+ markdown: <const O extends Only<O, BaseFieldOptions, "markdown">>(opts?: O) => TypedField<string, Declared<O>>;
59
+ number: <const O extends Only<O, BaseFieldOptions, "number">>(opts?: O) => TypedField<number, Declared<O>>;
60
+ date: <const O extends Only<O, BaseFieldOptions, "date">>(opts?: O) => TypedField<string, Declared<O>>;
61
+ datetime: <const O extends Only<O, BaseFieldOptions, "datetime">>(opts?: O) => TypedField<string, Declared<O>>;
62
+ boolean: <const O extends Only<O, BaseFieldOptions, "boolean">>(opts?: O) => TypedField<boolean, Declared<O>>;
63
+ color: <const O extends Only<O, BaseFieldOptions, "color">>(opts?: O) => TypedField<string, Declared<O>>;
64
+ link: <const O extends Only<O, BaseFieldOptions, "link">>(opts?: O) => TypedField<string, Declared<O>>;
65
+ url: <const O extends Only<O, BaseFieldOptions, "url">>(opts?: O) => TypedField<string, Declared<O>>;
66
+ email: <const O extends Only<O, BaseFieldOptions, "email">>(opts?: O) => TypedField<string, Declared<O>>;
67
+ json: <const O extends Only<O, BaseFieldOptions, "json">>(opts?: O) => TypedField<_cmssy_types.JsonValue, Declared<O>>;
68
+ form: <const O extends Only<O, BaseFieldOptions, "form">>(opts?: O) => TypedField<string, Declared<O>>;
69
+ table: <const O extends Only<O, TableFieldOptions, "table">>(opts?: O) => TypedField<FieldTypeValueMap["table"], Declared<O>>;
70
+ select: <const O extends Only<O, ChoiceFieldOptions, "select">>(opts: O) => TypedField<OptionValue<O>, Declared<O>>;
71
+ radio: <const O extends Only<O, ChoiceFieldOptions, "radio">>(opts: O) => TypedField<OptionValue<O>, Declared<O>>;
72
+ multiselect: <const O extends Only<O, ChoiceFieldOptions, "multiselect">>(opts: O) => TypedField<OptionValue<O>[], Declared<O>>;
73
+ media: <const O extends Only<O, MediaFieldOptions, "media">>(opts?: O) => TypedField<MediaValue<O>, Declared<O>>;
74
+ pageSelector: <const O extends Only<O, PageSelectorFieldOptions, "pageSelector">>(opts?: O) => TypedField<PageSelectorValue<O>, Declared<O>>;
75
+ repeater: <const O extends Only<O, RepeaterFieldOptions, "repeater">>(opts: O) => TypedField<RepeaterValue<O>, Declared<O>>;
76
+ relation: <const O extends Only<O, RelationFieldOptions, "relation">>(opts: O) => TypedField<RelationValue<O>, Declared<O>>;
75
77
  };
76
78
 
77
79
  /**
package/dist/index.js CHANGED
@@ -73,7 +73,7 @@ Set the listed environment variables (e.g. in .env.local) and restart the dev se
73
73
  }
74
74
 
75
75
  // src/version.ts
76
- var CMSSY_CORE_VERSION = "16.8.0" ;
76
+ var CMSSY_CORE_VERSION = "16.9.1" ;
77
77
  var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
78
78
 
79
79
  // src/data/http.ts
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  // src/version.ts
4
- var CMSSY_CORE_VERSION = "16.8.0" ;
4
+ var CMSSY_CORE_VERSION = "16.9.1" ;
5
5
  var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
6
6
 
7
7
  // src/data/http.ts
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var CMSSY_CORE_VERSION = "16.8.0" ;
2
+ var CMSSY_CORE_VERSION = "16.9.1" ;
3
3
  var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
4
4
 
5
5
  // src/data/http.ts
package/dist/internal.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  var types = require('@cmssy/types');
4
4
 
5
5
  // src/version.ts
6
- var CMSSY_CORE_VERSION = "16.8.0" ;
6
+ var CMSSY_CORE_VERSION = "16.9.1" ;
7
7
  var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
8
8
 
9
9
  // src/data/http.ts
package/dist/internal.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { DEFAULT_LAYOUT_REGIONS } from '@cmssy/types';
2
2
 
3
3
  // src/version.ts
4
- var CMSSY_CORE_VERSION = "16.8.0" ;
4
+ var CMSSY_CORE_VERSION = "16.9.1" ;
5
5
  var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
6
6
 
7
7
  // src/data/http.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/core",
3
- "version": "16.8.0",
3
+ "version": "16.9.1",
4
4
  "description": "Framework-agnostic cmssy gateway: GraphQL client, block/field system, editor protocol. No React, no Next.",
5
5
  "keywords": [
6
6
  "cmssy",