@sanity/blueprints 0.34.0 → 0.35.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.
Files changed (149) hide show
  1. package/dist/definers/agents.d.ts +3 -1
  2. package/dist/definers/agents.js +3 -1
  3. package/dist/definers/agents.js.map +1 -1
  4. package/dist/definers/applications.d.ts +30 -18
  5. package/dist/definers/applications.js +30 -18
  6. package/dist/definers/applications.js.map +1 -1
  7. package/dist/definers/blueprints.d.ts +1 -0
  8. package/dist/definers/blueprints.js +1 -25
  9. package/dist/definers/blueprints.js.map +1 -1
  10. package/dist/definers/context.d.ts +6 -2
  11. package/dist/definers/context.js +6 -2
  12. package/dist/definers/context.js.map +1 -1
  13. package/dist/definers/cors.d.ts +11 -1
  14. package/dist/definers/cors.js +10 -12
  15. package/dist/definers/cors.js.map +1 -1
  16. package/dist/definers/datasets.d.ts +12 -2
  17. package/dist/definers/datasets.js +11 -14
  18. package/dist/definers/datasets.js.map +1 -1
  19. package/dist/definers/functions/document.d.ts +30 -0
  20. package/dist/definers/functions/document.js.map +1 -1
  21. package/dist/definers/functions/durable.d.ts +4 -3
  22. package/dist/definers/functions/durable.js +4 -3
  23. package/dist/definers/functions/durable.js.map +1 -1
  24. package/dist/definers/functions/media-library.d.ts +31 -0
  25. package/dist/definers/functions/media-library.js +18 -19
  26. package/dist/definers/functions/media-library.js.map +1 -1
  27. package/dist/definers/functions/pubsub.d.ts +2 -3
  28. package/dist/definers/functions/pubsub.js +2 -3
  29. package/dist/definers/functions/pubsub.js.map +1 -1
  30. package/dist/definers/functions/queue.d.ts +15 -4
  31. package/dist/definers/functions/queue.js +19 -6
  32. package/dist/definers/functions/queue.js.map +1 -1
  33. package/dist/definers/functions/scheduled.d.ts +7 -6
  34. package/dist/definers/functions/scheduled.js +7 -6
  35. package/dist/definers/functions/scheduled.js.map +1 -1
  36. package/dist/definers/functions/sync-tag-invalidate.d.ts +5 -2
  37. package/dist/definers/functions/sync-tag-invalidate.js +5 -2
  38. package/dist/definers/functions/sync-tag-invalidate.js.map +1 -1
  39. package/dist/definers/installation-config.d.ts +4 -2
  40. package/dist/definers/installation-config.js +4 -2
  41. package/dist/definers/installation-config.js.map +1 -1
  42. package/dist/definers/permissions.d.ts +8 -2
  43. package/dist/definers/permissions.js +8 -2
  44. package/dist/definers/permissions.js.map +1 -1
  45. package/dist/definers/projects.d.ts +3 -4
  46. package/dist/definers/projects.js +3 -4
  47. package/dist/definers/projects.js.map +1 -1
  48. package/dist/definers/resources.d.ts +1 -0
  49. package/dist/definers/resources.js +1 -11
  50. package/dist/definers/resources.js.map +1 -1
  51. package/dist/definers/robotTokens.d.ts +22 -3
  52. package/dist/definers/robotTokens.js +17 -18
  53. package/dist/definers/robotTokens.js.map +1 -1
  54. package/dist/definers/roles.d.ts +53 -5
  55. package/dist/definers/roles.js +38 -40
  56. package/dist/definers/roles.js.map +1 -1
  57. package/dist/definers/studios.d.ts +5 -3
  58. package/dist/definers/studios.js +5 -3
  59. package/dist/definers/studios.js.map +1 -1
  60. package/dist/definers/webhooks.d.ts +19 -1
  61. package/dist/definers/webhooks.js +15 -17
  62. package/dist/definers/webhooks.js.map +1 -1
  63. package/dist/index.d.ts +18 -18
  64. package/dist/index.js +19 -20
  65. package/dist/index.js.map +1 -1
  66. package/dist/resolve/index.d.ts +2 -3
  67. package/dist/resolve/index.js +2 -3
  68. package/dist/resolve/index.js.map +1 -1
  69. package/dist/types/agents.d.ts +7 -3
  70. package/dist/types/applications.d.ts +67 -49
  71. package/dist/types/applications.js +9 -6
  72. package/dist/types/applications.js.map +1 -1
  73. package/dist/types/context.d.ts +17 -7
  74. package/dist/types/cors.d.ts +0 -2
  75. package/dist/types/datasets.d.ts +0 -6
  76. package/dist/types/functions/index.d.ts +64 -14
  77. package/dist/types/functions/index.js +2 -1
  78. package/dist/types/functions/index.js.map +1 -1
  79. package/dist/types/installation-config.d.ts +13 -10
  80. package/dist/types/permissions.d.ts +8 -4
  81. package/dist/types/projects.d.ts +5 -4
  82. package/dist/types/robotTokens.d.ts +0 -3
  83. package/dist/types/roles.d.ts +0 -4
  84. package/dist/types/studios.d.ts +28 -15
  85. package/dist/types/studios.js +3 -2
  86. package/dist/types/studios.js.map +1 -1
  87. package/dist/types/webhooks.d.ts +0 -3
  88. package/dist/utils/debounce.d.ts +0 -11
  89. package/dist/utils/debounce.js +0 -22
  90. package/dist/utils/debounce.js.map +1 -1
  91. package/dist/utils/parse-duration.d.ts +13 -0
  92. package/dist/utils/parse-duration.js +24 -0
  93. package/dist/utils/parse-duration.js.map +1 -1
  94. package/dist/utils/throttle.d.ts +9 -0
  95. package/dist/utils/throttle.js +22 -0
  96. package/dist/utils/throttle.js.map +1 -0
  97. package/dist/validation/applications.js +7 -2
  98. package/dist/validation/applications.js.map +1 -1
  99. package/dist/validation/functions.d.ts +10 -0
  100. package/dist/validation/functions.js +112 -12
  101. package/dist/validation/functions.js.map +1 -1
  102. package/dist/validation/projects.js +3 -0
  103. package/dist/validation/projects.js.map +1 -1
  104. package/dist/validation/studios.js +4 -5
  105. package/dist/validation/studios.js.map +1 -1
  106. package/package.json +1 -1
  107. package/src/definers/agents.ts +3 -1
  108. package/src/definers/applications.ts +30 -18
  109. package/src/definers/blueprints.ts +1 -25
  110. package/src/definers/context.ts +6 -2
  111. package/src/definers/cors.ts +10 -12
  112. package/src/definers/datasets.ts +11 -14
  113. package/src/definers/functions/document.ts +17 -24
  114. package/src/definers/functions/durable.ts +4 -3
  115. package/src/definers/functions/media-library.ts +18 -19
  116. package/src/definers/functions/pubsub.ts +2 -3
  117. package/src/definers/functions/queue.ts +19 -6
  118. package/src/definers/functions/scheduled.ts +7 -6
  119. package/src/definers/functions/sync-tag-invalidate.ts +5 -2
  120. package/src/definers/installation-config.ts +4 -2
  121. package/src/definers/permissions.ts +8 -2
  122. package/src/definers/projects.ts +3 -4
  123. package/src/definers/resources.ts +1 -11
  124. package/src/definers/robotTokens.ts +17 -18
  125. package/src/definers/roles.ts +38 -40
  126. package/src/definers/studios.ts +5 -3
  127. package/src/definers/webhooks.ts +15 -17
  128. package/src/index.ts +20 -21
  129. package/src/resolve/index.ts +2 -4
  130. package/src/types/agents.ts +7 -3
  131. package/src/types/applications.ts +67 -49
  132. package/src/types/context.ts +17 -7
  133. package/src/types/cors.ts +0 -2
  134. package/src/types/datasets.ts +0 -6
  135. package/src/types/functions/index.ts +67 -14
  136. package/src/types/installation-config.ts +13 -10
  137. package/src/types/permissions.ts +8 -4
  138. package/src/types/projects.ts +6 -4
  139. package/src/types/robotTokens.ts +0 -3
  140. package/src/types/roles.ts +0 -4
  141. package/src/types/studios.ts +28 -16
  142. package/src/types/webhooks.ts +0 -3
  143. package/src/utils/debounce.ts +0 -25
  144. package/src/utils/parse-duration.ts +27 -0
  145. package/src/utils/throttle.ts +25 -0
  146. package/src/validation/applications.ts +6 -2
  147. package/src/validation/functions.ts +123 -12
  148. package/src/validation/projects.ts +4 -0
  149. package/src/validation/studios.ts +3 -6
