@sanity/blueprints 0.10.0 → 0.12.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 (112) hide show
  1. package/README.md +55 -20
  2. package/dist/definers/blueprints.d.ts +17 -3
  3. package/dist/definers/blueprints.js +42 -3
  4. package/dist/definers/blueprints.js.map +1 -1
  5. package/dist/definers/cors.d.ts +9 -2
  6. package/dist/definers/cors.js +21 -2
  7. package/dist/definers/cors.js.map +1 -1
  8. package/dist/definers/datasets.d.ts +10 -2
  9. package/dist/definers/datasets.js +23 -2
  10. package/dist/definers/datasets.js.map +1 -1
  11. package/dist/definers/functions.d.ts +58 -53
  12. package/dist/definers/functions.js +101 -86
  13. package/dist/definers/functions.js.map +1 -1
  14. package/dist/definers/resources.d.ts +12 -0
  15. package/dist/definers/resources.js +23 -0
  16. package/dist/definers/resources.js.map +1 -1
  17. package/dist/definers/robotTokens.d.ts +22 -0
  18. package/dist/definers/robotTokens.js +53 -0
  19. package/dist/definers/robotTokens.js.map +1 -0
  20. package/dist/definers/robots.d.ts +2 -18
  21. package/dist/definers/robots.js +2 -29
  22. package/dist/definers/robots.js.map +1 -1
  23. package/dist/definers/roles.d.ts +22 -25
  24. package/dist/definers/roles.js +70 -23
  25. package/dist/definers/roles.js.map +1 -1
  26. package/dist/definers/webhooks.d.ts +9 -2
  27. package/dist/definers/webhooks.js +29 -2
  28. package/dist/definers/webhooks.js.map +1 -1
  29. package/dist/index.d.ts +23 -0
  30. package/dist/index.js +24 -0
  31. package/dist/index.js.map +1 -1
  32. package/dist/types/blueprints.d.ts +16 -4
  33. package/dist/types/cors.d.ts +6 -0
  34. package/dist/types/datasets.d.ts +19 -3
  35. package/dist/types/errors.d.ts +4 -1
  36. package/dist/types/functions.d.ts +139 -17
  37. package/dist/types/functions.js +5 -1
  38. package/dist/types/functions.js.map +1 -1
  39. package/dist/types/resources.d.ts +17 -0
  40. package/dist/types/robotTokens.d.ts +45 -0
  41. package/dist/types/robotTokens.js +2 -0
  42. package/dist/types/robotTokens.js.map +1 -0
  43. package/dist/types/robots.d.ts +8 -30
  44. package/dist/types/robots.js +1 -0
  45. package/dist/types/robots.js.map +1 -1
  46. package/dist/types/roles.d.ts +12 -3
  47. package/dist/types/webhooks.d.ts +23 -5
  48. package/dist/utils/schedule-parser.d.ts +42 -0
  49. package/dist/utils/schedule-parser.js +450 -0
  50. package/dist/utils/schedule-parser.js.map +1 -0
  51. package/dist/utils/validation.d.ts +1 -0
  52. package/dist/utils/validation.js +1 -0
  53. package/dist/utils/validation.js.map +1 -1
  54. package/dist/validation/blueprints.d.ts +1 -0
  55. package/dist/validation/blueprints.js +1 -0
  56. package/dist/validation/blueprints.js.map +1 -1
  57. package/dist/validation/cors.d.ts +1 -0
  58. package/dist/validation/cors.js +1 -0
  59. package/dist/validation/cors.js.map +1 -1
  60. package/dist/validation/datasets.d.ts +2 -0
  61. package/dist/validation/datasets.js +2 -0
  62. package/dist/validation/datasets.js.map +1 -1
  63. package/dist/validation/functions.d.ts +11 -0
  64. package/dist/validation/functions.js +37 -1
  65. package/dist/validation/functions.js.map +1 -1
  66. package/dist/validation/resources.d.ts +7 -1
  67. package/dist/validation/resources.js +20 -14
  68. package/dist/validation/resources.js.map +1 -1
  69. package/dist/validation/robotTokens.d.ts +15 -0
  70. package/dist/validation/robotTokens.js +104 -0
  71. package/dist/validation/robotTokens.js.map +1 -0
  72. package/dist/validation/robots.d.ts +4 -8
  73. package/dist/validation/robots.js +5 -96
  74. package/dist/validation/robots.js.map +1 -1
  75. package/dist/validation/roles.d.ts +3 -1
  76. package/dist/validation/roles.js +3 -1
  77. package/dist/validation/roles.js.map +1 -1
  78. package/dist/validation/webhooks.d.ts +1 -0
  79. package/dist/validation/webhooks.js +1 -0
  80. package/dist/validation/webhooks.js.map +1 -1
  81. package/package.json +7 -4
  82. package/src/definers/blueprints.ts +42 -3
  83. package/src/definers/cors.ts +21 -2
  84. package/src/definers/datasets.ts +23 -2
  85. package/src/definers/functions.ts +159 -123
  86. package/src/definers/resources.ts +23 -0
  87. package/src/definers/robotTokens.ts +56 -0
  88. package/src/definers/robots.ts +2 -33
  89. package/src/definers/roles.ts +70 -23
  90. package/src/definers/webhooks.ts +29 -2
  91. package/src/index.ts +25 -0
  92. package/src/types/blueprints.ts +16 -4
  93. package/src/types/cors.ts +6 -0
  94. package/src/types/datasets.ts +19 -3
  95. package/src/types/errors.ts +4 -1
  96. package/src/types/functions.ts +156 -16
  97. package/src/types/resources.ts +17 -1
  98. package/src/types/robotTokens.ts +50 -0
  99. package/src/types/robots.ts +10 -35
  100. package/src/types/roles.ts +12 -3
  101. package/src/types/webhooks.ts +23 -5
  102. package/src/utils/schedule-parser.ts +502 -0
  103. package/src/utils/validation.ts +1 -0
  104. package/src/validation/blueprints.ts +1 -0
  105. package/src/validation/cors.ts +1 -0
  106. package/src/validation/datasets.ts +2 -0
  107. package/src/validation/functions.ts +37 -0
  108. package/src/validation/resources.ts +20 -14
  109. package/src/validation/robotTokens.ts +103 -0
  110. package/src/validation/robots.ts +5 -95
  111. package/src/validation/roles.ts +3 -1
  112. package/src/validation/webhooks.ts +1 -0
