@sanity/presets 0.0.1 → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sanity.io
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,45 +1,18 @@
1
1
  # @sanity/presets
2
2
 
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
3
+ > **This package is under active development and is not ready for use.**
4
+ > The API is unstable and will change without notice. Do not install it as a dependency.
4
5
 
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
6
+ ## Status
6
7
 
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
8
+ This plugin is a work in progress. There are no stable APIs, no published releases intended for production, and no guarantees of backward compatibility.
8
9
 
9
- ## Purpose
10
+ When the package is ready, this README will be updated with installation and usage instructions.
10
11
 
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `@sanity/presets`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
12
+ ## Do not use this package
15
13
 
16
- ## What is OIDC Trusted Publishing?
14
+ - It is not published to npm as a usable release
15
+ - It contains no stable public API
16
+ - It will change without notice
17
17
 
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
19
-
20
- ## Setup Instructions
21
-
22
- To properly configure OIDC trusted publishing for this package:
23
-
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
28
-
29
- ## DO NOT USE THIS PACKAGE
30
-
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
36
-
37
- ## More Information
38
-
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
42
-
43
- ---
44
-
45
- **Maintained for OIDC setup purposes only**
18
+ Check back later, or watch the repository for updates.
@@ -0,0 +1,12 @@
1
+ import { PluginOptions, SchemaTypeDefinition } from "sanity";
2
+ interface PresetResult {
3
+ types: SchemaTypeDefinition[];
4
+ }
5
+ declare function presets(...types: PresetResult[]): PluginOptions;
6
+ declare const LINK_TYPE_NAME = "core.presets.link";
7
+ interface LinkTypeConfig {
8
+ internalTypes: string[];
9
+ }
10
+ declare function linkType(config: LinkTypeConfig): PresetResult;
11
+ export { LINK_TYPE_NAME, type LinkTypeConfig, type PresetResult, linkType, presets };
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/composer.ts","../src/presets/link-type/constants.ts","../src/presets/link-type/index.ts"],"mappings":";UAEiB,YAAA;EACf,KAAA,EAAO,oBAAA;AAAA;AAAA,iBCkBO,OAAA,CAAA,GAAW,KAAA,EAAO,YAAA,KAAiB,aAAA;AAAA,cCrBtC,cAAA;AAAA,UCKI,cAAA;EACf,aAAA;AAAA;AAAA,iBAGc,QAAA,CAAS,MAAA,EAAQ,cAAA,GAAiB,YAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,96 @@
1
+ import { defineType, defineField } from "sanity";
2
+ function collectTypes(presets2) {
3
+ const seen = /* @__PURE__ */ new Set();
4
+ return presets2.flatMap((preset) => preset.types.filter((typeDef) => seen.has(typeDef.name) ? (console.warn(`[@sanity/presets] Dropped duplicate type "${typeDef.name}". Keeping first definition.`), !1) : (seen.add(typeDef.name), !0)));
5
+ }
6
+ function presets(...types) {
7
+ return {
8
+ name: "@sanity/presets",
9
+ schema: {
10
+ types: collectTypes(types)
11
+ }
12
+ };
13
+ }
14
+ const LINK_TYPE_NAME = "core.presets.link";
15
+ function createLinkType(internalTypes) {
16
+ const referenceTargets = internalTypes.map((typeName) => ({
17
+ type: typeName
18
+ }));
19
+ return defineType({
20
+ name: LINK_TYPE_NAME,
21
+ type: "object",
22
+ title: "Link",
23
+ fields: [defineField({
24
+ name: "linkType",
25
+ type: "string",
26
+ title: "Link Type",
27
+ initialValue: "internal",
28
+ options: {
29
+ layout: "radio",
30
+ list: [{
31
+ title: "Internal",
32
+ value: "internal"
33
+ }, {
34
+ title: "External",
35
+ value: "external"
36
+ }]
37
+ }
38
+ }), defineField({
39
+ name: "reference",
40
+ type: "reference",
41
+ title: "Internal Link",
42
+ to: referenceTargets,
43
+ hidden: ({
44
+ parent
45
+ }) => parent?.linkType === "external"
46
+ }), defineField({
47
+ name: "url",
48
+ type: "url",
49
+ title: "URL",
50
+ hidden: ({
51
+ parent
52
+ }) => parent?.linkType === "internal",
53
+ validation: (rule) => rule.uri({
54
+ scheme: ["http", "https", "mailto", "tel"]
55
+ })
56
+ }), defineField({
57
+ name: "openInNewTab",
58
+ type: "boolean",
59
+ title: "Open in New Tab",
60
+ initialValue: !1,
61
+ hidden: ({
62
+ parent
63
+ }) => parent?.linkType === "internal"
64
+ })],
65
+ preview: {
66
+ select: {
67
+ linkType: "linkType",
68
+ url: "url",
69
+ referenceTitle: "reference.title"
70
+ },
71
+ prepare({
72
+ linkType: linkType2,
73
+ url,
74
+ referenceTitle
75
+ }) {
76
+ return {
77
+ title: linkType2 === "external" ? url || "No URL" : referenceTitle || "No reference",
78
+ subtitle: linkType2 === "external" ? "External link" : "Internal link"
79
+ };
80
+ }
81
+ }
82
+ });
83
+ }
84
+ function linkType(config) {
85
+ if (config.internalTypes.length === 0)
86
+ throw new Error("[@sanity/presets] linkType requires at least one internalTypes entry.");
87
+ return {
88
+ types: [createLinkType(config.internalTypes)]
89
+ };
90
+ }
91
+ export {
92
+ LINK_TYPE_NAME,
93
+ linkType,
94
+ presets
95
+ };
96
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/composer.ts","../src/presets/link-type/constants.ts","../src/presets/link-type/schema.ts","../src/presets/link-type/index.ts"],"sourcesContent":["import {type PluginOptions, type SchemaTypeDefinition} from 'sanity'\n\nimport type {PresetResult} from './types'\n\nexport function collectTypes(presets: PresetResult[]): SchemaTypeDefinition[] {\n const seen = new Set<string>()\n\n return presets.flatMap((preset) =>\n preset.types.filter((typeDef) => {\n if (seen.has(typeDef.name)) {\n console.warn(\n `[@sanity/presets] Dropped duplicate type \"${typeDef.name}\". Keeping first definition.`,\n )\n return false\n }\n seen.add(typeDef.name)\n return true\n }),\n )\n}\n\nexport function presets(...types: PresetResult[]): PluginOptions {\n return {\n name: '@sanity/presets',\n schema: {types: collectTypes(types)},\n }\n}\n","export const LINK_TYPE_NAME = 'core.presets.link'\n","import {defineField, defineType, type SchemaTypeDefinition} from 'sanity'\n\nimport {LINK_TYPE_NAME} from './constants'\n\nexport function createLinkType(internalTypes: string[]): SchemaTypeDefinition {\n const referenceTargets = internalTypes.map((typeName) => ({type: typeName}))\n\n return defineType({\n name: LINK_TYPE_NAME,\n type: 'object',\n title: 'Link',\n fields: [\n defineField({\n name: 'linkType',\n type: 'string',\n title: 'Link Type',\n initialValue: 'internal',\n options: {\n layout: 'radio',\n list: [\n {title: 'Internal', value: 'internal'},\n {title: 'External', value: 'external'},\n ],\n },\n }),\n defineField({\n name: 'reference',\n type: 'reference',\n title: 'Internal Link',\n to: referenceTargets,\n hidden: ({parent}) => parent?.linkType === 'external',\n }),\n defineField({\n name: 'url',\n type: 'url',\n title: 'URL',\n hidden: ({parent}) => parent?.linkType === 'internal',\n validation: (rule) =>\n rule.uri({\n scheme: ['http', 'https', 'mailto', 'tel'],\n }),\n }),\n defineField({\n name: 'openInNewTab',\n type: 'boolean',\n title: 'Open in New Tab',\n initialValue: false,\n hidden: ({parent}) => parent?.linkType === 'internal',\n }),\n ],\n preview: {\n select: {\n linkType: 'linkType',\n url: 'url',\n referenceTitle: 'reference.title',\n },\n prepare({linkType, url, referenceTitle}) {\n const title = linkType === 'external' ? url || 'No URL' : referenceTitle || 'No reference'\n\n return {\n title,\n subtitle: linkType === 'external' ? 'External link' : 'Internal link',\n }\n },\n },\n })\n}\n","import type {PresetResult} from '../../types'\nimport {createLinkType} from './schema'\n\nexport {LINK_TYPE_NAME} from './constants'\n\nexport interface LinkTypeConfig {\n internalTypes: string[]\n}\n\nexport function linkType(config: LinkTypeConfig): PresetResult {\n if (config.internalTypes.length === 0) {\n throw new Error('[@sanity/presets] linkType requires at least one internalTypes entry.')\n }\n\n return {\n types: [createLinkType(config.internalTypes)],\n }\n}\n"],"names":["collectTypes","presets","seen","Set","flatMap","preset","types","filter","typeDef","has","name","console","warn","add","schema","LINK_TYPE_NAME","createLinkType","internalTypes","referenceTargets","map","typeName","type","defineType","title","fields","defineField","initialValue","options","layout","list","value","to","hidden","parent","linkType","validation","rule","uri","scheme","preview","select","url","referenceTitle","prepare","subtitle","config","length","Error"],"mappings":";AAIO,SAASA,aAAaC,UAAiD;AAC5E,QAAMC,2BAAWC,IAAAA;AAEjB,SAAOF,SAAQG,QAASC,CAAAA,WACtBA,OAAOC,MAAMC,OAAQC,CAAAA,YACfN,KAAKO,IAAID,QAAQE,IAAI,KACvBC,QAAQC,KACN,6CAA6CJ,QAAQE,IAAI,8BAC3D,GACO,OAETR,KAAKW,IAAIL,QAAQE,IAAI,GACd,GACR,CACH;AACF;AAEO,SAAST,WAAWK,OAAsC;AAC/D,SAAO;AAAA,IACLI,MAAM;AAAA,IACNI,QAAQ;AAAA,MAACR,OAAON,aAAaM,KAAK;AAAA,IAAA;AAAA,EAAC;AAEvC;AC1BO,MAAMS,iBAAiB;ACIvB,SAASC,eAAeC,eAA+C;AAC5E,QAAMC,mBAAmBD,cAAcE,IAAKC,CAAAA,cAAc;AAAA,IAACC,MAAMD;AAAAA,EAAAA,EAAU;AAE3E,SAAOE,WAAW;AAAA,IAChBZ,MAAMK;AAAAA,IACNM,MAAM;AAAA,IACNE,OAAO;AAAA,IACPC,QAAQ,CACNC,YAAY;AAAA,MACVf,MAAM;AAAA,MACNW,MAAM;AAAA,MACNE,OAAO;AAAA,MACPG,cAAc;AAAA,MACdC,SAAS;AAAA,QACPC,QAAQ;AAAA,QACRC,MAAM,CACJ;AAAA,UAACN,OAAO;AAAA,UAAYO,OAAO;AAAA,QAAA,GAC3B;AAAA,UAACP,OAAO;AAAA,UAAYO,OAAO;AAAA,QAAA,CAAW;AAAA,MAAA;AAAA,IAE1C,CACD,GACDL,YAAY;AAAA,MACVf,MAAM;AAAA,MACNW,MAAM;AAAA,MACNE,OAAO;AAAA,MACPQ,IAAIb;AAAAA,MACJc,QAAQA,CAAC;AAAA,QAACC;AAAAA,MAAAA,MAAYA,QAAQC,aAAa;AAAA,IAAA,CAC5C,GACDT,YAAY;AAAA,MACVf,MAAM;AAAA,MACNW,MAAM;AAAA,MACNE,OAAO;AAAA,MACPS,QAAQA,CAAC;AAAA,QAACC;AAAAA,MAAAA,MAAYA,QAAQC,aAAa;AAAA,MAC3CC,YAAaC,CAAAA,SACXA,KAAKC,IAAI;AAAA,QACPC,QAAQ,CAAC,QAAQ,SAAS,UAAU,KAAK;AAAA,MAAA,CAC1C;AAAA,IAAA,CACJ,GACDb,YAAY;AAAA,MACVf,MAAM;AAAA,MACNW,MAAM;AAAA,MACNE,OAAO;AAAA,MACPG,cAAc;AAAA,MACdM,QAAQA,CAAC;AAAA,QAACC;AAAAA,MAAAA,MAAYA,QAAQC,aAAa;AAAA,IAAA,CAC5C,CAAC;AAAA,IAEJK,SAAS;AAAA,MACPC,QAAQ;AAAA,QACNN,UAAU;AAAA,QACVO,KAAK;AAAA,QACLC,gBAAgB;AAAA,MAAA;AAAA,MAElBC,QAAQ;AAAA,QAACT,UAAAA;AAAAA,QAAUO;AAAAA,QAAKC;AAAAA,MAAAA,GAAiB;AAGvC,eAAO;AAAA,UACLnB,OAHYW,cAAa,aAAaO,OAAO,WAAWC,kBAAkB;AAAA,UAI1EE,UAAUV,cAAa,aAAa,kBAAkB;AAAA,QAAA;AAAA,MAE1D;AAAA,IAAA;AAAA,EACF,CACD;AACH;ACzDO,SAASA,SAASW,QAAsC;AAC7D,MAAIA,OAAO5B,cAAc6B,WAAW;AAClC,UAAM,IAAIC,MAAM,uEAAuE;AAGzF,SAAO;AAAA,IACLzC,OAAO,CAACU,eAAe6B,OAAO5B,aAAa,CAAC;AAAA,EAAA;AAEhD;"}
package/package.json CHANGED
@@ -1,10 +1,44 @@
1
1
  {
2
2
  "name": "@sanity/presets",
3
- "version": "0.0.1",
4
- "description": "OIDC trusted publishing setup package for @sanity/presets",
3
+ "version": "0.1.0",
4
+ "description": "Production ready preset patterns for Sanity Studio",
5
5
  "keywords": [
6
- "oidc",
7
- "trusted-publishing",
8
- "setup"
9
- ]
10
- }
6
+ "sanity",
7
+ "sanity-plugin"
8
+ ],
9
+ "homepage": "https://github.com/sanity-io/plugins/tree/main/plugins/@sanity/presets#readme",
10
+ "bugs": {
11
+ "url": "https://github.com/sanity-io/plugins/issues"
12
+ },
13
+ "license": "MIT",
14
+ "author": "Sanity.io <hello@sanity.io>",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+ssh://git@github.com/sanity-io/plugins.git",
18
+ "directory": "plugins/@sanity/presets"
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "type": "module",
24
+ "types": "./dist/index.d.ts",
25
+ "exports": {
26
+ ".": "./dist/index.js",
27
+ "./package.json": "./package.json"
28
+ },
29
+ "devDependencies": {
30
+ "@sanity/pkg-utils": "^10.4.11",
31
+ "sanity": "^5.17.1",
32
+ "@repo/package.config": "0.0.0",
33
+ "@repo/tsconfig": "0.0.0"
34
+ },
35
+ "peerDependencies": {
36
+ "sanity": "^5"
37
+ },
38
+ "engines": {
39
+ "node": ">=20.19 <22 || >=22.12"
40
+ },
41
+ "scripts": {
42
+ "build": "pkg build --strict --check --clean"
43
+ }
44
+ }