@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
|
@@ -5,10 +5,12 @@
|
|
|
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
|
* An ownership action that will cause the referenced resource to be attached to the current stack.
|
|
13
|
+
* @category Blueprint Internals
|
|
12
14
|
*/
|
|
13
15
|
export interface BlueprintOwnershipAttachAction {
|
|
14
16
|
type: 'attach';
|
|
@@ -17,16 +19,20 @@ export interface BlueprintOwnershipAttachAction {
|
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
19
21
|
* An ownership action that will cause the referenced resource to be detached from the current stack.
|
|
22
|
+
* @category Blueprint Internals
|
|
20
23
|
*/
|
|
21
24
|
export interface BlueprintOwnershipDetachAction {
|
|
22
25
|
type: 'detach';
|
|
23
26
|
}
|
|
24
27
|
/**
|
|
25
28
|
* A union of all possible ownership actions.
|
|
29
|
+
* @category Blueprint Internals
|
|
30
|
+
* @expand
|
|
26
31
|
*/
|
|
27
32
|
export type BlueprintOwnershipAction = BlueprintOwnershipAttachAction | BlueprintOwnershipDetachAction;
|
|
28
33
|
/**
|
|
29
34
|
* An ownership action that will cause the referenced project-contained resource to be attached to the current stack.
|
|
35
|
+
* @category Blueprint Internals
|
|
30
36
|
*/
|
|
31
37
|
export interface BlueprintProjectOwnershipAttachAction extends BlueprintOwnershipAttachAction {
|
|
32
38
|
/** The identifier of the project for resources contained in a project */
|
|
@@ -34,10 +40,13 @@ export interface BlueprintProjectOwnershipAttachAction extends BlueprintOwnershi
|
|
|
34
40
|
}
|
|
35
41
|
/**
|
|
36
42
|
* A union of all possible ownership actions for resources belonging to projects.
|
|
43
|
+
* @category Blueprint Internals
|
|
44
|
+
* @expand
|
|
37
45
|
*/
|
|
38
46
|
export type BlueprintProjectOwnershipAction = BlueprintProjectOwnershipAttachAction;
|
|
39
47
|
/**
|
|
40
48
|
* Defines the lifcycle policy for this resource.
|
|
49
|
+
* @category Blueprint Internals
|
|
41
50
|
*/
|
|
42
51
|
export interface BlueprintResourceLifecycle {
|
|
43
52
|
deletionPolicy?: BlueprintResourceDeletionPolicy;
|
|
@@ -45,15 +54,23 @@ export interface BlueprintResourceLifecycle {
|
|
|
45
54
|
}
|
|
46
55
|
/**
|
|
47
56
|
* Defines the lifcycle policy for this resource.
|
|
57
|
+
* @category Blueprint Internals
|
|
58
|
+
* @experimental
|
|
48
59
|
*/
|
|
49
60
|
export interface BlueprintProjectResourceLifecycle extends BlueprintResourceLifecycle {
|
|
50
61
|
ownershipAction?: BlueprintProjectOwnershipAction;
|
|
51
62
|
}
|
|
52
63
|
/**
|
|
53
64
|
* The base type for all resources.
|
|
65
|
+
* @category Blueprint Internals
|
|
54
66
|
*/
|
|
55
67
|
export interface BlueprintResource<Lifecycle extends BlueprintResourceLifecycle = BlueprintResourceLifecycle> {
|
|
56
68
|
type: string;
|
|
57
69
|
name: string;
|
|
70
|
+
/**
|
|
71
|
+
* Defines the lifcycle policy for this resource.
|
|
72
|
+
* @experimental
|
|
73
|
+
* @hidden
|
|
74
|
+
*/
|
|
58
75
|
lifecycle?: Lifecycle;
|
|
59
76
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { BlueprintProjectResourceLifecycle, BlueprintResource } from './resources';
|
|
2
|
+
/**
|
|
3
|
+
* Resource types that robot tokens can be attached to.
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export type RobotTokenResourceType = 'organization' | 'project';
|
|
7
|
+
/**
|
|
8
|
+
* Defines the robot token's roles within a given resource.
|
|
9
|
+
* @beta This feature is subject to breaking changes.
|
|
10
|
+
* @category Resource Types
|
|
11
|
+
* @expand
|
|
12
|
+
*/
|
|
13
|
+
export interface RobotTokenMembership {
|
|
14
|
+
resourceType: RobotTokenResourceType;
|
|
15
|
+
resourceId: string;
|
|
16
|
+
roleNames: string[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A robot token that provides automated access.
|
|
20
|
+
* @see https://www.sanity.io/docs/content-lake/http-auth#k4c21d7b829fe
|
|
21
|
+
* @beta This feature is subject to breaking changes.
|
|
22
|
+
* @category Resource Types
|
|
23
|
+
*/
|
|
24
|
+
export interface BlueprintRobotTokenResource extends BlueprintResource<BlueprintProjectResourceLifecycle> {
|
|
25
|
+
type: 'sanity.access.robot';
|
|
26
|
+
/** A descriptive label for the robot token and its use case */
|
|
27
|
+
label: string;
|
|
28
|
+
memberships: RobotTokenMembership[];
|
|
29
|
+
resourceType?: RobotTokenResourceType;
|
|
30
|
+
resourceId?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Configuration for a robot token that provides automated access.
|
|
34
|
+
* @see https://www.sanity.io/docs/content-lake/http-auth#k4c21d7b829fe
|
|
35
|
+
* @beta This feature is subject to breaking changes.
|
|
36
|
+
* @category Resource Types
|
|
37
|
+
* @interface
|
|
38
|
+
*/
|
|
39
|
+
export type BlueprintRobotTokenConfig = Omit<BlueprintRobotTokenResource, 'type' | 'label' | 'token'> & {
|
|
40
|
+
/**
|
|
41
|
+
* A descriptive label for the robot token and its use case
|
|
42
|
+
* @defaultValue The `name` of the resource
|
|
43
|
+
*/
|
|
44
|
+
label?: string;
|
|
45
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"robotTokens.js","sourceRoot":"","sources":["../../src/types/robotTokens.ts"],"names":[],"mappings":""}
|
package/dist/types/robots.d.ts
CHANGED
|
@@ -1,30 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
resourceId: string;
|
|
10
|
-
roleNames: string[];
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* A robot that provides a token for automated access.
|
|
14
|
-
* @see https://www.sanity.io/docs/content-lake/http-auth#k4c21d7b829fe
|
|
15
|
-
*/
|
|
16
|
-
export interface BlueprintRobotResource extends BlueprintResource {
|
|
17
|
-
type: 'sanity.access.robot';
|
|
18
|
-
/** A descriptive label for the robot and its use case */
|
|
19
|
-
label: string;
|
|
20
|
-
memberships: RobotMembership[];
|
|
21
|
-
resourceType?: RobotResourceType;
|
|
22
|
-
resourceId?: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Configuration for a robot that provides a token for automated access.
|
|
26
|
-
* @see https://www.sanity.io/docs/content-lake/http-auth#k4c21d7b829fe
|
|
27
|
-
*/
|
|
28
|
-
export type BlueprintRobotConfig = Omit<BlueprintRobotResource, 'type' | 'label' | 'token'> & {
|
|
29
|
-
label?: string;
|
|
30
|
-
};
|
|
1
|
+
/** @deprecated Use {@link BlueprintRobotTokenConfig} instead @hidden */
|
|
2
|
+
export type { BlueprintRobotTokenConfig as BlueprintRobotConfig } from './robotTokens.js';
|
|
3
|
+
/** @deprecated Use {@link BlueprintRobotTokenResource} instead @hidden */
|
|
4
|
+
export type { BlueprintRobotTokenResource as BlueprintRobotResource } from './robotTokens.js';
|
|
5
|
+
/** @deprecated Use {@link RobotTokenMembership} instead @hidden */
|
|
6
|
+
export type { RobotTokenMembership as RobotMembership } from './robotTokens.js';
|
|
7
|
+
/** @deprecated Use {@link RobotTokenResourceType} instead @hidden */
|
|
8
|
+
export type { RobotTokenResourceType as RobotResourceType } from './robotTokens.js';
|
package/dist/types/robots.js
CHANGED
package/dist/types/robots.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"robots.js","sourceRoot":"","sources":["../../src/types/robots.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"robots.js","sourceRoot":"","sources":["../../src/types/robots.ts"],"names":[],"mappings":"AAAA,iFAAiF"}
|
package/dist/types/roles.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import type { BlueprintResource } from '../index.js';
|
|
1
|
+
import type { BlueprintProjectResourceLifecycle, BlueprintResource } from '../index.js';
|
|
2
2
|
/**
|
|
3
3
|
* A permission definition for a role.
|
|
4
|
+
* @beta This feature is subject to breaking changes.
|
|
5
|
+
* @category Resource Types
|
|
6
|
+
* @expand
|
|
4
7
|
*/
|
|
5
8
|
export interface RolePermission {
|
|
6
9
|
/** Predefined permission name (e.g., 'sanity-all-documents') */
|
|
@@ -12,8 +15,10 @@ export interface RolePermission {
|
|
|
12
15
|
}
|
|
13
16
|
/**
|
|
14
17
|
* Configuration for a custom role.
|
|
18
|
+
* @beta This feature is subject to breaking changes.
|
|
19
|
+
* @category Resource Types
|
|
15
20
|
*/
|
|
16
|
-
export interface BlueprintRoleConfig extends Omit<BlueprintResource
|
|
21
|
+
export interface BlueprintRoleConfig extends Omit<BlueprintResource<BlueprintProjectResourceLifecycle>, 'type'> {
|
|
17
22
|
title: string;
|
|
18
23
|
description?: string;
|
|
19
24
|
appliesToUsers: boolean;
|
|
@@ -22,12 +27,16 @@ export interface BlueprintRoleConfig extends Omit<BlueprintResource, 'type'> {
|
|
|
22
27
|
}
|
|
23
28
|
/**
|
|
24
29
|
* A custom role resource
|
|
30
|
+
* @beta This feature is subject to breaking changes.
|
|
31
|
+
* @category Resource Types
|
|
25
32
|
*/
|
|
26
|
-
export interface BlueprintRoleResource extends BlueprintRoleConfig, BlueprintResource {
|
|
33
|
+
export interface BlueprintRoleResource extends BlueprintRoleConfig, BlueprintResource<BlueprintProjectResourceLifecycle> {
|
|
27
34
|
type: 'sanity.access.role';
|
|
28
35
|
}
|
|
29
36
|
/**
|
|
30
37
|
* A custom role resource that is tied to a specific project
|
|
38
|
+
* @beta This feature is subject to breaking changes.
|
|
39
|
+
* @category Resource Types
|
|
31
40
|
*/
|
|
32
41
|
export interface BlueprintProjectRoleResource extends BlueprintRoleResource {
|
|
33
42
|
resourceType: 'project';
|
package/dist/types/webhooks.d.ts
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
|
-
import type { BlueprintResource } from '../index.js';
|
|
2
|
-
/**
|
|
1
|
+
import type { BlueprintProjectResourceLifecycle, BlueprintResource } from '../index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Types of events that can trigger a webhook
|
|
4
|
+
* @beta This feature is subject to breaking changes.
|
|
5
|
+
* @category Resource Types
|
|
6
|
+
*/
|
|
3
7
|
export type WebhookTrigger = 'create' | 'update' | 'delete';
|
|
4
|
-
/**
|
|
5
|
-
|
|
8
|
+
/**
|
|
9
|
+
* A webhook resource definition
|
|
10
|
+
* @beta This feature is subject to breaking changes.
|
|
11
|
+
* @category Resource Types
|
|
12
|
+
*/
|
|
13
|
+
export interface BlueprintDocumentWebhookResource extends BlueprintResource<BlueprintProjectResourceLifecycle> {
|
|
6
14
|
type: 'sanity.project.webhook';
|
|
7
15
|
project?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Display name shown in the Sanity dashboard
|
|
18
|
+
* @defaultValue The `name` of the resource
|
|
19
|
+
*/
|
|
8
20
|
displayName?: string;
|
|
9
21
|
description?: string | null;
|
|
10
22
|
url: string;
|
|
@@ -18,7 +30,13 @@ export interface BlueprintDocumentWebhookResource extends BlueprintResource {
|
|
|
18
30
|
includeAllVersions?: boolean;
|
|
19
31
|
secret?: string;
|
|
20
32
|
dataset: string;
|
|
33
|
+
/** Must start with 'v' and use the format YYYY-MM-DD */
|
|
21
34
|
apiVersion: string;
|
|
22
35
|
}
|
|
23
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Configuration for a webhook
|
|
38
|
+
* @beta This feature is subject to breaking changes.
|
|
39
|
+
* @category Resource Types
|
|
40
|
+
* @interface
|
|
41
|
+
*/
|
|
24
42
|
export type BlueprintDocumentWebhookConfig = Omit<BlueprintDocumentWebhookResource, 'type'>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { BlueprintError } from '../types/errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validates a schedule expression and returns any errors found.
|
|
4
|
+
*
|
|
5
|
+
* Checks for:
|
|
6
|
+
* - Empty expressions
|
|
7
|
+
* - Invalid time formats (hours, minutes out of range)
|
|
8
|
+
* - Invalid intervals (minutes, hours out of range)
|
|
9
|
+
* - Invalid day of month values
|
|
10
|
+
* - Unrecognizable expressions
|
|
11
|
+
*
|
|
12
|
+
* @param expression Natural language schedule or cron expression
|
|
13
|
+
* @returns Array of validation errors, empty if valid
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export declare function validateScheduleExpression(expression: string): BlueprintError[];
|
|
17
|
+
/**
|
|
18
|
+
* Parse a natural language schedule expression into a cron expression.
|
|
19
|
+
*
|
|
20
|
+
* The parser is **forgiving** and **freeform** - it extracts recognized parts
|
|
21
|
+
* (days, times, intervals) and ignores unrecognized tokens like "at", "on", "the".
|
|
22
|
+
*
|
|
23
|
+
* Supported patterns:
|
|
24
|
+
* - "every minute", "every 5 minutes", "every hour", "every 2 hours"
|
|
25
|
+
* - "every day at 9am", "daily 14:30", "9am daily"
|
|
26
|
+
* - "at midnight", "noon"
|
|
27
|
+
* - "morning", "evening"
|
|
28
|
+
* - "mondays 9am", "mon wed fri 9:00", "mon-fri 8am"
|
|
29
|
+
* - "9pm fridays and wed", "wednesday friday 9pm"
|
|
30
|
+
* - "weekdays 9am", "weekends 10am"
|
|
31
|
+
* - "first of the month 9am", "15th noon"
|
|
32
|
+
*
|
|
33
|
+
* If the input is already a valid cron expression, it is returned unchanged.
|
|
34
|
+
*
|
|
35
|
+
* This function assumes the expression has already been validated via
|
|
36
|
+
* `validateScheduleExpression`. For invalid input, behavior is undefined.
|
|
37
|
+
*
|
|
38
|
+
* @param expression Natural language schedule or cron expression
|
|
39
|
+
* @returns Cron expression string
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
export declare function parseScheduleExpression(expression: string): string;
|