@@ -1,26 +1,47 @@
1
1
  import { validateProjectRole, validateRole, } from '../index.js';
2
2
  import { runValidation } from '../utils/validation.js';
3
- /**
4
- * Defines a role that is scoped to the same resource as the blueprint.
5
- * ```
3
+ /*
4
+ * FUTURE example (move below @example when ready)
5
+ * @example All options
6
+ * ```ts
6
7
  * defineRole({
7
- * name: 'custom-robot-role',
8
- * title: 'Custom Robot Role',
8
+ * name: 'ci-deploy-role',
9
+ * title: 'CI Deploy Role',
10
+ * description: 'Permissions for CI/CD pipelines to manage CORS and datasets',
9
11
  * appliesToRobots: true,
10
12
  * appliesToUsers: false,
11
13
  * permissions: [{
12
14
  * name: 'sanity-project-cors',
13
- * action: 'create'
15
+ * action: 'create',
14
16
  * }, {
15
17
  * name: 'sanity-project-cors',
16
- * action: 'read'
18
+ * action: 'read',
17
19
  * }, {
18
20
  * name: 'sanity-project-cors',
19
- * action: 'delete'
20
- * }]
21
- * }),
21
+ * action: 'delete',
22
+ * }],
23
+ * })
24
+ * ```
25
+ */
26
+ /**
27
+ * Defines a role that is scoped to the same resource as the blueprint.
28
+ *
29
+ * ```ts
30
+ * defineRole({
31
+ * name: 'custom-robot-role',
32
+ * title: 'Custom Robot Role',
33
+ * appliesToRobots: true,
34
+ * permissions: [{
35
+ * name: 'sanity-project-cors',
36
+ * action: 'create',
37
+ * }],
38
+ * })
22
39
  * ```
23
40
  * @param parameters The configuration of the role
41
+ * @public
42
+ * @beta Deploying Roles via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
43
+ * @category Definers
44
+ * @expandType BlueprintRoleConfig
24
45
  * @returns The role resource
25
46
  */
