@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/README.md
CHANGED
|
@@ -1,42 +1,77 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@sanity/blueprints`
|
|
2
2
|
|
|
3
|
-
> [!IMPORTANT]
|
|
3
|
+
> [!IMPORTANT]
|
|
4
4
|
> This package is currently in beta and may change. Refer to the [CHANGELOG](./CHANGELOG.md) for details.
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
TypeScript helpers for defining and validating [Sanity Blueprints](https://www.sanity.io/docs/blueprints) — declarative infrastructure-as-code for your Sanity project.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @sanity/blueprints
|
|
12
|
+
```
|
|
7
13
|
|
|
8
14
|
## Usage
|
|
9
15
|
|
|
16
|
+
A blueprint is a module that declares the Sanity resources your project needs. Export it as the default from your blueprint file:
|
|
17
|
+
|
|
10
18
|
```ts
|
|
11
19
|
import {
|
|
12
|
-
defineBlueprint,
|
|
13
|
-
|
|
14
|
-
|
|
20
|
+
defineBlueprint,
|
|
21
|
+
defineCorsOrigin,
|
|
22
|
+
defineDocumentFunction,
|
|
23
|
+
defineDocumentWebhook,
|
|
24
|
+
defineRobotToken,
|
|
25
|
+
defineRole,
|
|
15
26
|
} from '@sanity/blueprints'
|
|
16
27
|
|
|
17
28
|
export default defineBlueprint({
|
|
18
29
|
resources: [
|
|
30
|
+
defineCorsOrigin({
|
|
31
|
+
name: 'localhost-origin',
|
|
32
|
+
origin: 'http://localhost:3333',
|
|
33
|
+
allowCredentials: true,
|
|
34
|
+
}),
|
|
35
|
+
|
|
19
36
|
defineDocumentFunction({
|
|
20
|
-
name: '
|
|
21
|
-
src: 'functions/create-fancy-report',
|
|
22
|
-
memory: 2,
|
|
23
|
-
timeout: 360,
|
|
37
|
+
name: 'on-publish',
|
|
24
38
|
event: {
|
|
25
39
|
on: ['create', 'update'],
|
|
26
|
-
filter: "_type == '
|
|
27
|
-
projection:
|
|
28
|
-
},
|
|
29
|
-
env: {
|
|
30
|
-
currency: 'USD',
|
|
40
|
+
filter: "_type == 'product'",
|
|
41
|
+
projection: '{_id, title, slug}',
|
|
31
42
|
},
|
|
32
43
|
}),
|
|
44
|
+
|
|
33
45
|
defineDocumentWebhook({
|
|
34
|
-
name: '
|
|
35
|
-
url: '
|
|
36
|
-
on: ['create'],
|
|
46
|
+
name: 'server-webhook',
|
|
47
|
+
url: 'https://api.example.com/webhooks/sanity',
|
|
48
|
+
on: ['create', 'update'],
|
|
37
49
|
dataset: 'production',
|
|
38
|
-
apiVersion: '
|
|
39
|
-
})
|
|
50
|
+
apiVersion: 'v2026-01-01',
|
|
51
|
+
}),
|
|
52
|
+
|
|
53
|
+
defineRobotToken({
|
|
54
|
+
name: 'ci-robot',
|
|
55
|
+
memberships: [{
|
|
56
|
+
resourceType: 'project',
|
|
57
|
+
resourceId: 'your-project-id',
|
|
58
|
+
roleNames: ['developer'],
|
|
59
|
+
}],
|
|
60
|
+
}),
|
|
40
61
|
],
|
|
41
62
|
})
|
|
42
63
|
```
|
|
64
|
+
|
|
65
|
+
## Available resources
|
|
66
|
+
|
|
67
|
+
| Definer | Description |
|
|
68
|
+
|---|---|
|
|
69
|
+
| `defineBlueprint` | Top-level blueprint module containing resources |
|
|
70
|
+
| `defineDocumentFunction` | Function triggered by document events |
|
|
71
|
+
| `defineMediaLibraryAssetFunction` | Function triggered by media library events |
|
|
72
|
+
| `defineCorsOrigin` β | CORS origin allowing browser requests to your project |
|
|
73
|
+
| `defineDocumentWebhook` β | Webhook triggered by document changes |
|
|
74
|
+
| `defineRole` β | Custom role with permissions |
|
|
75
|
+
| `defineRobotToken` β | Robot token for automated access |
|
|
76
|
+
|
|
77
|
+
Each definer validates its input at call time and returns a typed resource object. See the [reference docs](https://reference.sanity.io/_sanity/blueprints) for full configuration details and additional resource types.
|
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
import { type Blueprint, type BlueprintModule, type BlueprintsApiConfig } from '../index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Define a Blueprint to manage Sanity resources
|
|
4
|
-
*
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
5
6
|
* defineBlueprint({
|
|
6
7
|
* resources: [
|
|
7
|
-
*
|
|
8
|
-
*
|
|
8
|
+
* defineCorsOrigin({
|
|
9
|
+
* name: 'localhost-origin',
|
|
10
|
+
* origin: 'http://localhost:3333',
|
|
11
|
+
* }),
|
|
12
|
+
* defineDocumentFunction({
|
|
13
|
+
* name: 'update-search-index',
|
|
14
|
+
* event: {
|
|
15
|
+
* on: ['create', 'update'],
|
|
16
|
+
* filter: "_type == 'post'",
|
|
17
|
+
* projection: "{_id, title, slug}",
|
|
18
|
+
* },
|
|
19
|
+
* }),
|
|
20
|
+
* ],
|
|
9
21
|
* })
|
|
10
22
|
* ```
|
|
11
23
|
* @param blueprintConfig The blueprint configuration
|
|
24
|
+
* @public
|
|
25
|
+
* @category Definers
|
|
12
26
|
* @returns A blueprint module
|
|
13
27
|
*/
|
|
14
28
|
export declare function defineBlueprint(blueprintConfig: Partial<Blueprint> & Partial<BlueprintsApiConfig>): BlueprintModule;
|
|
@@ -1,15 +1,54 @@
|
|
|
1
1
|
import { validateBlueprint } from '../index.js';
|
|
2
2
|
import { runValidation } from '../utils/validation.js';
|
|
3
|
+
/*
|
|
4
|
+
* FUTURE example (move below @example when ready)
|
|
5
|
+
* @example With deployment API config
|
|
6
|
+
* ```ts
|
|
7
|
+
* defineBlueprint({
|
|
8
|
+
* resources: [
|
|
9
|
+
* defineCorsOrigin({
|
|
10
|
+
* name: 'cors-localhost',
|
|
11
|
+
* origin: 'http://localhost:3333'
|
|
12
|
+
* }),
|
|
13
|
+
* defineRole({
|
|
14
|
+
* name: 'role-ci',
|
|
15
|
+
* title: 'CI Role',
|
|
16
|
+
* appliesToRobots: true,
|
|
17
|
+
* permissions: []
|
|
18
|
+
* }),
|
|
19
|
+
* defineRobotToken({
|
|
20
|
+
* name: 'ci-robot',
|
|
21
|
+
* memberships: [{
|
|
22
|
+
* roleNames: ['$.resources.ci-role']}],
|
|
23
|
+
* }),
|
|
24
|
+
* ],
|
|
25
|
+
* })
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
3
28
|
/**
|
|
4
29
|
* Define a Blueprint to manage Sanity resources
|
|
5
|
-
*
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
6
32
|
* defineBlueprint({
|
|
7
33
|
* resources: [
|
|
8
|
-
*
|
|
9
|
-
*
|
|
34
|
+
* defineCorsOrigin({
|
|
35
|
+
* name: 'localhost-origin',
|
|
36
|
+
* origin: 'http://localhost:3333',
|
|
37
|
+
* }),
|
|
38
|
+
* defineDocumentFunction({
|
|
39
|
+
* name: 'update-search-index',
|
|
40
|
+
* event: {
|
|
41
|
+
* on: ['create', 'update'],
|
|
42
|
+
* filter: "_type == 'post'",
|
|
43
|
+
* projection: "{_id, title, slug}",
|
|
44
|
+
* },
|
|
45
|
+
* }),
|
|
46
|
+
* ],
|
|
10
47
|
* })
|
|
11
48
|
* ```
|
|
12
49
|
* @param blueprintConfig The blueprint configuration
|
|
50
|
+
* @public
|
|
51
|
+
* @category Definers
|
|
13
52
|
* @returns A blueprint module
|
|
14
53
|
*/
|
|
15
54
|
export function defineBlueprint(blueprintConfig) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blueprints.js","sourceRoot":"","sources":["../../src/definers/blueprints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiE,iBAAiB,EAAC,MAAM,aAAa,CAAA;AAC7G,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AAEpD
|
|
1
|
+
{"version":3,"file":"blueprints.js","sourceRoot":"","sources":["../../src/definers/blueprints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiE,iBAAiB,EAAC,MAAM,aAAa,CAAA;AAC7G,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,eAAe,CAAC,eAAkE;IAChG,MAAM,EAAC,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAC,GAAG,eAAe,CAAA;IAE1G,aAAa,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC,CAAA;IAEvD,SAAS,SAAS;QAChB,OAAO;YACL,OAAO,EAAE,wEAAwE;YACjF,gBAAgB,EAAE,gBAAgB,IAAI,YAAY;YAClD,SAAS;YACT,MAAM;YACN,OAAO;SACR,CAAA;IACH,CAAC;IAED,SAAS,CAAC,cAAc,GAAG,cAAc,CAAA;IACzC,SAAS,CAAC,SAAS,GAAG,SAAS,CAAA;IAC/B,SAAS,CAAC,OAAO,GAAG,OAAO,CAAA;IAE3B,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
package/dist/definers/cors.d.ts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { type BlueprintCorsOriginConfig, type BlueprintCorsOriginResource } from '../index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Defines a CORS Origin to be managed in a Blueprint.
|
|
4
|
-
*
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
5
6
|
* defineCorsOrigin({
|
|
7
|
+
* name: 'my-cors-origin',
|
|
6
8
|
* origin: 'https://mydomain.com',
|
|
7
|
-
* allowCredentials: true
|
|
9
|
+
* allowCredentials: true,
|
|
8
10
|
* })
|
|
9
11
|
* ```
|
|
10
12
|
* @param parameters The CORS Origin configuration
|
|
13
|
+
* @public
|
|
14
|
+
* @beta Deploying CORS Origins via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
15
|
+
* @category Definers
|
|
16
|
+
* @expandType BlueprintCorsOriginConfig
|
|
17
|
+
* @returns The CORS Origin resource
|
|
11
18
|
*/
|
|
12
19
|
export declare function defineCorsOrigin(parameters: BlueprintCorsOriginConfig): BlueprintCorsOriginResource;
|
package/dist/definers/cors.js
CHANGED
|
@@ -1,14 +1,33 @@
|
|
|
1
1
|
import { validateCorsOrigin } 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
|
+
* defineCorsOrigin({
|
|
8
|
+
* name: 'studio-cors',
|
|
9
|
+
* origin: 'https://my-studio.sanity.studio',
|
|
10
|
+
* allowCredentials: true,
|
|
11
|
+
* project: 'my-project-id',
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
3
15
|
/**
|
|
4
16
|
* Defines a CORS Origin to be managed in a Blueprint.
|
|
5
|
-
*
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
6
19
|
* defineCorsOrigin({
|
|
20
|
+
* name: 'my-cors-origin',
|
|
7
21
|
* origin: 'https://mydomain.com',
|
|
8
|
-
* allowCredentials: true
|
|
22
|
+
* allowCredentials: true,
|
|
9
23
|
* })
|
|
10
24
|
* ```
|
|
11
25
|
* @param parameters The CORS Origin configuration
|
|
26
|
+
* @public
|
|
27
|
+
* @beta Deploying CORS Origins via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
28
|
+
* @category Definers
|
|
29
|
+
* @expandType BlueprintCorsOriginConfig
|
|
30
|
+
* @returns The CORS Origin resource
|
|
12
31
|
*/
|
|
13
32
|
export function defineCorsOrigin(parameters) {
|
|
14
33
|
const corsResource = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cors.js","sourceRoot":"","sources":["../../src/definers/cors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmE,kBAAkB,EAAC,MAAM,aAAa,CAAA;AAChH,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AAEpD
|
|
1
|
+
{"version":3,"file":"cors.js","sourceRoot":"","sources":["../../src/definers/cors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmE,kBAAkB,EAAC,MAAM,aAAa,CAAA;AAChH,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AAEpD;;;;;;;;;;;GAWG;AACH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAqC;IACpE,MAAM,YAAY,GAAgC;QAChD,GAAG,UAAU;QACb,gBAAgB,EAAE,UAAU,CAAC,gBAAgB,IAAI,KAAK;QACtD,IAAI,EAAE,qBAAqB;KAC5B,CAAA;IAED,aAAa,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC,CAAA;IAErD,OAAO,YAAY,CAAA;AACrB,CAAC"}
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { type BlueprintDatasetConfig, type BlueprintDatasetResource } from '../index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Defines a Dataset to be managed in a Blueprint.
|
|
4
|
-
*
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
5
6
|
* defineDataset({
|
|
6
|
-
* name: '
|
|
7
|
+
* name: 'staging-dataset',
|
|
8
|
+
* datasetName: 'staging',
|
|
7
9
|
* })
|
|
8
10
|
* ```
|
|
9
11
|
* @param parameters The dataset configuration
|
|
12
|
+
* @public
|
|
13
|
+
* @alpha Deploying Datasets via Blueprints is experimental. This feature is subject to breaking changes.
|
|
14
|
+
* @hidden
|
|
15
|
+
* @category Definers
|
|
16
|
+
* @expandType BlueprintDatasetConfig
|
|
17
|
+
* @returns The dataset resource
|
|
10
18
|
*/
|
|
11
19
|
export declare function defineDataset(parameters: BlueprintDatasetConfig): BlueprintDatasetResource;
|
|
@@ -1,13 +1,34 @@
|
|
|
1
1
|
import { validateDataset } 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
|
+
* defineDataset({
|
|
8
|
+
* name: 'staging',
|
|
9
|
+
* datasetName: 'staging-v2',
|
|
10
|
+
* aclMode: 'private',
|
|
11
|
+
* project: 'my-project-id',
|
|
12
|
+
* lifecycle: {deletionPolicy: 'protect'},
|
|
13
|
+
* })
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
3
16
|
/**
|
|
4
17
|
* Defines a Dataset to be managed in a Blueprint.
|
|
5
|
-
*
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
6
20
|
* defineDataset({
|
|
7
|
-
* name: '
|
|
21
|
+
* name: 'staging-dataset',
|
|
22
|
+
* datasetName: 'staging',
|
|
8
23
|
* })
|
|
9
24
|
* ```
|
|
10
25
|
* @param parameters The dataset configuration
|
|
26
|
+
* @public
|
|
27
|
+
* @alpha Deploying Datasets via Blueprints is experimental. This feature is subject to breaking changes.
|
|
28
|
+
* @hidden
|
|
29
|
+
* @category Definers
|
|
30
|
+
* @expandType BlueprintDatasetConfig
|
|
31
|
+
* @returns The dataset resource
|
|
11
32
|
*/
|
|
12
33
|
export function defineDataset(parameters) {
|
|
13
34
|
// default dataset name
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datasets.js","sourceRoot":"","sources":["../../src/definers/datasets.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6D,eAAe,EAAC,MAAM,aAAa,CAAA;AACvG,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AAEpD
|
|
1
|
+
{"version":3,"file":"datasets.js","sourceRoot":"","sources":["../../src/definers/datasets.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6D,eAAe,EAAC,MAAM,aAAa,CAAA;AACvG,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AAEpD;;;;;;;;;;;;GAYG;AACH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,aAAa,CAAC,UAAkC;IAC9D,uBAAuB;IACvB,MAAM,WAAW,GAAG,UAAU,CAAC,WAAW,IAAI,UAAU,CAAC,IAAI,CAAA;IAE7D,MAAM,eAAe,GAA6B;QAChD,GAAG,UAAU;QACb,WAAW;QACX,IAAI,EAAE,wBAAwB;KAC/B,CAAA;IAED,aAAa,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC,CAAA;IAErD,OAAO,eAAe,CAAA;AACxB,CAAC"}
|
|
@@ -1,96 +1,101 @@
|
|
|
1
|
-
import { type BlueprintBaseFunctionResource, type BlueprintDocumentFunctionResource, type BlueprintDocumentFunctionResourceEvent, type
|
|
2
|
-
interface RequiredFunctionProperties {
|
|
3
|
-
name: string;
|
|
4
|
-
}
|
|
1
|
+
import { type BlueprintBaseFunctionConfig, type BlueprintBaseFunctionResource, type BlueprintDocumentFunctionConfig, type BlueprintDocumentFunctionResource, type BlueprintDocumentFunctionResourceEvent, type BlueprintMediaLibraryAssetFunctionConfig, type BlueprintMediaLibraryAssetFunctionResource, type BlueprintScheduleFunctionConfig, type BlueprintScheduleFunctionResource } from '../index.js';
|
|
5
2
|
/**
|
|
6
3
|
* Defines a function that is triggered by document events in Sanity datasets.
|
|
7
|
-
*
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
8
6
|
* defineDocumentFunction({
|
|
9
7
|
* name: 'my-document-function',
|
|
10
|
-
* src: 'functions/my-function',
|
|
11
|
-
* memory: 3,
|
|
12
|
-
* timeout: 300,
|
|
13
8
|
* event: {
|
|
14
9
|
* on: ['create', 'update'],
|
|
15
|
-
* filter: "_type == '
|
|
16
|
-
* projection: "{
|
|
17
|
-
* includeDrafts: false,
|
|
18
|
-
* },
|
|
19
|
-
* env: {
|
|
20
|
-
* MY_ENV_VAR: 'custom-value',
|
|
10
|
+
* filter: "_type == 'post'",
|
|
11
|
+
* projection: "{_id, title, slug}",
|
|
21
12
|
* },
|
|
22
13
|
* })
|
|
23
14
|
* ```
|
|
24
15
|
* @param functionConfig The configuration for the document function
|
|
16
|
+
* @public
|
|
17
|
+
* @category Definers
|
|
18
|
+
* @expandType BlueprintDocumentFunctionConfig
|
|
25
19
|
* @returns The validated document function resource
|
|
26
20
|
*/
|
|
27
|
-
export declare function defineDocumentFunction(functionConfig:
|
|
28
|
-
/**
|
|
29
|
-
|
|
21
|
+
export declare function defineDocumentFunction(functionConfig: BlueprintDocumentFunctionConfig): BlueprintDocumentFunctionResource;
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated Define event properties under the 'event' key instead of specifying them at the top level
|
|
24
|
+
* @hidden
|
|
25
|
+
*/
|
|
26
|
+
export declare function defineDocumentFunction(functionConfig: BlueprintDocumentFunctionConfig & Partial<BlueprintDocumentFunctionResourceEvent>): BlueprintDocumentFunctionResource;
|
|
30
27
|
/**
|
|
31
28
|
* Defines a function that is triggered by media library events.
|
|
32
|
-
*
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
33
31
|
* defineMediaLibraryAssetFunction({
|
|
34
32
|
* name: 'my-media-library-function',
|
|
35
|
-
* src: 'functions/media-library-function',
|
|
36
33
|
* event: {
|
|
37
|
-
* on: ['create'
|
|
34
|
+
* on: ['create'],
|
|
38
35
|
* resource: {
|
|
39
36
|
* type: 'media-library',
|
|
40
37
|
* id: 'my-media-library-id',
|
|
41
38
|
* },
|
|
42
|
-
* filter: "type == 'my-type'",
|
|
43
|
-
* projection: "{_id}",
|
|
44
|
-
* },
|
|
45
|
-
* env: {
|
|
46
|
-
* MY_ENV_VAR: 'custom-value',
|
|
47
39
|
* },
|
|
48
40
|
* })
|
|
49
41
|
* ```
|
|
50
42
|
* @param functionConfig The configuration for the media library asset function
|
|
43
|
+
* @public
|
|
44
|
+
* @category Definers
|
|
45
|
+
* @expandType BlueprintMediaLibraryAssetFunctionConfig
|
|
51
46
|
* @returns The validated media library asset function resource
|
|
52
47
|
*/
|
|
53
|
-
export declare function defineMediaLibraryAssetFunction(functionConfig:
|
|
48
|
+
export declare function defineMediaLibraryAssetFunction(functionConfig: BlueprintMediaLibraryAssetFunctionConfig): BlueprintMediaLibraryAssetFunctionResource;
|
|
54
49
|
/**
|
|
55
50
|
* Defines a function that is triggered on a schedule.
|
|
51
|
+
* Supports cron expressions or natural language schedules.
|
|
52
|
+
*
|
|
53
|
+
* @remarks
|
|
54
|
+
* Using a cron expression:
|
|
55
|
+
* ```ts
|
|
56
|
+
* defineScheduleFunction({
|
|
57
|
+
* name: 'daily-cleanup',
|
|
58
|
+
* event: {expression: '0 9 * * *'},
|
|
59
|
+
* })
|
|
56
60
|
* ```
|
|
61
|
+
*
|
|
62
|
+
* Using explicit cron fields:
|
|
63
|
+
* ```ts
|
|
57
64
|
* defineScheduleFunction({
|
|
58
|
-
* name: '
|
|
59
|
-
*
|
|
60
|
-
* memory: 3,
|
|
61
|
-
* timeout: 300,
|
|
62
|
-
* event: {
|
|
63
|
-
* minute: "0",
|
|
64
|
-
* hour: "0",
|
|
65
|
-
* dayOfMonth: "*",
|
|
66
|
-
* month: "*",
|
|
67
|
-
* dayOfWeek: "*",
|
|
68
|
-
* },
|
|
65
|
+
* name: 'daily-cleanup',
|
|
66
|
+
* event: {minute: '0', hour: '9', dayOfMonth: '*', month: '*', dayOfWeek: '*'},
|
|
69
67
|
* })
|
|
70
68
|
* ```
|
|
71
|
-
*
|
|
72
|
-
*
|
|
69
|
+
*
|
|
70
|
+
* The `event.expression` field accepts standard cron expressions or natural language:
|
|
71
|
+
* `'every 15 minutes'`, `'weekdays at 8am'`, `'fridays in the evening'`,
|
|
72
|
+
* `'mon, wed, fri at 9am'`, `'first of the month at noon'`
|
|
73
|
+
*
|
|
74
|
+
* ```ts
|
|
75
|
+
* defineScheduleFunction({
|
|
76
|
+
* name: 'daily-cleanup',
|
|
77
|
+
* event: {expression: 'every day at 9am'},
|
|
78
|
+
* })
|
|
79
|
+
* ```
|
|
80
|
+
* @public
|
|
81
|
+
* @alpha Deploying Schedule Functions via Blueprints is experimental. This feature is not available publicly yet.
|
|
82
|
+
* @hidden
|
|
83
|
+
* @category Definers
|
|
84
|
+
* @expandType BlueprintScheduleFunctionConfig
|
|
85
|
+
* @param functionConfig The configuration for the schedule function
|
|
73
86
|
* @returns The validated schedule function resource
|
|
74
87
|
*/
|
|
75
|
-
export declare function defineScheduleFunction(functionConfig:
|
|
88
|
+
export declare function defineScheduleFunction(functionConfig: BlueprintScheduleFunctionConfig): BlueprintScheduleFunctionResource;
|
|
76
89
|
/**
|
|
77
90
|
* Defines a base function resource with common properties.
|
|
78
|
-
*
|
|
79
|
-
* defineFunction({
|
|
80
|
-
* name: 'my-function',
|
|
81
|
-
* src: 'functions/my-function',
|
|
82
|
-
* timeout: 300,
|
|
83
|
-
* memory: 1,
|
|
84
|
-
* env: {
|
|
85
|
-
* MY_ENV_VAR: 'my-custom-value'
|
|
86
|
-
* },
|
|
87
|
-
* })
|
|
88
|
-
* ```
|
|
91
|
+
*
|
|
89
92
|
* @param functionConfig The configuration for the function
|
|
90
93
|
* @param options Optional configuration including validation options
|
|
94
|
+
* @category Definers
|
|
95
|
+
* @internal
|
|
96
|
+
* @expandType BlueprintBaseFunctionConfig
|
|
91
97
|
* @returns The validated function resource
|
|
92
98
|
*/
|
|
93
|
-
export declare function defineFunction(functionConfig:
|
|
99
|
+
export declare function defineFunction(functionConfig: BlueprintBaseFunctionConfig, options?: {
|
|
94
100
|
skipValidation?: boolean;
|
|
95
101
|
}): BlueprintBaseFunctionResource;
|
|
96
|
-
export {};
|