@@ -1,34 +1,10 @@
1
1
  import {type Blueprint, type BlueprintModule, type BlueprintsApiConfig, validateBlueprint} from '../index.js'
2
2
  import {runValidation} from '../utils/validation.js'
3
3
 
4
- /*
5
- * FUTURE example (move below @example when ready)
6
- * @example With deployment API config
7
- * ```ts
8
- * defineBlueprint({
9
- * resources: [
10
- * defineCorsOrigin({
11
- * name: 'cors-localhost',
12
- * origin: 'http://localhost:3333'
13
- * }),
14
- * defineRole({
15
- * name: 'role-ci',
16
- * title: 'CI Role',
17
- * appliesToRobots: true,
18
- * permissions: []
19
- * }),
20
- * defineRobotToken({
21
- * name: 'ci-robot',
22
- * memberships: [{
23
- * roleNames: ['$.resources.ci-role']}],
24
- * }),
25
- * ],
26
- * })
27
- * ```
28
- */
29
4
  /**
30
5
  * Define a Blueprint to manage Sanity resources
31
6
  *
7
+ * @example
32
8
  * ```ts
33
9
  * defineBlueprint({
34
10
  * resources: [
@@ -11,6 +11,8 @@ import {runValidation} from '../utils/validation.js'
11
11
  /**
12
12
  * Defines a Context knowledge base.
13
13
  *
14
+ * Deploying Context via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
15
+ *
14
16
  * @remarks
15
17
  * The blueprint must be scoped to an organization. A new knowledge base has no sources. Add sources in the Context API
16
18
  * or the dashboard.
@@ -41,7 +43,7 @@ import {runValidation} from '../utils/validation.js'
41
43
  * ```
42
44
  * @param parameters The knowledge base configuration
43
45
  * @public
44
- * @beta Deploying Context via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
46
+ * @beta
45
47
  * @category Definers
46
48
  * @expandType BlueprintContextKnowledgeBaseConfig
47
49
  * @returns The knowledge base resource
@@ -60,6 +62,8 @@ export function defineContextKnowledgeBase(parameters: BlueprintContextKnowledge
60
62
  /**
61
63
  * Defines a Context MCP endpoint that agents connect to.
62
64
  *
65
+ * Deploying Context via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
66
+ *
63
67
  * @remarks
64
68
  * The blueprint must be scoped to an organization.
65
69
  *
@@ -99,7 +103,7 @@ export function defineContextKnowledgeBase(parameters: BlueprintContextKnowledge
99
103
  * ```
100
104
  * @param parameters The MCP endpoint configuration
101
105
  * @public
102
- * @beta Deploying Context via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
106
+ * @beta
103
107
  * @category Definers
104
108
  * @expandType BlueprintContextMcpEndpointConfig
105
109
  * @returns The MCP endpoint resource
@@ -1,31 +1,29 @@
1
1
  import {type BlueprintCorsOriginConfig, type BlueprintCorsOriginResource, validateCorsOrigin} from '../index.js'
2
2
  import {runValidation} from '../utils/validation.js'
3
3
 
4
- /*
5
- * FUTURE example (move below @example when ready)
6
- * @example All options
4
+ /**
5
+ * Defines a CORS Origin to be managed in a Blueprint.
6
+ *
7
+ * @example
7
8
  * ```ts
8
9
  * defineCorsOrigin({
9
- * name: 'studio-cors',
10
- * origin: 'https://my-studio.sanity.studio',
10
+ * name: 'my-cors-origin',
11
+ * origin: 'https://mydomain.com',
11
12
  * allowCredentials: true,
12
- * project: 'my-project-id',
13
13
  * })
14
14
  * ```
15
- */
16
- /**
17
- * Defines a CORS Origin to be managed in a Blueprint.
18
15
  *
16
+ * @example All options
19
17
  * ```ts
20
18
  * defineCorsOrigin({
21
- * name: 'my-cors-origin',
22
- * origin: 'https://mydomain.com',
19
+ * name: 'studio-cors',
20
+ * origin: 'https://my-studio.sanity.studio',
23
21
  * allowCredentials: true,
22
+ * project: 'my-project-id',
24
23
  * })
25
24
  * ```
26
25
  * @param parameters The CORS Origin configuration
27
26
  * @public
28
- * @beta Deploying CORS Origins via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
29
27
  * @category Definers
30
28
  * @expandType BlueprintCorsOriginConfig
31
29
  * @returns The CORS Origin resource
@@ -1,8 +1,17 @@
1
1
  import {type BlueprintDatasetConfig, type BlueprintDatasetResource, validateDataset} from '../index.js'
2
2
  import {runValidation} from '../utils/validation.js'
3
3
 
4
- /*
5
- * FUTURE example (move below @example when ready)
4
+ /**
5
+ * Defines a Dataset to be managed in a Blueprint.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * defineDataset({
10
+ * name: 'staging-dataset',
11
+ * datasetName: 'staging',
12
+ * })
13
+ * ```
14
+ *
6
15
  * @example All options
7
16
  * ```ts
8
17
  * defineDataset({
@@ -13,20 +22,8 @@ import {runValidation} from '../utils/validation.js'
13
22
  * lifecycle: {deletionPolicy: 'protect'},
14
23
  * })
15
24
  * ```
16
- */
17
- /**
18
- * Defines a Dataset to be managed in a Blueprint.
19
- *
20
- * ```ts
21
- * defineDataset({
22
- * name: 'staging-dataset',
23
- * datasetName: 'staging',
24
- * })
25
- * ```
26
25
  * @param parameters The dataset configuration
27
26
  * @public
28
- * @alpha Deploying Datasets via Blueprints is experimental. This feature is subject to breaking changes.
29
- * @hidden
30
27
  * @category Definers
31
28
  * @expandType BlueprintDatasetConfig
32
29
  * @returns The dataset resource
@@ -11,21 +11,29 @@ import {defineFunction} from './index.js'
11
11
  type DocumentFunctionEventKey = keyof BlueprintDocumentFunctionResourceEvent
12
12
  const DOCUMENT_EVENT_KEYS = new Set<DocumentFunctionEventKey>(['includeAllVersions', 'resource', ...BASE_EVENT_KEYS.values()])
13
13
 
14
- /*
15
- * FUTURE example (move below @example when ready)
16
- * @example With robot token reference
14
+ /**
15
+ * Defines a function that is triggered by document events in Sanity datasets.
16
+ *
17
+ * @example
17
18
  * ```ts
18
- * defineRole({
19
- * name: 'fn-role',
20
- * title: 'Function Role',
21
- * appliesToRobots: true,
22
- * permissions: [{name: 'sanity-project-dataset', action: 'read'}],
19
+ * defineDocumentFunction({
20
+ * name: 'my-document-function',
21
+ * event: {
22
+ * on: ['create', 'update'],
23
+ * filter: "_type == 'post'",
24
+ * projection: "{_id, title, slug}",
25
+ * },
23
26
  * })
27
+ * ```
24
28
  *
29
+ * @example With robot token reference
30
+ * ```ts
25
31
  * defineRobotToken({
26
32
  * name: 'fn-robot',
27
33
  * memberships: [{
28
- * roleNames: ['$.resources.fn-role'],
34
+ * resourceType: 'project',
35
+ * resourceId: 'my-project-id',
36
+ * roleNames: ['editor'],
29
37
  * }],
30
38
  * })
31
39
  *
@@ -43,21 +51,6 @@ const DOCUMENT_EVENT_KEYS = new Set<DocumentFunctionEventKey>(['includeAllVersio
43
51
  * },
44
52
  * env: {
45
53
  * EXTERNAL_API_URL: 'https://api.example.com',
46
- * SUPER_SECRET: process.env.SUPER_SECRET,
47
- * },
48
- * })
49
- * ```
50
- */
51
- /**
52
- * Defines a function that is triggered by document events in Sanity datasets.
53
- *
54
- * ```ts
55
- * defineDocumentFunction({
56
- * name: 'my-document-function',
57
- * event: {
58
- * on: ['create', 'update'],
59
- * filter: "_type == 'post'",
60
- * projection: "{_id, title, slug}",
61
54
  * },
62
55
  * })
63
56
  * ```
@@ -6,8 +6,9 @@ import {defineFunction} from './index.js'
6
6
  /**
7
7
  * Defines a durable function resource.
8
8
  *
9
- * @remarks
9
+ * Deploying Durable Functions via Blueprints is experimental.
10
10
  *
11
+ * @example
11
12
  * ```ts
12
13
  * defineDurableFunction({
13
14
  * name: 'daily-cleanup',
@@ -16,9 +17,9 @@ import {defineFunction} from './index.js'
16
17
  * ```
17
18
  *
18
19
  * @param functionConfig The configuration for the function
19
- * @category Definers
20
- * @beta Deploying Durable Functions via Blueprints is experimental.
21
20
  * @public
21
+ * @beta
22
+ * @category Definers
22
23
  * @expandType BlueprintDurableConfig
23
24
  * @returns The validated durable function resource
24
25
  */
