@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
@@ -5,11 +5,13 @@
5
5
  * - **replace** if a stack is deployed, the resource will be destroyed and created instead of performing an update. If the resource is removed from the blueprint, it will be destroyed. If the stack is destroyed, the resource will be destroyed.
6
6
  * - **allow** if a stack is destroyed, the resource will be destroyed along with it. If the resource is removed it will be destroyed
7
7
  * - **protect** if a stack is deployed the resource will not be updated. If the resource is removed from the blueprint or the stack is destroyed, deployment will fail.
8
+ * @category Blueprint Internals
8
9
  */
9
10
  export type BlueprintResourceDeletionPolicy = 'allow' | 'retain' | 'replace' | 'protect'
10
11
 
11
12
  /**
12
13
  * An ownership action that will cause the referenced resource to be attached to the current stack.
14
+ * @category Blueprint Internals
13
15
  */
14
16
  export interface BlueprintOwnershipAttachAction {
15
17
  type: 'attach'
@@ -18,17 +20,21 @@ export interface BlueprintOwnershipAttachAction {
18
20
  }
19
21
  /**
20
22
  * An ownership action that will cause the referenced resource to be detached from the current stack.
23
+ * @category Blueprint Internals
21
24
  */
22
25
  export interface BlueprintOwnershipDetachAction {
23
26
  type: 'detach'
24
27
  }
25
28
  /**
26
29
  * A union of all possible ownership actions.
30
+ * @category Blueprint Internals
31
+ * @expand
27
32
  */
28
33
  export type BlueprintOwnershipAction = BlueprintOwnershipAttachAction | BlueprintOwnershipDetachAction
29
34
 
30
35
  /**
31
36
  * An ownership action that will cause the referenced project-contained resource to be attached to the current stack.
37
+ * @category Blueprint Internals
32
38
  */
33
39
  export interface BlueprintProjectOwnershipAttachAction extends BlueprintOwnershipAttachAction {
34
40
  /** The identifier of the project for resources contained in a project */
@@ -36,11 +42,14 @@ export interface BlueprintProjectOwnershipAttachAction extends BlueprintOwnershi
36
42
  }
37
43
  /**
38
44
  * A union of all possible ownership actions for resources belonging to projects.
45
+ * @category Blueprint Internals
46
+ * @expand
39
47
  */
40
48
  export type BlueprintProjectOwnershipAction = BlueprintProjectOwnershipAttachAction
41
49
 
42
50
  /**
43
51
  * Defines the lifcycle policy for this resource.
52
+ * @category Blueprint Internals
44
53
  */
45
54
  export interface BlueprintResourceLifecycle {
46
55
  deletionPolicy?: BlueprintResourceDeletionPolicy
@@ -50,6 +59,8 @@ export interface BlueprintResourceLifecycle {
50
59
 
51
60
  /**
52
61
  * Defines the lifcycle policy for this resource.
62
+ * @category Blueprint Internals
63
+ * @experimental
53
64
  */
54
65
  export interface BlueprintProjectResourceLifecycle extends BlueprintResourceLifecycle {
55
66
  ownershipAction?: BlueprintProjectOwnershipAction
@@ -57,10 +68,15 @@ export interface BlueprintProjectResourceLifecycle extends BlueprintResourceLife
57
68
 
58
69
  /**
59
70
  * The base type for all resources.
71
+ * @category Blueprint Internals
60
72
  */
61
73
  export interface BlueprintResource<Lifecycle extends BlueprintResourceLifecycle = BlueprintResourceLifecycle> {
62
74
  type: string
63
75
  name: string
64
-
76
+ /**
77
+ * Defines the lifcycle policy for this resource.
78
+ * @experimental
79
+ * @hidden
80
+ */
65
81
  lifecycle?: Lifecycle
66
82
  }
@@ -0,0 +1,50 @@
1
+ import type {BlueprintProjectResourceLifecycle, BlueprintResource} from './resources'
2
+
3
+ /**
4
+ * Resource types that robot tokens can be attached to.
5
+ * @internal
6
+ */
7
+ export type RobotTokenResourceType = 'organization' | 'project'
8
+
9
+ /**
10
+ * Defines the robot token's roles within a given resource.
11
+ * @beta This feature is subject to breaking changes.
12
+ * @category Resource Types
13
+ * @expand
14
+ */
15
+ export interface RobotTokenMembership {
16
+ resourceType: RobotTokenResourceType
17
+ resourceId: string
18
+ roleNames: string[]
19
+ }
20
+
21
+ /**
22
+ * A robot token that provides automated access.
23
+ * @see https://www.sanity.io/docs/content-lake/http-auth#k4c21d7b829fe
24
+ * @beta This feature is subject to breaking changes.
25
+ * @category Resource Types
26
+ */
27
+ export interface BlueprintRobotTokenResource extends BlueprintResource<BlueprintProjectResourceLifecycle> {
28
+ type: 'sanity.access.robot'
29
+ /** A descriptive label for the robot token and its use case */
30
+ label: string
31
+ memberships: RobotTokenMembership[]
32
+
33
+ resourceType?: RobotTokenResourceType
34
+ resourceId?: string
35
+ }
36
+
37
+ /**
38
+ * Configuration for a robot token that provides automated access.
39
+ * @see https://www.sanity.io/docs/content-lake/http-auth#k4c21d7b829fe
40
+ * @beta This feature is subject to breaking changes.
41
+ * @category Resource Types
42
+ * @interface
43
+ */
44
+ export type BlueprintRobotTokenConfig = Omit<BlueprintRobotTokenResource, 'type' | 'label' | 'token'> & {
45
+ /**
46
+ * A descriptive label for the robot token and its use case
47
+ * @defaultValue The `name` of the resource
48
+ */
49
+ label?: string
50
+ }
@@ -1,35 +1,10 @@
1
- import type {BlueprintResource} from './resources'
2
-
3
- /** Resource types that robots can be attached to. */
4
- export type RobotResourceType = 'organization' | 'project'
5
-
6
- /**
7
- * Defines the robot's roles within a given resource.
8
- */
9
- export interface RobotMembership {
10
- resourceType: RobotResourceType
11
- resourceId: string
12
- roleNames: string[]
13
- }
14
-
15
- /**
16
- * A robot that provides a token for automated access.
17
- * @see https://www.sanity.io/docs/content-lake/http-auth#k4c21d7b829fe
18
- */
19
- export interface BlueprintRobotResource extends BlueprintResource {
20
- type: 'sanity.access.robot'
21
- /** A descriptive label for the robot and its use case */
22
- label: string
23
- memberships: RobotMembership[]
24
-
25
- resourceType?: RobotResourceType
26
- resourceId?: string
27
- }
28
-
29
- /**
30
- * Configuration for a robot that provides a token for automated access.
31
- * @see https://www.sanity.io/docs/content-lake/http-auth#k4c21d7b829fe
32
- */
33
- export type BlueprintRobotConfig = Omit<BlueprintRobotResource, 'type' | 'label' | 'token'> & {
34
- label?: string
35
- }
1
+ // biome-ignore-all assist/source/organizeImports: sorting imports moves typedocs
2
+
3
+ /** @deprecated Use {@link BlueprintRobotTokenConfig} instead @hidden */
4
+ export type {BlueprintRobotTokenConfig as BlueprintRobotConfig} from './robotTokens.js'
5
+ /** @deprecated Use {@link BlueprintRobotTokenResource} instead @hidden */
6
+ export type {BlueprintRobotTokenResource as BlueprintRobotResource} from './robotTokens.js'
7
+ /** @deprecated Use {@link RobotTokenMembership} instead @hidden */
8
+ export type {RobotTokenMembership as RobotMembership} from './robotTokens.js'
9
+ /** @deprecated Use {@link RobotTokenResourceType} instead @hidden */
10
+ export type {RobotTokenResourceType as RobotResourceType} from './robotTokens.js'
@@ -1,7 +1,10 @@
1
- import type {BlueprintResource} from '../index.js'
1
+ import type {BlueprintProjectResourceLifecycle, BlueprintResource} from '../index.js'
2
2
 
3
3
  /**
4
4
  * A permission definition for a role.
5
+ * @beta This feature is subject to breaking changes.
6
+ * @category Resource Types
7
+ * @expand
5
8
  */
6
9
  export interface RolePermission {
7
10
  /** Predefined permission name (e.g., 'sanity-all-documents') */
@@ -14,8 +17,10 @@ export interface RolePermission {
14
17
 
15
18
  /**
16
19
  * Configuration for a custom role.
20
+ * @beta This feature is subject to breaking changes.
21
+ * @category Resource Types
17
22
  */
18
- export interface BlueprintRoleConfig extends Omit<BlueprintResource, 'type'> {
23
+ export interface BlueprintRoleConfig extends Omit<BlueprintResource<BlueprintProjectResourceLifecycle>, 'type'> {
19
24
  title: string
20
25
  description?: string
21
26
  appliesToUsers: boolean
@@ -25,13 +30,17 @@ export interface BlueprintRoleConfig extends Omit<BlueprintResource, 'type'> {
25
30
 
26
31
  /**
27
32
  * A custom role resource
33
+ * @beta This feature is subject to breaking changes.
34
+ * @category Resource Types
28
35
  */
29
- export interface BlueprintRoleResource extends BlueprintRoleConfig, BlueprintResource {
36
+ export interface BlueprintRoleResource extends BlueprintRoleConfig, BlueprintResource<BlueprintProjectResourceLifecycle> {
30
37
  type: 'sanity.access.role'
31
38
  }
32
39
 
33
40
  /**
34
41
  * A custom role resource that is tied to a specific project
42
+ * @beta This feature is subject to breaking changes.
43
+ * @category Resource Types
35
44
  */
36
45
  export interface BlueprintProjectRoleResource extends BlueprintRoleResource {
37
46
  resourceType: 'project'
@@ -1,12 +1,24 @@
1
- import type {BlueprintResource} from '../index.js'
1
+ import type {BlueprintProjectResourceLifecycle, BlueprintResource} from '../index.js'
2
2
 
3
- /** Types of events that can trigger a webhook */
3
+ /**
4
+ * Types of events that can trigger a webhook
5
+ * @beta This feature is subject to breaking changes.
6
+ * @category Resource Types
7
+ */
4
8
  export type WebhookTrigger = 'create' | 'update' | 'delete'
5
9
 
6
- /** A webhook resource definition */
7
- export interface BlueprintDocumentWebhookResource extends BlueprintResource {
10
+ /**
11
+ * A webhook resource definition
12
+ * @beta This feature is subject to breaking changes.
13
+ * @category Resource Types
14
+ */
15
+ export interface BlueprintDocumentWebhookResource extends BlueprintResource<BlueprintProjectResourceLifecycle> {
8
16
  type: 'sanity.project.webhook'
9
17
  project?: string
18
+ /**
19
+ * Display name shown in the Sanity dashboard
20
+ * @defaultValue The `name` of the resource
21
+ */
10
22
  displayName?: string
11
23
  description?: string | null
12
24
  url: string
@@ -20,8 +32,14 @@ export interface BlueprintDocumentWebhookResource extends BlueprintResource {
20
32
  includeAllVersions?: boolean
21
33
  secret?: string
22
34
  dataset: string
35
+ /** Must start with 'v' and use the format YYYY-MM-DD */
23
36
  apiVersion: string
24
37
  }
25
38
 
26
- /** Configuration for a webhook */
39
+ /**
40
+ * Configuration for a webhook
41
+ * @beta This feature is subject to breaking changes.
42
+ * @category Resource Types
43
+ * @interface
44
+ */
27
45
  export type BlueprintDocumentWebhookConfig = Omit<BlueprintDocumentWebhookResource, 'type'>