@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.
- package/README.md +55 -20
- package/dist/definers/blueprints.d.ts +17 -3
- package/dist/definers/blueprints.js +42 -3
- package/dist/definers/blueprints.js.map +1 -1
- package/dist/definers/cors.d.ts +9 -2
- package/dist/definers/cors.js +21 -2
- package/dist/definers/cors.js.map +1 -1
- package/dist/definers/datasets.d.ts +10 -2
- package/dist/definers/datasets.js +23 -2
- package/dist/definers/datasets.js.map +1 -1
- package/dist/definers/functions.d.ts +58 -53
- package/dist/definers/functions.js +101 -86
- package/dist/definers/functions.js.map +1 -1
- package/dist/definers/resources.d.ts +12 -0
- package/dist/definers/resources.js +23 -0
- package/dist/definers/resources.js.map +1 -1
- package/dist/definers/robotTokens.d.ts +22 -0
- package/dist/definers/robotTokens.js +53 -0
- package/dist/definers/robotTokens.js.map +1 -0
- package/dist/definers/robots.d.ts +2 -18
- package/dist/definers/robots.js +2 -29
- package/dist/definers/robots.js.map +1 -1
- package/dist/definers/roles.d.ts +22 -25
- package/dist/definers/roles.js +70 -23
- package/dist/definers/roles.js.map +1 -1
- package/dist/definers/webhooks.d.ts +9 -2
- package/dist/definers/webhooks.js +29 -2
- package/dist/definers/webhooks.js.map +1 -1
- package/dist/index.d.ts +23 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -1
- package/dist/types/blueprints.d.ts +16 -4
- package/dist/types/cors.d.ts +6 -0
- package/dist/types/datasets.d.ts +19 -3
- package/dist/types/errors.d.ts +4 -1
- package/dist/types/functions.d.ts +139 -17
- package/dist/types/functions.js +5 -1
- package/dist/types/functions.js.map +1 -1
- package/dist/types/resources.d.ts +17 -0
- package/dist/types/robotTokens.d.ts +45 -0
- package/dist/types/robotTokens.js +2 -0
- package/dist/types/robotTokens.js.map +1 -0
- package/dist/types/robots.d.ts +8 -30
- package/dist/types/robots.js +1 -0
- package/dist/types/robots.js.map +1 -1
- package/dist/types/roles.d.ts +12 -3
- package/dist/types/webhooks.d.ts +23 -5
- package/dist/utils/schedule-parser.d.ts +42 -0
- package/dist/utils/schedule-parser.js +450 -0
- package/dist/utils/schedule-parser.js.map +1 -0
- package/dist/utils/validation.d.ts +1 -0
- package/dist/utils/validation.js +1 -0
- package/dist/utils/validation.js.map +1 -1
- package/dist/validation/blueprints.d.ts +1 -0
- package/dist/validation/blueprints.js +1 -0
- package/dist/validation/blueprints.js.map +1 -1
- package/dist/validation/cors.d.ts +1 -0
- package/dist/validation/cors.js +1 -0
- package/dist/validation/cors.js.map +1 -1
- package/dist/validation/datasets.d.ts +2 -0
- package/dist/validation/datasets.js +2 -0
- package/dist/validation/datasets.js.map +1 -1
- package/dist/validation/functions.d.ts +11 -0
- package/dist/validation/functions.js +37 -1
- package/dist/validation/functions.js.map +1 -1
- package/dist/validation/resources.d.ts +7 -1
- package/dist/validation/resources.js +20 -14
- package/dist/validation/resources.js.map +1 -1
- package/dist/validation/robotTokens.d.ts +15 -0
- package/dist/validation/robotTokens.js +104 -0
- package/dist/validation/robotTokens.js.map +1 -0
- package/dist/validation/robots.d.ts +4 -8
- package/dist/validation/robots.js +5 -96
- package/dist/validation/robots.js.map +1 -1
- package/dist/validation/roles.d.ts +3 -1
- package/dist/validation/roles.js +3 -1
- package/dist/validation/roles.js.map +1 -1
- package/dist/validation/webhooks.d.ts +1 -0
- package/dist/validation/webhooks.js +1 -0
- package/dist/validation/webhooks.js.map +1 -1
- package/package.json +7 -4
- package/src/definers/blueprints.ts +42 -3
- package/src/definers/cors.ts +21 -2
- package/src/definers/datasets.ts +23 -2
- package/src/definers/functions.ts +159 -123
- package/src/definers/resources.ts +23 -0
- package/src/definers/robotTokens.ts +56 -0
- package/src/definers/robots.ts +2 -33
- package/src/definers/roles.ts +70 -23
- package/src/definers/webhooks.ts +29 -2
- package/src/index.ts +25 -0
- package/src/types/blueprints.ts +16 -4
- package/src/types/cors.ts +6 -0
- package/src/types/datasets.ts +19 -3
- package/src/types/errors.ts +4 -1
- package/src/types/functions.ts +156 -16
- package/src/types/resources.ts +17 -1
- package/src/types/robotTokens.ts +50 -0
- package/src/types/robots.ts +10 -35
- package/src/types/roles.ts +12 -3
- package/src/types/webhooks.ts +23 -5
- package/src/utils/schedule-parser.ts +502 -0
- package/src/utils/validation.ts +1 -0
- package/src/validation/blueprints.ts +1 -0
- package/src/validation/cors.ts +1 -0
- package/src/validation/datasets.ts +2 -0
- package/src/validation/functions.ts +37 -0
- package/src/validation/resources.ts +20 -14
- package/src/validation/robotTokens.ts +103 -0
- package/src/validation/robots.ts +5 -95
- package/src/validation/roles.ts +3 -1
- package/src/validation/webhooks.ts +1 -0
package/src/types/resources.ts
CHANGED
|
@@ -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
|
+
}
|
package/src/types/robots.ts
CHANGED
|
@@ -1,35 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
export type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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'
|
package/src/types/roles.ts
CHANGED
|
@@ -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
|
|
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'
|
package/src/types/webhooks.ts
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
|
-
import type {BlueprintResource} from '../index.js'
|
|
1
|
+
import type {BlueprintProjectResourceLifecycle, BlueprintResource} from '../index.js'
|
|
2
2
|
|
|
3
|
-
/**
|
|
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
|
-
/**
|
|
7
|
-
|
|
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
|
-
/**
|
|
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'>
|