@@ -10,15 +10,30 @@ import {defineFunction} from './index.js'
10
10
 
11
11
  type MediaLibraryFunctionEventKey = keyof BlueprintMediaLibraryFunctionResourceEvent
12
12
  const MEDIA_LIBRARY_EVENT_KEYS = new Set<MediaLibraryFunctionEventKey>(['resource', ...BASE_EVENT_KEYS.values()])
13
- /*
14
- * FUTURE example (move below @example when ready)
13
+ /**
14
+ * Defines a function that is triggered by media library events.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * defineMediaLibraryAssetFunction({
19
+ * name: 'my-media-library-function',
20
+ * event: {
21
+ * on: ['create'],
22
+ * resource: {
23
+ * type: 'media-library',
24
+ * id: 'my-media-library-id',
25
+ * },
26
+ * },
27
+ * })
28
+ * ```
29
+ *
15
30
  * @example With robot token reference
16
31
  * ```ts
17
32
  * defineRobotToken({
18
33
  * name: 'media-robot',
19
34
  * memberships: [{
20
35
  * resourceType: 'project',
21
- * resourceId: projectId,
36
+ * resourceId: 'my-project-id',
22
37
  * roleNames: ['editor'],
23
38
  * }],
24
39
  * })
@@ -41,22 +56,6 @@ const MEDIA_LIBRARY_EVENT_KEYS = new Set<MediaLibraryFunctionEventKey>(['resourc
41
56
  * },
42
57
  * })
43
58
  * ```
44
- */
45
- /**
46
- * Defines a function that is triggered by media library events.
47
- *
48
- * ```ts
49
- * defineMediaLibraryAssetFunction({
50
- * name: 'my-media-library-function',
51
- * event: {
52
- * on: ['create'],
53
- * resource: {
54
- * type: 'media-library',
55
- * id: 'my-media-library-id',
56
- * },
57
- * },
58
- * })
59
- * ```
60
59
  * @param functionConfig The configuration for the media library asset function
61
60
  * @public
62
61
  * @category Definers
@@ -3,10 +3,9 @@ import {runValidation} from '../../utils/validation.js'
3
3
  import {defineFunction} from './index.js'
4
4
 
5
5
  /**
6
- * Defines a function that provide pubsub behaviour.
6
+ * Defines a function that provides pubsub behaviour.
7
7
  *
8
- * @remarks
9
- * A barebones pubsub function
8
+ * @example
10
9
  * ```ts
11
10
  * definePubSubFunction({
12
11
  * name: 'send-email',
@@ -1,29 +1,41 @@
1
1
  import {type BlueprintQueueFunctionConfig, type BlueprintQueueFunctionResource, validateQueueFunction} from '../../index.js'
2
2
  import {createDebounceObject} from '../../utils/debounce.js'
3
+ import {createThrottleObject} from '../../utils/throttle.js'
3
4
  import {runValidation} from '../../utils/validation.js'
4
5
  import {defineFunction} from './index.js'
5
6
  /**
6
7
  * Defines a function that provide queueing behaviour.
7
8
  *
9
+ * Deploying Queue Functions via Blueprints is experimental. This feature is not available publicly yet.
10
+ *
8
11
  * @remarks
9
- * Using the reasonable defaults of concurrency: 1, fifo: true, and dlq: true
12
+ * Using the reasonable defaults of concurrency: 1 and fifo: true.
13
+ * Without `maxAttempts`, a failing message is redelivered until the queue's retention period expires.
10
14
  * ```ts
11
15
  * defineQueueFunction({
12
16
  * name: 'send-email',
13
17
  * })
14
18
  * ```
15
19
  *
16
- * Specifying a concurrency of 5
20
+ * Specifying a concurrency of 5, and giving up on a message after 3 attempts
17
21
  * ```ts
18
22
  * defineQueueFunction({
19
23
  * name: 'bustin-caches',
20
24
  * concurrency: 5,
21
25
  * fifo: true,
22
- * dlq: true,
26
+ * maxAttempts: 3,
27
+ * })
28
+ * ```
29
+ *
30
+ * Starting at most 100 messages per minute, paced per tenant, with bursts of up to 10
31
+ * ```ts
32
+ * defineQueueFunction({
33
+ * name: 'call-rate-limited-api',
34
+ * throttle: {limit: 100, period: '1 minute', burst: 10, key: 'event.data.tenantId'},
23
35
  * })
24
36
  * ```
25
37
  * @public
26
- * @alpha Deploying Queue Functions via Blueprints is experimental. This feature is not available publicly yet.
38
+ * @alpha
27
39
  * @hidden
28
40
  * @category Definers
29
41
  * @expandType BlueprintQueueFunctionConfig
@@ -31,16 +43,17 @@ import {defineFunction} from './index.js'
31
43
  * @returns The validated queue function resource
32
44
  */