26
47
  export function defineRole(parameters, options) {
@@ -40,26 +61,52 @@ export function defineRole(parameters, options) {
40
61
  runValidation(() => validateRole(roleResource));
41
62
  return roleResource;
42
63
  }
43
- /**
44
- * Defines a role that is scoped to the specified project.
45
- * ```
46
- * defineProjectRole(projectId, {
47
- * name: 'custom-robot-role',
48
- * title: 'Custom Robot Role',
64
+ /*
65
+ * FUTURE example (move below @example when ready)
66
+ * @example Cross-resource references
67
+ * ```ts
68
+ * const role = defineProjectRole(projectId, {
69
+ * name: 'ci-deploy-role',
70
+ * title: 'CI Deploy Role',
49
71
  * appliesToRobots: true,
50
- * appliesToUsers: false,
51
72
  * permissions: [{
52
73
  * name: 'sanity-project-cors',
53
- * action: 'create'
74
+ * action: 'create',
54
75
  * }, {
55
76
  * name: 'sanity-project-cors',
56
- * action: 'read'
57
- * }, {
77
+ * action: 'delete',
78
+ * }],
79
+ * })
80
+ *
81
+ * defineRobotToken({
82
+ * name: 'ci-robot',
83
+ * memberships: [{
84
+ * resourceType: 'project',
85
+ * resourceId: projectId,
86
+ * roleNames: ['$.resources.ci-deploy-role'],
87
+ * }],
88
+ * })
89
+ * ```
90
+ */
91
+ /**
92
+ * Defines a role that is scoped to the specified project.
93
+ *
94
+ * ```ts
95
+ * defineProjectRole(projectId, {
96
+ * name: 'viewer-role',
97
+ * title: 'Viewer',
98
+ * appliesToUsers: true,
99
+ * permissions: [{
58
100
  * name: 'sanity-project-cors',
59
- * action: 'delete'
60
- * }]
61
- * }),
101
+ * action: 'read',
102
+ * }],
103
+ * })
62
104
  * ```
105
+ * @public
106
+ * @beta Deploying Roles via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
107
+ * @hidden
108
+ * @category Definers
109
+ * @expandType BlueprintRoleConfig
63
110
  * @param projectId The ID of the project to which the role will be scoped
64
111
  * @param parameters The configuration of the role
65
112
  * @returns The role resource
@@ -1 +1 @@
1
- {"version":3,"file":"roles.js","sourceRoot":"","sources":["../../src/definers/roles.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,mBAAmB,EACnB,YAAY,GACb,MAAM,aAAa,CAAA;AACpB,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AAEpD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,UAAU,CAAC,UAA+B,EAAE,OAAoC;IAC9F,MAAM,YAAY,GAA0B;QAC1C,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,IAAI,EAAE,oBAAoB;QAC1B,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,cAAc,EAAE,UAAU,CAAC,cAAc;QACzC,eAAe,EAAE,UAAU,CAAC,eAAe;QAC3C,WAAW,EAAE,UAAU,CAAC,WAAW;KACpC,CAAA;IAED,IAAI,UAAU,CAAC,SAAS,EAAE,CAAC;QACzB,YAAY,CAAC,SAAS,GAAG,UAAU,CAAC,SAAS,CAAA;IAC/C,CAAC;IAED,IAAI,OAAO,EAAE,cAAc,KAAK,IAAI;QAAE,aAAa,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAA;IAErF,OAAO,YAAY,CAAA;AACrB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAiB,EAAE,UAA+B;IAClF,MAAM,YAAY,GAAG,UAAU,CAAC,UAAU,EAAE,EAAC,cAAc,EAAE,IAAI,EAAC,CAAC,CAAA;IAEnE,MAAM,mBAAmB,GAAiC;QACxD,GAAG,YAAY;QACf,YAAY,EAAE,SAAS;QACvB,UAAU,EAAE,SAAS;KACtB,CAAA;IAED,aAAa,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,CAAC,CAAA;IAE7D,OAAO,mBAAmB,CAAA;AAC5B,CAAC"}
1
+ {"version":3,"file":"roles.js","sourceRoot":"","sources":["../../src/definers/roles.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,mBAAmB,EACnB,YAAY,GACb,MAAM,aAAa,CAAA;AACpB,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AAEpD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,UAAU,CAAC,UAA+B,EAAE,OAAoC;IAC9F,MAAM,YAAY,GAA0B;QAC1C,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,IAAI,EAAE,oBAAoB;QAC1B,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,cAAc,EAAE,UAAU,CAAC,cAAc;QACzC,eAAe,EAAE,UAAU,CAAC,eAAe;QAC3C,WAAW,EAAE,UAAU,CAAC,WAAW;KACpC,CAAA;IAED,IAAI,UAAU,CAAC,SAAS,EAAE,CAAC;QACzB,YAAY,CAAC,SAAS,GAAG,UAAU,CAAC,SAAS,CAAA;IAC/C,CAAC;IAED,IAAI,OAAO,EAAE,cAAc,KAAK,IAAI;QAAE,aAAa,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAA;IAErF,OAAO,YAAY,CAAA;AACrB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAiB,EAAE,UAA+B;IAClF,MAAM,YAAY,GAAG,UAAU,CAAC,UAAU,EAAE,EAAC,cAAc,EAAE,IAAI,EAAC,CAAC,CAAA;IAEnE,MAAM,mBAAmB,GAAiC;QACxD,GAAG,YAAY;QACf,YAAY,EAAE,SAAS;QACvB,UAAU,EAAE,SAAS;KACtB,CAAA;IAED,aAAa,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,CAAC,CAAA;IAE7D,OAAO,mBAAmB,CAAA;AAC5B,CAAC"}
@@ -1,15 +1,22 @@
1
1
  import { type BlueprintDocumentWebhookConfig, type BlueprintDocumentWebhookResource } from '../index.js';
2
2
  /**
3
3
  * Defines a webhook that is called when document changes occur.
4
- * ```
4
+ *
5
+ * ```ts
5
6
  * defineDocumentWebhook({
6
7
  * name: 'my-webhook',
7
8
  * on: ['create'],
8
9
  * url: 'https://example.com/webhook',
9
10
  * projection: '{_id}',
10
- * dataset: 'staging'
11
+ * dataset: 'production',
12
+ * apiVersion: 'v2026-01-01',
11
13
  * })
12
14
  * ```
13
15
  * @param parameters The webhook configuration
16
+ * @public
17
+ * @beta Deploying Webhooks via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
18
+ * @category Definers
19
+ * @expandType BlueprintDocumentWebhookConfig
20
+ * @returns The webhook resource
14
21
  */
15
22
  export declare function defineDocumentWebhook(parameters: BlueprintDocumentWebhookConfig): BlueprintDocumentWebhookResource;
@@ -1,17 +1,44 @@
1
1
  import { validateDocumentWebhook } from '../index.js';
2
2
  import { runValidation } from '../utils/validation.js';
3
+ /*
4
+ * FUTURE example (move below @example when ready)
5
+ * @example All options
6
+ * ```ts
7
+ * defineDocumentWebhook({
8
+ * name: 'sync-webhook',
9
+ * url: 'https://example.com/sync',
10
+ * on: ['create', 'update', 'delete'],
11
+ * dataset: 'production',
12
+ * apiVersion: 'v2026-01-01',
13
+ * filter: "_type == 'product'",
14
+ * projection: '{_id, title, slug}',
15
+ * httpMethod: 'POST',
16
+ * headers: {'X-Custom-Header': 'value'},
17
+ * secret: 'my-webhook-secret',
18
+ * includeDrafts: false,
19
+ * status: 'enabled',
20
+ * })
21
+ * ```
22
+ */
3
23
  /**
4
24
  * Defines a webhook that is called when document changes occur.
5
- * ```
25
+ *
26
+ * ```ts
6
27
  * defineDocumentWebhook({
7
28
  * name: 'my-webhook',
8
29
  * on: ['create'],
9
30
  * url: 'https://example.com/webhook',
10
31
  * projection: '{_id}',
11
- * dataset: 'staging'
32
+ * dataset: 'production',
33
+ * apiVersion: 'v2026-01-01',
12
34
  * })
13
35
  * ```
14
36
  * @param parameters The webhook configuration
37
+ * @public
38
+ * @beta Deploying Webhooks via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
39
+ * @category Definers
40
+ * @expandType BlueprintDocumentWebhookConfig
41
+ * @returns The webhook resource
15
42
  */
16
43
  export function defineDocumentWebhook(parameters) {
17
44
  // default the display name
@@ -1 +1 @@
1
- {"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../src/definers/webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6E,uBAAuB,EAAC,MAAM,aAAa,CAAA;AAC/H,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AAEpD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,qBAAqB,CAAC,UAA0C;IAC9E,2BAA2B;IAC3B,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;QAC5B,UAAU,CAAC,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IAC5D,CAAC;IAED,MAAM,eAAe,GAAqC;QACxD,GAAG,UAAU;QACb,IAAI,EAAE,wBAAwB;KAC/B,CAAA;IAED,aAAa,CAAC,GAAG,EAAE,CAAC,uBAAuB,CAAC,eAAe,CAAC,CAAC,CAAA;IAE7D,OAAO,eAAe,CAAA;AACxB,CAAC"}
1
+ {"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../src/definers/webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6E,uBAAuB,EAAC,MAAM,aAAa,CAAA;AAC/H,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AAEpD;;;;;;;;;;;;;;;;;;;GAmBG;AACH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,qBAAqB,CAAC,UAA0C;IAC9E,2BAA2B;IAC3B,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;QAC5B,UAAU,CAAC,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IAC5D,CAAC;IAED,MAAM,eAAe,GAAqC;QACxD,GAAG,UAAU;QACb,IAAI,EAAE,wBAAwB;KAC/B,CAAA;IAED,aAAa,CAAC,GAAG,EAAE,CAAC,uBAAuB,CAAC,eAAe,CAAC,CAAC,CAAA;IAE7D,OAAO,eAAe,CAAA;AACxB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,11 +1,24 @@
1
+ /**
2
+ * @categoryDescription Definers
3
+ * These functions are used to define resources in a Blueprint.
4
+ */
1
5
  export * from './definers/blueprints.js';
2
6
  export * from './definers/cors.js';
3
7
  export * from './definers/datasets.js';
4
8
  export * from './definers/functions.js';
5
9
  export * from './definers/resources.js';
6
10
  export * from './definers/robots.js';
11
+ export * from './definers/robotTokens.js';
7
12
  export * from './definers/roles.js';
8
13
  export * from './definers/webhooks.js';
14
+ /**
15
+ * @categoryDescription Resource Types
16
+ * These types are used to define the shape of resources in a Blueprint.
17
+ */
18
+ /**
19
+ * @categoryDescription Functions Types
20
+ * Resource types for functions in a Blueprint.
21
+ */
9
22
  export * from './types/blueprints.js';
10
23
  export * from './types/cors.js';
11
24
  export * from './types/datasets.js';
@@ -13,13 +26,23 @@ export * from './types/errors.js';
13
26
  export * from './types/functions.js';
14
27
  export * from './types/resources.js';
15
28
  export * from './types/robots.js';
29
+ export * from './types/robotTokens.js';
16
30
  export * from './types/roles.js';
17
31
  export * from './types/webhooks.js';
32
+ /**
33
+ * @categoryDescription Validation
34
+ * These functions are used to validate resources in a Blueprint.
35
+ */
18
36
  export * from './validation/blueprints.js';
19
37
  export * from './validation/cors.js';
20
38
  export * from './validation/datasets.js';
21
39
  export * from './validation/functions.js';
22
40
  export * from './validation/resources.js';
23
41
  export * from './validation/robots.js';
42
+ export * from './validation/robotTokens.js';
24
43
  export * from './validation/roles.js';
25
44
  export * from './validation/webhooks.js';
45
+ /**
46
+ * @categoryDescription Blueprint Internals
47
+ * Miscellaneous Blueprint types that make up the public API but are not exported directly.
48
+ */
package/dist/index.js CHANGED
@@ -1,13 +1,26 @@
1
1
  // DEFINERS - helper functions to create resources
2
+ /**
3
+ * @categoryDescription Definers
4
+ * These functions are used to define resources in a Blueprint.
5
+ */
2
6
  export * from './definers/blueprints.js';
3
7
  export * from './definers/cors.js';
4
8
  export * from './definers/datasets.js';
5
9
  export * from './definers/functions.js';
6
10
  export * from './definers/resources.js';
7
11
  export * from './definers/robots.js';
12
+ export * from './definers/robotTokens.js';
8
13
  export * from './definers/roles.js';
9
14
  export * from './definers/webhooks.js';
10
15
  // TYPES - base types for all resources
16
+ /**
17
+ * @categoryDescription Resource Types
18
+ * These types are used to define the shape of resources in a Blueprint.
19
+ */
20
+ /**
21
+ * @categoryDescription Functions Types
22
+ * Resource types for functions in a Blueprint.
23
+ */
11
24
  export * from './types/blueprints.js';
12
25
  export * from './types/cors.js';
13
26
  export * from './types/datasets.js';
@@ -15,15 +28,26 @@ export * from './types/errors.js';
15
28
  export * from './types/functions.js';
16
29
  export * from './types/resources.js';
17
30
  export * from './types/robots.js';
31
+ export * from './types/robotTokens.js';
18
32
  export * from './types/roles.js';
19
33
  export * from './types/webhooks.js';
20
34
  // VALIDATION - validation for all resources
35
+ /**
36
+ * @categoryDescription Validation
37
+ * These functions are used to validate resources in a Blueprint.
38
+ */
21
39
  export * from './validation/blueprints.js';
22
40
  export * from './validation/cors.js';
23
41
  export * from './validation/datasets.js';
24
42
  export * from './validation/functions.js';
25
43
  export * from './validation/resources.js';
26
44
  export * from './validation/robots.js';
45
+ export * from './validation/robotTokens.js';
27
46
  export * from './validation/roles.js';
28
47
  export * from './validation/webhooks.js';
48
+ // Public BLUEPRINTS INTERNALS - published bucket of misc Blueprint types
49
+ /**
50
+ * @categoryDescription Blueprint Internals
51
+ * Miscellaneous Blueprint types that make up the public API but are not exported directly.
52
+ */
29
53
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,cAAc,0BAA0B,CAAA;AACxC,cAAc,oBAAoB,CAAA;AAClC,cAAc,wBAAwB,CAAA;AACtC,cAAc,yBAAyB,CAAA;AACvC,cAAc,yBAAyB,CAAA;AACvC,cAAc,sBAAsB,CAAA;AACpC,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA;AAEtC,uCAAuC;AACvC,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AAEnC,4CAA4C;AAC5C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,sBAAsB,CAAA;AACpC,cAAc,0BAA0B,CAAA;AACxC,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA;AACzC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,0BAA0B,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD;;;GAGG;AACH,cAAc,0BAA0B,CAAA;AACxC,cAAc,oBAAoB,CAAA;AAClC,cAAc,wBAAwB,CAAA;AACtC,cAAc,yBAAyB,CAAA;AACvC,cAAc,yBAAyB,CAAA;AACvC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA;AAEtC,uCAAuC;AACvC;;;GAGG;AACH;;;GAGG;AACH,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AAEnC,4CAA4C;AAC5C;;;GAGG;AACH,cAAc,4BAA4B,CAAA;AAC1C,cAAc,sBAAsB,CAAA;AACpC,cAAc,0BAA0B,CAAA;AACxC,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA;AACzC,cAAc,wBAAwB,CAAA;AACtC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,uBAAuB,CAAA;AACrC,cAAc,0BAA0B,CAAA;AAExC,yEAAyE;AACzE;;;GAGG"}
@@ -1,16 +1,25 @@
1
1
  import type { BlueprintResource } from '../index.js';
2
- /** Additional configuration on a Blueprint that overrides the normal configuration */
2
+ /**
3
+ * Additional configuration on a Blueprint that overrides the normal configuration
4
+ * @internal
5
+ */
3
6
  export interface BlueprintsApiConfig {
4
7
  organizationId: string;
5
8
  projectId: string;
6
9
  stackId: string;
7
10
  }
8
- /** A key-value pair that will be output from a Blueprint */
11
+ /**
12
+ * A key-value pair that will be output from a Blueprint
13
+ * @internal
14
+ */
9
15
  export interface BlueprintOutput {
10
16
  name: string;
11
17
  value: string;
12
18
  }
13
- /** A representation of a Blueprint document */
19
+ /**
20
+ * A representation of a Blueprint document
21
+ * @category Blueprint Internals
22
+ */
14
23
  export interface Blueprint {
15
24
  $schema: string;
16
25
  blueprintVersion: string;
@@ -18,5 +27,8 @@ export interface Blueprint {
18
27
  values?: Record<string, unknown>;
19
28
  outputs?: BlueprintOutput[];
20
29
  }
21
- /** The result of defining a blueprint with `defineBlueprint` */
30
+ /**
31
+ * The result of defining a blueprint with `defineBlueprint`
32
+ * @internal
33
+ */
22
34
  export type BlueprintModule = ((args?: unknown) => Blueprint) & Partial<BlueprintsApiConfig>;
@@ -2,6 +2,8 @@ import type { BlueprintProjectResourceLifecycle, BlueprintResource } from '../in
2
2
  /**
3
3
  * Represents a CORS Origin resource.
4
4
  * @see https://www.sanity.io/docs/content-lake/cors
5
+ * @beta This feature is subject to breaking changes.
6
+ * @category Resource Types
5
7
  */
6
8
  export interface BlueprintCorsOriginResource extends BlueprintResource<BlueprintProjectResourceLifecycle> {
7
9
  type: 'sanity.project.cors';
@@ -28,6 +30,9 @@ export interface BlueprintCorsOriginResource extends BlueprintResource<Blueprint
28
30
  /**
29
31
  * Configuration for a CORS Origin resource.
30
32
  * @see https://www.sanity.io/docs/content-lake/cors
33
+ * @beta This feature is subject to breaking changes.
34
+ * @category Resource Types
35
+ * @interface
31
36
  */
32
37
  export type BlueprintCorsOriginConfig = Omit<BlueprintCorsOriginResource, 'type' | 'allowCredentials'> & {
33
38
  /**
@@ -36,6 +41,7 @@ export type BlueprintCorsOriginConfig = Omit<BlueprintCorsOriginResource, 'type'
36
41
  * If this origin hosts a studio, you will need to allow credentials. Otherwise, you should probably select not to allow credentials.
37
42
  *
38
43
  * Allowing credentials from wildcard origins is dangerous. Any domain that matches the given pattern will be able to send requests on the user's behalf if they are logged in to your studio.
44
+ * @defaultValue false
39
45
  */
40
46
  allowCredentials?: boolean;
41
47
  };
@@ -1,10 +1,19 @@
1
- import type { BlueprintResource } from '../index.js';
1
+ import type { BlueprintProjectResourceLifecycle, BlueprintResource } from '../index.js';
2
+ /**
3
+ * The ACL mode for a dataset.
4
+ * @alpha
5
+ * @hidden
6
+ * @category Resource Types
7
+ */
2
8
  export type AclMode = 'public' | 'private' | 'custom';
3
9
  /**
4
10
  * Represents a Dataset resource.
5
11
  * @see https://www.sanity.io/docs/content-lake/datasets
12
+ * @alpha This feature is subject to breaking changes.
13
+ * @hidden
14
+ * @category Resource Types
6
15
  */
7
- export interface BlueprintDatasetResource extends BlueprintResource {
16
+ export interface BlueprintDatasetResource extends BlueprintResource<BlueprintProjectResourceLifecycle> {
8
17
  type: 'sanity.project.dataset';
9
18
  /** The name of the dataset. Must be unique within a project. */
10
19
  datasetName: string;
@@ -20,8 +29,15 @@ export interface BlueprintDatasetResource extends BlueprintResource {
20
29
  /**
21
30
  * Configuration for a Dataset resource.
22
31
  * @see https://www.sanity.io/docs/content-lake/datasets
32
+ * @alpha This feature is subject to breaking changes.
33
+ * @hidden
34
+ * @category Resource Types
35
+ * @interface
23
36
  */
24
37
  export type BlueprintDatasetConfig = Omit<BlueprintDatasetResource, 'type' | 'datasetName'> & {
25
- /** The name of the dataset. Must be unique within a project. Defaults to the name of the resource. */
38
+ /**
39
+ * The name of the dataset. Must be unique within a project.
40
+ * @defaultValue The `name` of the resource
41
+ */
26
42
  datasetName?: string;
27
43
  };
@@ -1,4 +1,7 @@
1
- /** Standard error shape returned by validation functions */
1
+ /**
2
+ * Standard error shape returned by validation functions
3
+ * @internal
4
+ */
2
5
  export interface BlueprintError {
3
6
  message: string;
4
7
  type: string;
@@ -1,7 +1,13 @@
1
1
  import type { BlueprintResource } from '../index.js';
2
- /** Base event configuration shared by document and media library function types */
2
+ /**
3
+ * Base event configuration shared by document and media library function types
4
+ * @category Functions Types
5
+ */
3
6
  export interface BlueprintFunctionBaseResourceEvent {
4
- /** Event types that trigger the function. Defaults to ['publish'] */
7
+ /**
8
+ * Event types that trigger the function
9
+ * @defaultValue ['publish']
10
+ */
5
11
  on?: [BlueprintFunctionResourceEventName, ...BlueprintFunctionResourceEventName[]];
6
12
  /** GROQ filter expression to match specific documents (e.g., "_type == 'post'") */
7
13
  filter?: string;
@@ -10,23 +16,33 @@ export interface BlueprintFunctionBaseResourceEvent {
10
16
  /** Include draft documents in addition to published documents */
11
17
  includeDrafts?: boolean;
12
18
  }
13
- /** Event configuration for document functions */
19
+ /**
20
+ * Event configuration for document functions
21
+ * @category Functions Types
22
+ */
14
23
  export interface BlueprintDocumentFunctionResourceEvent extends BlueprintFunctionBaseResourceEvent {
15
24
  /** Include all versions of documents, not just the current version */
16
25
  includeAllVersions?: boolean;
17
26
  /** Optional dataset resource scoping for the function */
18
27
  resource?: BlueprintFunctionResourceEventResourceDataset;
19
28
  }
20
- /** Event configuration for media library asset functions */
29
+ /**
30
+ * Event configuration for media library asset functions
31
+ * @category Functions Types
32
+ */
21
33
  export interface BlueprintMediaLibraryFunctionResourceEvent extends BlueprintFunctionBaseResourceEvent {
22
34
  /** Media library resource scoping (required for media library functions) */
23
35
  resource: BlueprintFunctionResourceEventResourceMediaLibrary;
24
36
  }
25
- /** Union type of all function resource event configurations */
37
+ /**
38
+ * Union type of all function resource event configurations
39
+ * @category Functions Types
40
+ */
26
41
  export type BlueprintFunctionResourceEvent = BlueprintDocumentFunctionResourceEvent | BlueprintMediaLibraryFunctionResourceEvent;
27
42
  /**
28
- * Dataset resource for scoping document functions to specific datasets
29
- * @example { type: 'dataset', id: 'my-project.production' }
43
+ * Explicit resource event for schedule functions to specific minutes, hours, days of month, months, and days of week
44
+ * @example { minute: '0', hour: '9', dayOfMonth: '1', month: '1', dayOfWeek: '1' }
45
+ * @category Functions Types
30
46
  */
31
47
  export interface BlueprintScheduleFunctionExplicitResourceEvent {
32
48
  minute: string;
@@ -35,23 +51,56 @@ export interface BlueprintScheduleFunctionExplicitResourceEvent {
35
51
  month: string;
36
52
  dayOfWeek: string;
37
53
  }
54
+ /**
55
+ * Expression resource for schedule functions to specific expressions
56
+ * @example { expression: '0 9 * * *' }
57
+ * @category Functions Types
58
+ */
38
59
  export interface BlueprintScheduleFunctionExpressionResourceEvent {
39
60
  expression: string;
40
61
  }
62
+ /**
63
+ * Union type of all schedule function resource event configurations
64
+ * @category Functions Types
65
+ */
41
66
  export type BlueprintScheduleFunctionResourceEvent = BlueprintScheduleFunctionExplicitResourceEvent | BlueprintScheduleFunctionExpressionResourceEvent;
42
- interface BlueprintFunctionResourceEventResourceDataset {
67
+ /**
68
+ * Dataset resource for scoping document functions to specific datasets
69
+ * @example { type: 'dataset', id: 'my-project.production' }
70
+ * @category Functions Types
71
+ */
72
+ export interface BlueprintFunctionResourceEventResourceDataset {
43
73
  type: 'dataset';
44
- /** @description A dataset ID in the format <projectId>.<datasetName>. <datasetName> can be `*` to signify "all datasets in project with ID <projectId>." */
74
+ /** A dataset ID in the format <projectId>.<datasetName>. <datasetName> can be `*` to signify "all datasets in project with ID <projectId>." */
45
75
  id: string;
46
76
  }
47
- /** Media library resource for scoping media library functions */
48
- interface BlueprintFunctionResourceEventResourceMediaLibrary {
77
+ /**
78
+ * Media library resource for scoping media library functions
79
+ * @category Functions Types
80
+ */
81
+ export interface BlueprintFunctionResourceEventResourceMediaLibrary {
49
82
  type: 'media-library';
50
83
  id: string;
51
84
  }
52
- /** Events that can trigger a function */
53
- type BlueprintFunctionResourceEventName = 'publish' | 'create' | 'delete' | 'update';
54
- /** Base function resource with common properties for all function types */
85
+ /**
86
+ * Events that can trigger a function
87
+ * @category Functions Types
88
+ */
89
+ export type BlueprintFunctionResourceEventName = 'publish' | 'create' | 'delete' | 'update';
90
+ /**
91
+ * Current support Function runtimes
92
+ * @category Functions Types
93
+ */
94
+ export declare const VALID_RUNTIMES: readonly ["node", "nodejs22.x", "nodejs24.x"];
95
+ /**
96
+ * Supported function runtimes
97
+ * @category Functions Types
98
+ */
99
+ export type FunctionRuntimes = (typeof VALID_RUNTIMES)[number];
100
+ /**
101
+ * Base function resource with common properties for all function types
102
+ * @category Functions Types
103
+ */
55
104
  export interface BlueprintBaseFunctionResource extends BlueprintResource {
56
105
  /** Human-readable display name for the function */
57
106
  displayName?: string;
@@ -70,22 +119,95 @@ export interface BlueprintBaseFunctionResource extends BlueprintResource {
70
119
  *
71
120
  * The `project` attribute must be defined if your blueprint is scoped to an organization. */
72
121
  project?: string;
122
+ /**
123
+ * The runtime environment for the function (currently only Node.js is supported)
124
+ * @defaultValue 'nodejs24.x'
125
+ */
126
+ runtime?: FunctionRuntimes;
73
127
  }
74
- /** A function resource triggered by document events in Sanity datasets */
128
+ /**
129
+ * A function resource triggered by document events in Sanity datasets
130
+ * @category Functions Types
131
+ */
75
132
  export interface BlueprintDocumentFunctionResource extends BlueprintBaseFunctionResource {
76
133
  type: 'sanity.function.document';
77
134
  /** Event configuration specifying when and how the function is triggered */
78
135
  event: BlueprintDocumentFunctionResourceEvent;
79
136
  }
80
- /** A function resource triggered by media library asset events */
137
+ /**
138
+ * A function resource triggered by media library asset events
139
+ * @category Functions Types
140
+ */
81
141
  export interface BlueprintMediaLibraryAssetFunctionResource extends BlueprintBaseFunctionResource {
82
142
  type: 'sanity.function.media-library.asset';
83
143
  /** Event configuration specifying when and how the function is triggered */
84
144
  event: BlueprintMediaLibraryFunctionResourceEvent;
85
145
  }
146
+ /**
147
+ * A function resource triggered by schedule events
148
+ * @category Functions Types
149
+ */
86
150
  export interface BlueprintScheduleFunctionResource extends BlueprintBaseFunctionResource {
87
151
  type: 'sanity.function.cron';
88
152
  event: BlueprintScheduleFunctionResourceEvent;
89
153
  timezone?: string;
90
154
  }
91
- export {};
155
+ /**
156
+ * Configuration for defining a base function.
157
+ * @internal
158
+ * @category Functions Types
159
+ * @interface
160
+ */
161
+ export type BlueprintBaseFunctionConfig = Omit<BlueprintBaseFunctionResource, 'type' | 'src'> & {
162
+ /**
163
+ * Path to the function source code
164
+ * @defaultValue `functions/${name}`
165
+ */
166
+ src?: string;
167
+ };
168
+ /**
169
+ * Configuration for defining a document function.
170
+ * @public
171
+ * @category Functions Types
172
+ * @interface
173
+ */
174
+ export type BlueprintDocumentFunctionConfig = Omit<BlueprintDocumentFunctionResource, 'type' | 'src' | 'event'> & {
175
+ /**
176
+ * Path to the function source code
177
+ * @defaultValue `functions/${name}`
178
+ */
179
+ src?: string;
180
+ /**
181
+ * Event configuration specifying when and how the function is triggered
182
+ * @defaultValue `{on: ['publish']}`
183
+ */
184
+ event?: BlueprintDocumentFunctionResourceEvent;
185
+ };
186
+ /**
187
+ * Configuration for defining a media library asset function.
188
+ * @public
189
+ * @category Functions Types
190
+ * @interface
191
+ */
192
+ export type BlueprintMediaLibraryAssetFunctionConfig = Omit<BlueprintMediaLibraryAssetFunctionResource, 'type' | 'src'> & {
193
+ /**
194
+ * Path to the function source code
195
+ * @defaultValue `functions/${name}`
196
+ */
197
+ src?: string;
198
+ };
199
+ /**
200
+ * Configuration for defining a schedule function.
201
+ * @public
202
+ * @alpha Deploying Schedule Functions via Blueprints is experimental. This feature is not available publicly yet.
203
+ * @hidden
204
+ * @category Functions Types
205
+ * @interface
206
+ */
207
+ export type BlueprintScheduleFunctionConfig = Omit<BlueprintScheduleFunctionResource, 'type' | 'src'> & {
208
+ /**
209
+ * Path to the function source code
210
+ * @defaultValue `functions/${name}`
211
+ */
212
+ src?: string;
213
+ };
@@ -1,2 +1,6 @@
1
- export {};
1
+ /**
2
+ * Current support Function runtimes
3
+ * @category Functions Types
4
+ */
5
+ export const VALID_RUNTIMES = ['node', 'nodejs22.x', 'nodejs24.x'];
2
6
  //# sourceMappingURL=functions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"functions.js","sourceRoot":"","sources":["../../src/types/functions.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"functions.js","sourceRoot":"","sources":["../../src/types/functions.ts"],"names":[],"mappings":"AAwGA;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,YAAY,CAAU,CAAA"}