33
45
  export function defineQueueFunction(functionConfig: BlueprintQueueFunctionConfig): BlueprintQueueFunctionResource {
34
- const {concurrency = 1, fifo = true, dlq = true, debounce, event} = functionConfig
46
+ const {concurrency = 1, fifo = true, debounce, event, maxAttempts, throttle} = functionConfig
35
47
 
36
48
  const functionResource: BlueprintQueueFunctionResource = {
37
49
  ...defineFunction(functionConfig, {skipValidation: true}),
38
50
  type: 'sanity.function.queue',
39
51
  ...(concurrency !== undefined && {concurrency}),
40
52
  ...(debounce !== undefined && {debounce: createDebounceObject(debounce)}),
41
- ...(dlq !== undefined && {dlq}),
42
53
  ...(event !== undefined && {event}),
43
54
  ...(fifo !== undefined && {fifo}),
55
+ ...(maxAttempts !== undefined && {maxAttempts}),
56
+ ...(throttle !== undefined && {throttle: createThrottleObject(throttle)}),
44
57
  }
45
58
 
46
59
  runValidation(() => validateQueueFunction(functionResource))
@@ -21,7 +21,11 @@ const SCHEDULED_EVENT_KEYS = new Set<ScheduledFunctionEventKey>(['minute', 'hour
21
21
  * Supports cron expressions or natural language schedules.
22
22
  *
23
23
  * @remarks
24
- * Using a cron expression:
24
+ * The `event.expression` field accepts standard cron expressions or natural language:
25
+ * `'every 15 minutes'`, `'weekdays at 8am'`, `'fridays in the evening'`,
26
+ * `'mon, wed, fri at 9am'`, `'first of the month at noon'`
27
+ *
28
+ * @example
25
29
  * ```ts
26
30
  * defineScheduledFunction({
27
31
  * name: 'daily-cleanup',
@@ -29,7 +33,7 @@ const SCHEDULED_EVENT_KEYS = new Set<ScheduledFunctionEventKey>(['minute', 'hour
29
33
  * })
30
34
  * ```
31
35
  *
32
- * Using explicit cron fields:
36
+ * @example Explicit cron fields
33
37
  * ```ts
34
38
  * defineScheduledFunction({
35
39
  * name: 'daily-cleanup',
@@ -37,10 +41,7 @@ const SCHEDULED_EVENT_KEYS = new Set<ScheduledFunctionEventKey>(['minute', 'hour
37
41
  * })
38
42
  * ```
39
43
  *
40
- * The `event.expression` field accepts standard cron expressions or natural language:
41
- * `'every 15 minutes'`, `'weekdays at 8am'`, `'fridays in the evening'`,
42
- * `'mon, wed, fri at 9am'`, `'first of the month at noon'`
43
- *
44
+ * @example Natural language schedule
44
45
  * ```ts
45
46
  * defineScheduledFunction({
46
47
  * name: 'daily-cleanup',
@@ -9,14 +9,17 @@ import {defineFunction} from './index.js'
9
9
  * Defines a function that is triggered on a sync tag invalidate event.
10
10
  *
11
11
  * @remarks
12
- * Using implicit event scoping to all datasets in the function project:
12
+ * By default, the event covers all datasets in the function project.
13
+ * Set `event.resource` to scope the event to one dataset.
14
+ *
15
+ * @example
13
16
  * ```ts
14
17
  * defineSyncTagInvalidateFunction({
15
18
  * name: 'bustin-caches',
16
19
  * })
17
20
  * ```
18
21
  *
19
- * Using explicit event scoping to a particular dataset in the function project:
22
+ * @example Scoped to one dataset
20
23
  * ```ts
21
24
  * defineSyncTagInvalidateFunction({
22
25
  * name: 'bustin-caches',
@@ -4,12 +4,15 @@ import {runValidation} from '../utils/validation.js'
4
4
  /**
5
5
  * Defines a singleton Media Library configuration.
6
6
  *
7
+ * Configuring the Media Library via Blueprints is experimental. This may be subject to breaking changes.
8
+ *
7
9
  * @remarks
8
10
  * The Media Library is a Sanity-owned singleton, so this resource carries no
9
11
  * application identity of its own — only the config `root` and its `fields`.
10
12
  * The provider resolves the organization's media library installation id at
11
13
  * deploy time.
12
14
  *
15
+ * @example
13
16
  * ```ts
14
17
  * defineMediaLibraryConfig({
15
18
  * name: 'media-library',
@@ -19,11 +22,10 @@ import {runValidation} from '../utils/validation.js'
19
22
  * ```
20
23
  * @param config The Media Library configuration
21
24
  * @public
22
- * @beta Configuring the Media Library via Blueprints is experimental. This may be subject to breaking changes.
25
+ * @beta
23
26
  * @category Definers
24
27
  * @expandType BlueprintMediaLibraryConfigConfig
25
28
  * @returns The Media Library configuration resource
26
- * @hidden
27
29
  */
28
30
  export function defineMediaLibraryConfig(config: BlueprintMediaLibraryConfigConfig): BlueprintMediaLibraryConfigResource {
29
31
  const resource = {
@@ -10,6 +10,9 @@ import {runValidation} from '../utils/validation.js'
10
10
  /**
11
11
  * Defines a custom permission that roles can grant, in the shape of the Access API.
12
12
  *
13
+ * Deploying Permissions via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
14
+ *
15
+ * @example
13
16
  * ```ts
14
17
  * definePermission({
15
18
  * name: 'articles-only',
@@ -42,7 +45,7 @@ import {runValidation} from '../utils/validation.js'
42
45
  * ```
43
46
  * @param parameters The configuration of the permission
44
47
  * @public
45
- * @beta Deploying Permissions via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
48
+ * @beta
46
49
  * @category Definers
47
50
  * @expandType BlueprintPermissionConfig
48
51
  * @returns The permission resource
@@ -61,6 +64,9 @@ export function definePermission(parameters: BlueprintPermissionConfig): Bluepri
61
64
  /**
62
65
  * Defines a content resource as the Manage UI makes it: a custom permission of type `sanity.document.filter.mode`.
63
66
  *
67
+ * Deploying Permissions via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
68
+ *
69
+ * @example
64
70
  * ```ts
65
71
  * defineContentResource({
66
72
  * name: 'movies',
@@ -81,7 +87,7 @@ export function definePermission(parameters: BlueprintPermissionConfig): Bluepri
81
87
  * ```
82
88
  * @param parameters The configuration of the content resource
83
89
  * @public
84
- * @beta Deploying Permissions via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
90
+ * @beta
85
91
  * @category Definers
86
92
  * @expandType BlueprintContentResourceConfig
87
93
  * @returns The permission resource
@@ -11,19 +11,19 @@ import {runValidation} from '../utils/validation.js'
11
11
  /**
12
12
  * Defines a project.
13
13
  *
14
+ * @example
14
15
  * ```ts
15
16
  * defineProject({
16
17
  * name: 'my-project',
17
18
  * displayName: 'My Project',
19
+ * logo: './logo.png',
18
20
  * })
19
21
  * ```
20
22
  * @param parameters The project configuration
21
23
  * @public
22
- * @beta Deploying Projects via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
23
24
  * @category Definers
24
25
  * @expandType BlueprintProjectConfig
25
26
  * @returns The project resource
26
- * @hidden
27
27
  */
28
28
  export function defineProject(parameters: BlueprintProjectConfig): BlueprintProjectResource {
29
29
  // default project name
@@ -43,6 +43,7 @@ export function defineProject(parameters: BlueprintProjectConfig): BlueprintProj
43
43
  /**
44
44
  * Creates a reference to a project in another stack.
45
45
  *
46
+ * @example
46
47
  * ```ts
47
48
  * referenceProject({
48
49
  * name: 'editorial-project',
@@ -52,10 +53,8 @@ export function defineProject(parameters: BlueprintProjectConfig): BlueprintProj
52
53
  *
53
54
  * @param params The parameters for referencing the project
54
55
  * @public
55
- * @beta Referencing Projects via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
56
56
  * @category Referencers
57
57
  * @returns The project reference
58
- * @hidden
59
58
  */
60
59
  export function referenceProject({name, stack, localName}: BlueprintCrossStackReferenceConfig): BlueprintResource {
61
60
  return referenceResource({name, stack, localName, type: 'sanity.project'})
@@ -1,22 +1,12 @@
1
1
  import {assertResource, type BlueprintCrossStackReferenceResourceConfig, type BlueprintResource} from '../index.js'
2
2
 
3
- /*
4
- * FUTURE example (move below @example when ready)
5
- * @example With lifecycle
6
- * ```ts
7
- * defineResource({
8
- * name: 'my-resource',
9
- * type: 'sanity.new.resource',
10
- * lifecycle: {deletionPolicy: 'retain'},
11
- * })
12
- * ```
13
- */
14
3
  /**
15
4
  * Defines a generic resource to be managed in Blueprints.
16
5
  *
17
6
  * @remarks
18
7
  * This is useful if the resource type does not yet have a `define*` function.
19
8
  *
9
+ * @example
20
10
  * ```ts
21
11
  * defineResource({
22
12
  * name: 'my-resource',
@@ -8,14 +8,28 @@ import {
8
8
  } from '../index.js'
9
9
  import {runValidation} from '../utils/validation.js'
10
10
 
11
- /*
12
- * FUTURE example (move below @example when ready)
11
+ /**
12
+ * Defines a Robot Token for automated access. Has a token property provided during deployment that can be referenced by other resources.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * defineRobotToken({
17
+ * name: 'my-robot',
18
+ * memberships: [{
19
+ * resourceType: 'project',
20
+ * resourceId: 'my-project-id',
21
+ * roleNames: ['editor'],
22
+ * }],
23
+ * })
24
+ * ```
25
+ *
13
26
  * @example Cross-resource references
14
27
  * ```ts
15
28
  * defineRole({
16
29
  * name: 'ci-deploy-role',
17
30
  * title: 'CI Deploy Role',
18
31
  * appliesToRobots: true,
32
+ * appliesToUsers: false,
19
33
  * permissions: [{name: 'sanity-project-cors', action: 'create'}],
20
34
  * })
21
35
  *
@@ -27,23 +41,8 @@ import {runValidation} from '../utils/validation.js'
27
41
  * }],
28
42
  * })
29
43
  * ```
30
- */
31
- /**
32
- * Defines a Robot Token for automated access. Has a token property provided during deployment that can be referenced by other resources.
33
- *
34
- * ```ts
35
- * defineRobotToken({
36
- * name: 'my-robot',
37
- * memberships: [{
38
- * resourceType: 'project',
39
- * resourceId: projectId,
40
- * roleNames: ['editor'],
41
- * }],
42
- * })
43
- * ```
44
44
  * @param parameters The robot token configuration
45
45
  * @public
46
- * @beta Deploying Robot Tokens via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
47
46
  * @category Definers
48
47
  * @expandType BlueprintRobotTokenConfig
49
48
  * @returns The robot token resource
@@ -65,6 +64,7 @@ export function defineRobotToken(parameters: BlueprintRobotTokenConfig): Bluepri
65
64
  /**
66
65
  * Creates a reference to a robot token in another stack.
67
66
  *
67
+ * @example
68
68
  * ```ts
69
69
  * referenceRobotToken({
70
70
  * name: 'editor-token',
@@ -73,7 +73,6 @@ export function defineRobotToken(parameters: BlueprintRobotTokenConfig): Bluepri
73
73
  * ```
74
74
  *
75
75
  * @public
76
- * @beta Referencing Robot Tokens via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
77
76
  * @category Referencers
78
77
  * @expandType BlueprintCrossStackReferenceConfig
79
78
  * @param params The parameters for referencing the robot token