@sanity/runtime-cli 17.5.0 → 17.6.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 CHANGED
@@ -45,7 +45,7 @@ All `sanity-run` commands can also be run as `sanity <command>` when `@sanity/cl
45
45
  USAGE
46
46
  $ sanity-run blueprints add TYPE [--json] [--example <value> | -n <value> | --fn-type
47
47
  document-publish|document-create|document-delete|document-update|media-library-asset-create|media-library-asset-dele
48
- te|media-library-asset-update|scheduled-function|sync-tag-invalidate... | --language ts|js | --javascript |
48
+ te|media-library-asset-update|pub-sub|scheduled-function|sync-tag-invalidate... | --language ts|js | --javascript |
49
49
  --fn-helpers | --fn-installer skip|npm|pnpm|yarn] [-i | ]
50
50
 
51
51
  ARGUMENTS
@@ -62,8 +62,8 @@ FLAGS
62
62
  --fn-type=<option>... Document change event(s) that should trigger the function; you can specify multiple
63
63
  events by specifying this flag multiple times
64
64
  <options: document-publish|document-create|document-delete|document-update|media-library-
65
- asset-create|media-library-asset-delete|media-library-asset-update|scheduled-function|syn
66
- c-tag-invalidate>
65
+ asset-create|media-library-asset-delete|media-library-asset-update|pub-sub|scheduled-func
66
+ tion|sync-tag-invalidate>
67
67
  --javascript Use JavaScript instead of TypeScript
68
68
  --json Format output as json
69
69
  --language=<option> [default: ts] Language of the new function
@@ -90,7 +90,7 @@ EXAMPLES
90
90
  $ sanity-run blueprints add function --name my-function --fn-type document-create --fn-type document-update --lang js
91
91
  ```
92
92
 
93
- _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.5.0/src/commands/blueprints/add.ts)_
93
+ _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.0/src/commands/blueprints/add.ts)_
94
94
 
95
95
  ## `sanity-run blueprints config`
96
96
 
@@ -127,7 +127,7 @@ EXAMPLES
127
127
  $ sanity-run blueprints config --edit --project-id <projectId> --stack <name-or-id>
128
128
  ```
129
129
 
130
- _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v17.5.0/src/commands/blueprints/config.ts)_
130
+ _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.0/src/commands/blueprints/config.ts)_
131
131
 
132
132
  ## `sanity-run blueprints deploy`
133
133
 
@@ -183,7 +183,7 @@ EXAMPLES
183
183
  $ sanity-run blueprints deploy --new-stack-name <new-name>
184
184
  ```
185
185
 
186
- _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.5.0/src/commands/blueprints/deploy.ts)_
186
+ _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.0/src/commands/blueprints/deploy.ts)_
187
187
 
188
188
  ## `sanity-run blueprints destroy`
189
189
 
@@ -221,7 +221,7 @@ EXAMPLES
221
221
  $ sanity-run blueprints destroy --stack <name-or-id> --project-id <projectId> --force --no-wait
222
222
  ```
223
223
 
224
- _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.5.0/src/commands/blueprints/destroy.ts)_
224
+ _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.0/src/commands/blueprints/destroy.ts)_
225
225
 
226
226
  ## `sanity-run blueprints doctor`
227
227
 
@@ -253,7 +253,7 @@ EXAMPLES
253
253
  $ sanity-run blueprints doctor --fix
254
254
  ```
255
255
 
256
- _See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v17.5.0/src/commands/blueprints/doctor.ts)_
256
+ _See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.0/src/commands/blueprints/doctor.ts)_
257
257
 
258
258
  ## `sanity-run blueprints info`
259
259
 
@@ -291,7 +291,7 @@ EXAMPLES
291
291
  $ sanity-run blueprints info --organization-id <orgId> --stack <name-or-id>
292
292
  ```
293
293
 
294
- _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v17.5.0/src/commands/blueprints/info.ts)_
294
+ _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.0/src/commands/blueprints/info.ts)_
295
295
 
296
296
  ## `sanity-run blueprints init [DIR]`
297
297
 
@@ -355,7 +355,7 @@ EXAMPLES
355
355
  $ sanity-run blueprints init old-stack --type <json|js|ts> --project-id <projectId> --stack-id <existingStackId>
356
356
  ```
357
357
 
358
- _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v17.5.0/src/commands/blueprints/init.ts)_
358
+ _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.0/src/commands/blueprints/init.ts)_
359
359
 
360
360
  ## `sanity-run blueprints logs`
361
361
 
@@ -401,7 +401,7 @@ EXAMPLES
401
401
  $ sanity-run blueprints logs --before 2026-05-01T00:00:00Z
402
402
  ```
403
403
 
404
- _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.5.0/src/commands/blueprints/logs.ts)_
404
+ _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.0/src/commands/blueprints/logs.ts)_
405
405
 
406
406
  ## `sanity-run blueprints mint-deploy-token`
407
407
 
@@ -446,7 +446,7 @@ EXAMPLES
446
446
  $ sanity-run blueprints mint-deploy-token --organization-id <orgId>
447
447
  ```
448
448
 
449
- _See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v17.5.0/src/commands/blueprints/mint-deploy-token.ts)_
449
+ _See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.0/src/commands/blueprints/mint-deploy-token.ts)_
450
450
 
451
451
  ## `sanity-run blueprints plan`
452
452
 
@@ -479,7 +479,7 @@ EXAMPLES
479
479
  $ sanity-run blueprints plan --organization-id <orgId> --stack <name-or-id>
480
480
  ```
481
481
 
482
- _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v17.5.0/src/commands/blueprints/plan.ts)_
482
+ _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.0/src/commands/blueprints/plan.ts)_
483
483
 
484
484
  ## `sanity-run blueprints promote`
485
485
 
@@ -515,7 +515,7 @@ EXAMPLES
515
515
  $ sanity-run blueprints promote --new-stack-name <new-name>
516
516
  ```
517
517
 
518
- _See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v17.5.0/src/commands/blueprints/promote.ts)_
518
+ _See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.0/src/commands/blueprints/promote.ts)_
519
519
 
520
520
  ## `sanity-run blueprints stacks`
521
521
 
@@ -551,7 +551,7 @@ EXAMPLES
551
551
  $ sanity-run blueprints stacks --organization-id <organizationId> --include-projects
552
552
  ```
553
553
 
554
- _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v17.5.0/src/commands/blueprints/stacks.ts)_
554
+ _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.0/src/commands/blueprints/stacks.ts)_
555
555
 
556
556
  ## `sanity-run functions add`
557
557
 
@@ -561,7 +561,7 @@ Add a Function to your Blueprint
561
561
  USAGE
562
562
  $ sanity-run functions add [--json] [--example <value> | -n <value> | --type
563
563
  document-publish|document-create|document-delete|document-update|media-library-asset-create|media-library-asset-dele
564
- te|media-library-asset-update|scheduled-function|sync-tag-invalidate... | --language ts|js | --javascript |
564
+ te|media-library-asset-update|pub-sub|scheduled-function|sync-tag-invalidate... | --language ts|js | --javascript |
565
565
  --helpers | --installer skip|npm|pnpm|yarn | -i]
566
566
 
567
567
  FLAGS
@@ -578,8 +578,8 @@ FLAGS
578
578
  --type=<option>... Document change event(s) that should trigger the function; you can specify multiple events
579
579
  by specifying this flag multiple times
580
580
  <options: document-publish|document-create|document-delete|document-update|media-library-ass
581
- et-create|media-library-asset-delete|media-library-asset-update|scheduled-function|sync-tag-
582
- invalidate>
581
+ et-create|media-library-asset-delete|media-library-asset-update|pub-sub|scheduled-function|s
582
+ ync-tag-invalidate>
583
583
 
584
584
  DESCRIPTION
585
585
  Add a Function to your Blueprint
@@ -603,7 +603,7 @@ EXAMPLES
603
603
  $ sanity-run functions add --name my-function --type document-create --type document-update --lang js
604
604
  ```
605
605
 
606
- _See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.5.0/src/commands/functions/add.ts)_
606
+ _See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.0/src/commands/functions/add.ts)_
607
607
 
608
608
  ## `sanity-run functions dev`
609
609
 
@@ -638,7 +638,7 @@ EXAMPLES
638
638
  $ sanity-run functions dev --timeout 60
639
639
  ```
640
640
 
641
- _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v17.5.0/src/commands/functions/dev.ts)_
641
+ _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.0/src/commands/functions/dev.ts)_
642
642
 
643
643
  ## `sanity-run functions env add NAME KEY VALUE`
644
644
 
@@ -671,7 +671,7 @@ EXAMPLES
671
671
  $ sanity-run functions env add --stack <name-or-id> MyFunction API_URL https://api.example.com/
672
672
  ```
673
673
 
674
- _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.5.0/src/commands/functions/env/add.ts)_
674
+ _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.0/src/commands/functions/env/add.ts)_
675
675
 
676
676
  ## `sanity-run functions env list NAME`
677
677
 
@@ -701,7 +701,7 @@ EXAMPLES
701
701
  $ sanity-run functions env list --stack <name-or-id> MyFunction
702
702
  ```
703
703
 
704
- _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v17.5.0/src/commands/functions/env/list.ts)_
704
+ _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.0/src/commands/functions/env/list.ts)_
705
705
 
706
706
  ## `sanity-run functions env remove NAME KEY`
707
707
 
@@ -733,7 +733,7 @@ EXAMPLES
733
733
  $ sanity-run functions env remove --stack <name-or-id> MyFunction API_URL
734
734
  ```
735
735
 
736
- _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v17.5.0/src/commands/functions/env/remove.ts)_
736
+ _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.0/src/commands/functions/env/remove.ts)_
737
737
 
738
738
  ## `sanity-run functions logs [NAME]`
739
739
 
@@ -773,7 +773,7 @@ EXAMPLES
773
773
  $ sanity-run functions logs <name> --delete
774
774
  ```
775
775
 
776
- _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.5.0/src/commands/functions/logs.ts)_
776
+ _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.0/src/commands/functions/logs.ts)_
777
777
 
778
778
  ## `sanity-run functions test [NAME]`
779
779
 
@@ -830,7 +830,7 @@ EXAMPLES
830
830
  $ sanity-run functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
831
831
  ```
832
832
 
833
- _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v17.5.0/src/commands/functions/test.ts)_
833
+ _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v17.6.0/src/commands/functions/test.ts)_
834
834
 
835
835
  ## `sanity-run help [COMMAND]`
836
836
 
@@ -5,7 +5,7 @@ import { pathToFileURL } from 'node:url';
5
5
  import blueprintParserValidator from '@sanity/blueprints-parser';
6
6
  import * as find from 'empathic/find';
7
7
  import { createJiti } from 'jiti';
8
- import { SANITY_FUNCTION_DOCUMENT, SANITY_FUNCTION_MEDIA_LIBRARY_ASSET, SANITY_FUNCTION_SCHEDULED, } from '../../constants.js';
8
+ import { SANITY_FUNCTION_DOCUMENT, SANITY_FUNCTION_DURABLE, SANITY_FUNCTION_MEDIA_LIBRARY_ASSET, SANITY_FUNCTION_SCHEDULED, } from '../../constants.js';
9
9
  import { validateResources } from '../../utils/blueprints/validate-resources.js';
10
10
  import { backfillProjectBasedStackId, readConfigFile, } from './config.js';
11
11
  import { resolveIds } from './resolve.js';
@@ -122,6 +122,7 @@ export function parseBlueprintContent(rawBlueprint, options) {
122
122
  SANITY_FUNCTION_DOCUMENT,
123
123
  SANITY_FUNCTION_MEDIA_LIBRARY_ASSET,
124
124
  SANITY_FUNCTION_SCHEDULED,
125
+ SANITY_FUNCTION_DURABLE,
125
126
  ],
126
127
  });
127
128
  const parsedBlueprint = parserResult.result === 'valid' ? parserResult.blueprint : undefined;
@@ -2,7 +2,7 @@ import { spawn } from 'node:child_process';
2
2
  import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
3
3
  import { dirname, join } from 'node:path';
4
4
  import { cwd } from 'node:process';
5
- import { MAP_EVENT_TO_FUNCTION_TYPE, SANITY_FUNCTION_DOCUMENT, SANITY_FUNCTION_MEDIA_LIBRARY_ASSET, SANITY_FUNCTION_SCHEDULED, SANITY_FUNCTION_SYNC_TAG_INVALIDATE, } from '../../constants.js';
5
+ import { MAP_EVENT_TO_FUNCTION_TYPE, SANITY_FUNCTION_DOCUMENT, SANITY_FUNCTION_MEDIA_LIBRARY_ASSET, SANITY_FUNCTION_PUBSUB, SANITY_FUNCTION_SCHEDULED, SANITY_FUNCTION_SYNC_TAG_INVALIDATE, } from '../../constants.js';
6
6
  import { styleText } from '../../utils/style-text.js';
7
7
  import { writeOrUpdateNodeDependency } from '../node.js';
8
8
  import { addResourceToBlueprint } from './blueprint.js';
@@ -36,6 +36,12 @@ export const handler = syncTagInvalidateEventHandler(async ({ context, event, do
36
36
  console.error('Error invoking Sanity invalidation done endpoint!', e)
37
37
  }
38
38
  })`;
39
+ const DEFAULT_PUBSUB_HELPER_FUNCTION_TEMPLATE = /*ts*/ `import { pubSubEventHandler } from '@sanity/functions'
40
+
41
+ export const handler = pubSubEventHandler(async ({ context, event }) => {
42
+ const time = new Date().toLocaleTimeString()
43
+ console.log(\`Your pubsub Sanity Function was called at \${time}\`)
44
+ })`;
39
45
  /**
40
46
  * Creates a new function resource file and adds it to the blueprint
41
47
  */
@@ -68,6 +74,9 @@ export async function createFunctionResource(options, logger) {
68
74
  let template = DEFAULT_FUNCTION_TEMPLATE;
69
75
  if (addHelpers) {
70
76
  switch (functionType) {
77
+ case SANITY_FUNCTION_PUBSUB:
78
+ template = DEFAULT_PUBSUB_HELPER_FUNCTION_TEMPLATE;
79
+ break;
71
80
  case SANITY_FUNCTION_SCHEDULED:
72
81
  template = DEFAULT_SCHEDULED_HELPER_FUNCTION_TEMPLATE;
73
82
  break;
@@ -119,6 +128,13 @@ export async function createFunctionResource(options, logger) {
119
128
  },
120
129
  };
121
130
  break;
131
+ case SANITY_FUNCTION_PUBSUB:
132
+ resourceJson = {
133
+ name,
134
+ src: `functions/${name}`,
135
+ type: SANITY_FUNCTION_PUBSUB,
136
+ };
137
+ break;
122
138
  case SANITY_FUNCTION_SCHEDULED:
123
139
  resourceJson = {
124
140
  name,
@@ -3,8 +3,10 @@ export declare const SANITY_ACCESS_ROBOT = "sanity.access.robot";
3
3
  export declare const SANITY_FUNCTION_PREFIX = "sanity.function.";
4
4
  export declare const SANITY_FUNCTION_DOCUMENT = "sanity.function.document";
5
5
  export declare const SANITY_FUNCTION_MEDIA_LIBRARY_ASSET = "sanity.function.media-library.asset";
6
+ export declare const SANITY_FUNCTION_PUBSUB = "sanity.function.pubsub";
6
7
  export declare const SANITY_FUNCTION_SCHEDULED = "sanity.function.cron";
7
8
  export declare const SANITY_FUNCTION_SYNC_TAG_INVALIDATE = "sanity.function.sync-tag-invalidate";
9
+ export declare const SANITY_FUNCTION_DURABLE = "sanity.function.durable";
8
10
  export declare const SANITY_PROJECT = "sanity.project";
9
11
  export declare const SANITY_PROJECT_CORS = "sanity.project.cors";
10
12
  export declare const SANITY_PROJECT_DATASET = "sanity.project.dataset";
@@ -17,6 +19,7 @@ export declare const EVENT_DOCUMENT_DELETE = "document-delete";
17
19
  export declare const EVENT_MEDIA_LIBRARY_ASSET_CREATE = "media-library-asset-create";
18
20
  export declare const EVENT_MEDIA_LIBRARY_ASSET_UPDATE = "media-library-asset-update";
19
21
  export declare const EVENT_MEDIA_LIBRARY_ASSET_DELETE = "media-library-asset-delete";
22
+ export declare const EVENT_PUBSUB = "pub-sub";
20
23
  export declare const EVENT_SCHEDULED = "scheduled-function";
21
24
  export declare const EVENT_SYNC_TAG_INVALIDATE = "sync-tag-invalidate";
22
25
  export declare const MAP_EVENT_TO_FUNCTION_TYPE: {
@@ -27,6 +30,7 @@ export declare const MAP_EVENT_TO_FUNCTION_TYPE: {
27
30
  readonly "media-library-asset-create": "sanity.function.media-library.asset";
28
31
  readonly "media-library-asset-delete": "sanity.function.media-library.asset";
29
32
  readonly "media-library-asset-update": "sanity.function.media-library.asset";
33
+ readonly "pub-sub": "sanity.function.pubsub";
30
34
  readonly "scheduled-function": "sanity.function.cron";
31
35
  readonly "sync-tag-invalidate": "sanity.function.sync-tag-invalidate";
32
36
  };
@@ -42,6 +46,7 @@ export declare const LABEL_DOCUMENT_DELETE = "Document Delete";
42
46
  export declare const LABEL_MEDIA_LIBRARY_ASSET_CREATE = "Media Library Asset Create";
43
47
  export declare const LABEL_MEDIA_LIBRARY_ASSET_UPDATE = "Media Library Asset Update";
44
48
  export declare const LABEL_MEDIA_LIBRARY_ASSET_DELETE = "Media Library Asset Delete";
49
+ export declare const LABEL_PUBSUB = "PubSub";
45
50
  export declare const LABEL_SCHEDULED = "Scheduled";
46
51
  export declare const LABEL_SYNC_TAG_INVALIDATE = "Sync Tag Invalidate";
47
52
  export declare const CI_SETUP_DOCS_URL = "https://www.sanity.io/docs/blueprints/deploy-blueprints-from-ci";
package/dist/constants.js CHANGED
@@ -3,8 +3,10 @@ export const SANITY_ACCESS_ROBOT = 'sanity.access.robot';
3
3
  export const SANITY_FUNCTION_PREFIX = 'sanity.function.';
4
4
  export const SANITY_FUNCTION_DOCUMENT = 'sanity.function.document';
5
5
  export const SANITY_FUNCTION_MEDIA_LIBRARY_ASSET = 'sanity.function.media-library.asset';
6
+ export const SANITY_FUNCTION_PUBSUB = 'sanity.function.pubsub';
6
7
  export const SANITY_FUNCTION_SCHEDULED = 'sanity.function.cron';
7
8
  export const SANITY_FUNCTION_SYNC_TAG_INVALIDATE = 'sanity.function.sync-tag-invalidate';
9
+ export const SANITY_FUNCTION_DURABLE = 'sanity.function.durable';
8
10
  export const SANITY_PROJECT = 'sanity.project';
9
11
  export const SANITY_PROJECT_CORS = 'sanity.project.cors';
10
12
  export const SANITY_PROJECT_DATASET = 'sanity.project.dataset';
@@ -17,6 +19,7 @@ export const EVENT_DOCUMENT_DELETE = 'document-delete';
17
19
  export const EVENT_MEDIA_LIBRARY_ASSET_CREATE = 'media-library-asset-create';
18
20
  export const EVENT_MEDIA_LIBRARY_ASSET_UPDATE = 'media-library-asset-update';
19
21
  export const EVENT_MEDIA_LIBRARY_ASSET_DELETE = 'media-library-asset-delete';
22
+ export const EVENT_PUBSUB = 'pub-sub';
20
23
  export const EVENT_SCHEDULED = 'scheduled-function';
21
24
  export const EVENT_SYNC_TAG_INVALIDATE = 'sync-tag-invalidate';
22
25
  export const MAP_EVENT_TO_FUNCTION_TYPE = {
@@ -27,6 +30,7 @@ export const MAP_EVENT_TO_FUNCTION_TYPE = {
27
30
  [EVENT_MEDIA_LIBRARY_ASSET_CREATE]: SANITY_FUNCTION_MEDIA_LIBRARY_ASSET,
28
31
  [EVENT_MEDIA_LIBRARY_ASSET_DELETE]: SANITY_FUNCTION_MEDIA_LIBRARY_ASSET,
29
32
  [EVENT_MEDIA_LIBRARY_ASSET_UPDATE]: SANITY_FUNCTION_MEDIA_LIBRARY_ASSET,
33
+ [EVENT_PUBSUB]: SANITY_FUNCTION_PUBSUB,
30
34
  [EVENT_SCHEDULED]: SANITY_FUNCTION_SCHEDULED,
31
35
  [EVENT_SYNC_TAG_INVALIDATE]: SANITY_FUNCTION_SYNC_TAG_INVALIDATE,
32
36
  };
@@ -35,6 +39,7 @@ export const PROJECT_SCOPED_FUNCTION_TYPES = new Set([
35
39
  SANITY_FUNCTION_DOCUMENT,
36
40
  SANITY_FUNCTION_MEDIA_LIBRARY_ASSET,
37
41
  SANITY_FUNCTION_SYNC_TAG_INVALIDATE,
42
+ SANITY_FUNCTION_DURABLE,
38
43
  ]);
39
44
  export const ORGANIZATION_SCOPED_FUNCTION_TYPES = new Set([
40
45
  SANITY_FUNCTION_SCHEDULED,
@@ -47,6 +52,7 @@ export const LABEL_DOCUMENT_DELETE = 'Document Delete';
47
52
  export const LABEL_MEDIA_LIBRARY_ASSET_CREATE = 'Media Library Asset Create';
48
53
  export const LABEL_MEDIA_LIBRARY_ASSET_UPDATE = 'Media Library Asset Update';
49
54
  export const LABEL_MEDIA_LIBRARY_ASSET_DELETE = 'Media Library Asset Delete';
55
+ export const LABEL_PUBSUB = 'PubSub';
50
56
  export const LABEL_SCHEDULED = 'Scheduled';
51
57
  export const LABEL_SYNC_TAG_INVALIDATE = 'Sync Tag Invalidate';
52
58
  export const CI_SETUP_DOCS_URL = 'https://www.sanity.io/docs/blueprints/deploy-blueprints-from-ci';
@@ -3,6 +3,7 @@ import { preDeploy } from '../../actions/blueprints/pre-deploy.js';
3
3
  import { getStack, updateStack } from '../../actions/blueprints/stacks.js';
4
4
  import { waitForOperation } from '../../actions/blueprints/wait-for-operation.js';
5
5
  import { checkUserPermission } from '../../actions/sanity/access.js';
6
+ import { extractDurableConfig } from '../../utils/blueprints/extract-durable-config.js';
6
7
  import { createHintCollector } from '../../utils/blueprints/hints.js';
7
8
  import { check, niceId, severe } from '../../utils/display/presenters.js';
8
9
  import { CODE_OPERATION_UNCONFIRMED, EXIT_OPERATION_UNCONFIRMED } from '../../utils/exit-codes.js';
@@ -34,6 +35,7 @@ export async function blueprintDeployCore(options) {
34
35
  };
35
36
  }
36
37
  const resources = [...blueprint.resources];
38
+ await extractDurableConfig(resources, blueprintFileDir);
37
39
  const preDeployResult = await preDeploy({
38
40
  scopeType,
39
41
  scopeId,
@@ -1,5 +1,6 @@
1
1
  import { dirname } from 'node:path';
2
2
  import { planStack, resolveStackIdByNameOrId } from '../../actions/blueprints/stacks.js';
3
+ import { extractDurableConfig } from '../../utils/blueprints/extract-durable-config.js';
3
4
  import { createHintCollector } from '../../utils/blueprints/hints.js';
4
5
  import { formatDeploymentPlan, formatResourceTree, hasActionableChanges, } from '../../utils/display/blueprints-formatting.js';
5
6
  import { styleText } from '../../utils/style-text.js';
@@ -9,6 +10,7 @@ export async function blueprintPlanCore(options) {
9
10
  const { verbose: _verbose = false } = flags;
10
11
  const { scopeType, scopeId, stackId: blueprintStackId, parsedBlueprint, resources, fileInfo, } = blueprint;
11
12
  log(`${styleText(['bold', 'blueBright'], 'Local Blueprint')} ${styleText('dim', `(${fileInfo.fileName})`)}`);
13
+ await extractDurableConfig(resources, dirname(fileInfo.blueprintFilePath));
12
14
  log(formatResourceTree(resources));
13
15
  if (!token || !scopeType || !scopeId) {
14
16
  log(styleText('dim', 'Unable to retrieve live Stack deployment for comparison'));
@@ -5,7 +5,7 @@ import { checkbox, confirm, input, select } from '@inquirer/prompts';
5
5
  import { highlight } from 'cardinal';
6
6
  import { createFunctionResource } from '../../actions/blueprints/resources.js';
7
7
  import { verifyExampleExists, writeExample } from '../../actions/sanity/examples.js';
8
- import { EVENT_DOCUMENT_CREATE, EVENT_DOCUMENT_DELETE, EVENT_DOCUMENT_UPDATE, EVENT_MEDIA_LIBRARY_ASSET_CREATE, EVENT_MEDIA_LIBRARY_ASSET_DELETE, EVENT_MEDIA_LIBRARY_ASSET_UPDATE, EVENT_SCHEDULED, EVENT_SYNC_TAG_INVALIDATE, FUNCTION_TYPES, LABEL_DOCUMENT_CREATE, LABEL_DOCUMENT_DELETE, LABEL_DOCUMENT_UPDATE, LABEL_MEDIA_LIBRARY_ASSET_CREATE, LABEL_MEDIA_LIBRARY_ASSET_DELETE, LABEL_MEDIA_LIBRARY_ASSET_UPDATE, LABEL_SCHEDULED, LABEL_SYNC_TAG_INVALIDATE, MAP_EVENT_TO_FUNCTION_TYPE, SANITY_FUNCTION_DOCUMENT, SANITY_FUNCTION_MEDIA_LIBRARY_ASSET, SANITY_FUNCTION_SCHEDULED, SANITY_FUNCTION_SYNC_TAG_INVALIDATE, } from '../../constants.js';
8
+ import { EVENT_DOCUMENT_CREATE, EVENT_DOCUMENT_DELETE, EVENT_DOCUMENT_UPDATE, EVENT_MEDIA_LIBRARY_ASSET_CREATE, EVENT_MEDIA_LIBRARY_ASSET_DELETE, EVENT_MEDIA_LIBRARY_ASSET_UPDATE, EVENT_PUBSUB, EVENT_SCHEDULED, EVENT_SYNC_TAG_INVALIDATE, FUNCTION_TYPES, LABEL_DOCUMENT_CREATE, LABEL_DOCUMENT_DELETE, LABEL_DOCUMENT_UPDATE, LABEL_MEDIA_LIBRARY_ASSET_CREATE, LABEL_MEDIA_LIBRARY_ASSET_DELETE, LABEL_MEDIA_LIBRARY_ASSET_UPDATE, LABEL_PUBSUB, LABEL_SCHEDULED, LABEL_SYNC_TAG_INVALIDATE, MAP_EVENT_TO_FUNCTION_TYPE, SANITY_FUNCTION_DOCUMENT, SANITY_FUNCTION_MEDIA_LIBRARY_ASSET, SANITY_FUNCTION_PUBSUB, SANITY_FUNCTION_SCHEDULED, SANITY_FUNCTION_SYNC_TAG_INVALIDATE, } from '../../constants.js';
9
9
  import { check, indent, warn } from '../../utils/display/presenters.js';
10
10
  import { validateFunctionName } from '../../utils/functions/validate-name.js';
11
11
  import { styleText } from '../../utils/style-text.js';
@@ -21,6 +21,9 @@ export const generateFunctionBlueprintResourceTemplate = (fnName, eventNames) =>
21
21
  case SANITY_FUNCTION_MEDIA_LIBRARY_ASSET:
22
22
  definer = `defineMediaLibraryAssetFunction({name: '${fnName}', event: {on: [${eventOns.join(', ')}], resource: {type: 'media-library', id: 'my-media-library-id'}}}), // ← add this line`;
23
23
  break;
24
+ case SANITY_FUNCTION_PUBSUB:
25
+ definer = `definePubSubFunction({name: '${fnName}'}), // ← add this line`;
26
+ break;
24
27
  case SANITY_FUNCTION_SCHEDULED:
25
28
  definer = `defineScheduledFunction({name: '${fnName}', event: {expression: '0 0 * * *'}}), // ← add this line`;
26
29
  break;
@@ -158,7 +161,7 @@ export async function functionAddCore(options) {
158
161
  }
159
162
  const eventSources = new Set(fnTypes.map((t) => t.substring(0, t.lastIndexOf('-'))));
160
163
  if (eventSources.size > 1) {
161
- throw new Error('Invalid function type. Cannot mix document-*, media-library-asset-*, sync-tag-* and/or scheduled-* types.');
164
+ throw new Error('Invalid function type. Cannot mix document-*, media-library-asset-*, pub-sub, sync-tag-* and/or scheduled-* types.');
162
165
  }
163
166
  let addHelpers;
164
167
  let installCommand;
@@ -242,6 +245,7 @@ async function promptForFunctionType() {
242
245
  { name: LABEL_MEDIA_LIBRARY_ASSET_CREATE, value: EVENT_MEDIA_LIBRARY_ASSET_CREATE },
243
246
  { name: LABEL_MEDIA_LIBRARY_ASSET_UPDATE, value: EVENT_MEDIA_LIBRARY_ASSET_UPDATE },
244
247
  { name: LABEL_MEDIA_LIBRARY_ASSET_DELETE, value: EVENT_MEDIA_LIBRARY_ASSET_DELETE },
248
+ { name: LABEL_PUBSUB, value: EVENT_PUBSUB },
245
249
  { name: LABEL_SCHEDULED, value: EVENT_SCHEDULED },
246
250
  { name: LABEL_SYNC_TAG_INVALIDATE, value: EVENT_SYNC_TAG_INVALIDATE },
247
251
  ],
@@ -249,11 +253,10 @@ async function promptForFunctionType() {
249
253
  if (choices.length === 0) {
250
254
  return 'You must choose at least one function type / document change event';
251
255
  }
252
- const hasMedia = choices.some((c) => String(c.value).startsWith('media-library'));
253
- const hasDocument = choices.some((c) => String(c.value).startsWith('document'));
254
- const hasSchedule = choices.some((c) => String(c.value).startsWith('scheduled'));
255
- if ((hasMedia && hasDocument) || (hasMedia && hasSchedule) || (hasDocument && hasSchedule)) {
256
- return 'You cannot mix Document, Media Library Asset, and Scheduled events together in one Function';
256
+ // same grouping as the check in functionAddCore, so the prompt cannot drift from it
257
+ const eventSources = new Set(choices.map((c) => String(c.value).substring(0, String(c.value).lastIndexOf('-'))));
258
+ if (eventSources.size > 1) {
259
+ return 'You cannot mix Document, Media Library Asset, PubSub, Scheduled, and Sync Tag Invalidate events together in one Function';
257
260
  }
258
261
  return true;
259
262
  },
@@ -9,6 +9,7 @@ export class ApiBaseElement extends HTMLElement {
9
9
  this.api = api
10
10
  this.SANITY_FUNCTION_DOCUMENT = 'sanity.function.document'
11
11
  this.SANITY_FUNCTION_MEDIA_LIBRARY_ASSET = 'sanity.function.media-library.asset'
12
+ this.SANITY_FUNCTION_PUBSUB = 'sanity.function.pubsub'
12
13
  this.SANITY_FUNCTION_SCHEDULED = 'sanity.function.cron'
13
14
  this.SANITY_FUNCTION_SYNC_TAG_INVALIDATE = 'sanity.function.sync-tag-invalidate'
14
15
  }
@@ -79,6 +79,7 @@ class FiltersComponent extends ApiBaseElement {
79
79
  const mediaFunction = this.api.store.selectedFunctionType?.startsWith(
80
80
  this.SANITY_FUNCTION_MEDIA_LIBRARY_ASSET,
81
81
  )
82
+ const pubsubFunction = this.api.store.selectedFunctionType === this.SANITY_FUNCTION_PUBSUB
82
83
  const scheduleFunction = this.api.store.selectedFunctionType === this.SANITY_FUNCTION_SCHEDULED
83
84
  const stiFunction =
84
85
  this.api.store.selectedFunctionType === this.SANITY_FUNCTION_SYNC_TAG_INVALIDATE
@@ -89,15 +90,16 @@ class FiltersComponent extends ApiBaseElement {
89
90
  mediaFunction,
90
91
  scheduleFunction,
91
92
  stiFunction,
93
+ pubsubFunction,
92
94
  )
93
95
  }
94
96
 
95
- buildFilters = (docFunction, mediaFunction, scheduleFunction, stiFunction) => {
97
+ buildFilters = (docFunction, mediaFunction, scheduleFunction, stiFunction, pubsubFunction) => {
96
98
  return `
97
99
  <legend class="config-label">Client Options</legend>
98
100
  <div id="dynamic-dropdowns" class="flex gap-2">
99
101
  ${
100
- docFunction || scheduleFunction || stiFunction
102
+ docFunction || scheduleFunction || stiFunction || pubsubFunction
101
103
  ? `<select-dropdown
102
104
  label="Project"
103
105
  store-key="projects"
@@ -164,6 +164,9 @@ class PayloadPanel extends ApiBaseElement {
164
164
  const payloadTitle = this.shadowRoot.querySelector('#payloadTitle')
165
165
  let title = 'Document'
166
166
  switch (selectedFunctionType) {
167
+ case this.SANITY_FUNCTION_PUBSUB:
168
+ title = 'PubSub Payload'
169
+ break
167
170
  case this.SANITY_FUNCTION_SYNC_TAG_INVALIDATE:
168
171
  title = 'Sync Tag Payload'
169
172
  break
@@ -0,0 +1,8 @@
1
+ import { type BlueprintResource } from '@sanity/blueprints';
2
+ /**
3
+ * Extracts the blueprint config from the function source code and mutates it to the resource object.
4
+ * This is used for durable functions that may not have a config defined in the blueprint.
5
+ * @param resources
6
+ * @param blueprintFileDir
7
+ */
8
+ export declare const extractDurableConfig: (resources: BlueprintResource[], blueprintFileDir: string) => Promise<void>;
@@ -0,0 +1,60 @@
1
+ import { resolve } from 'node:path';
2
+ import { pathToFileURL } from 'node:url';
3
+ import { validateDurableFunction, } from '@sanity/blueprints';
4
+ import { SANITY_FUNCTION_DURABLE } from '../../constants.js';
5
+ import { findFunctionEntryPoint } from '../functions/find-entry-point.js';
6
+ import { transpileFunction } from '../functions/transpile/function.js';
7
+ import { isLocalFunctionResource } from '../types.js';
8
+ const DURABLE_CONFIG_KEYS = ['event', 'concurrency', 'debounce', 'debounceKey'];
9
+ /**
10
+ * Extracts the blueprint config from the function source code and mutates it to the resource object.
11
+ * This is used for durable functions that may not have a config defined in the blueprint.
12
+ * @param resources
13
+ * @param blueprintFileDir
14
+ */
15
+ export const extractDurableConfig = async (resources, blueprintFileDir) => {
16
+ for (const resource of resources) {
17
+ if (!isLocalFunctionResource(resource))
18
+ continue;
19
+ // skip if not a durable function
20
+ if (resource.type !== SANITY_FUNCTION_DURABLE)
21
+ continue;
22
+ // Check if source needs to be transpiled before attempting to get config
23
+ const resourceSrc = resolve(blueprintFileDir, resource.src);
24
+ const entryPoint = await findFunctionEntryPoint(resourceSrc, resource.name);
25
+ let importPath = entryPoint;
26
+ let cleanup = async () => { };
27
+ // need to transpile and grab the config from the built output if the entry point is a TypeScript file
28
+ if (entryPoint.endsWith('.ts')) {
29
+ const built = await transpileFunction({ resource, functionPath: resourceSrc, entryPoint });
30
+ importPath = await findFunctionEntryPoint(built.outputDir, resource.name);
31
+ cleanup = built.cleanup;
32
+ }
33
+ let config = {};
34
+ try {
35
+ const mod = await import(pathToFileURL(importPath).href);
36
+ config = (mod.handler || mod.default)?.config;
37
+ }
38
+ finally {
39
+ await cleanup();
40
+ }
41
+ // Update values not included in the blueprint.
42
+ if (resource.event === undefined && config?.event !== undefined) {
43
+ resource.event = config.event;
44
+ }
45
+ if (resource.concurrency === undefined && config?.concurrency !== undefined) {
46
+ resource.concurrency = config.concurrency;
47
+ }
48
+ if (resource.debounce === undefined && config?.debounce !== undefined) {
49
+ resource.debounce = config.debounce;
50
+ }
51
+ if (resource.debounceKey === undefined && config?.debounceKey !== undefined) {
52
+ resource.debounceKey = config.debounceKey;
53
+ }
54
+ // Validate the resource after merging the config values
55
+ const errors = validateDurableFunction(resource);
56
+ if (errors.length > 0) {
57
+ throw new Error(`Invalid durable resource "${resource.name}": ${errors.map((error) => error.message).join('; ')}`);
58
+ }
59
+ }
60
+ };
@@ -1,5 +1,5 @@
1
- import { validateCorsOrigin, validateDataset, validateDocumentFunction, validateDocumentWebhook, validateMediaLibraryAssetFunction, validateProject, validateRole, validateScheduledFunction, } from '@sanity/blueprints';
2
- import { SANITY_ACCESS_ROLE, SANITY_FUNCTION_DOCUMENT, SANITY_FUNCTION_MEDIA_LIBRARY_ASSET, SANITY_FUNCTION_SCHEDULED, SANITY_PROJECT, SANITY_PROJECT_CORS, SANITY_PROJECT_DATASET, SANITY_PROJECT_WEBHOOK, } from '../../constants.js';
1
+ import { validateCorsOrigin, validateDataset, validateDocumentFunction, validateDocumentWebhook, validateDurableFunction, validateMediaLibraryAssetFunction, validateProject, validateRole, validateScheduledFunction, } from '@sanity/blueprints';
2
+ import { SANITY_ACCESS_ROLE, SANITY_FUNCTION_DOCUMENT, SANITY_FUNCTION_DURABLE, SANITY_FUNCTION_MEDIA_LIBRARY_ASSET, SANITY_FUNCTION_SCHEDULED, SANITY_PROJECT, SANITY_PROJECT_CORS, SANITY_PROJECT_DATASET, SANITY_PROJECT_WEBHOOK, } from '../../constants.js';
3
3
  const RESOURCE_VALIDATORS = {
4
4
  [SANITY_ACCESS_ROLE]: {
5
5
  validate: validateRole,
@@ -25,6 +25,9 @@ const RESOURCE_VALIDATORS = {
25
25
  [SANITY_PROJECT_WEBHOOK]: {
26
26
  validate: validateDocumentWebhook,
27
27
  },
28
+ [SANITY_FUNCTION_DURABLE]: {
29
+ validate: validateDurableFunction,
30
+ },
28
31
  };
29
32
  export function validateResources(resources) {
30
33
  const errors = [];
@@ -1,5 +1,5 @@
1
1
  import { treeify } from 'array-treeify';
2
- import { SANITY_ACCESS_ROBOT, SANITY_ACCESS_ROLE, SANITY_FUNCTION_DOCUMENT, SANITY_FUNCTION_MEDIA_LIBRARY_ASSET, SANITY_FUNCTION_SCHEDULED, SANITY_FUNCTION_SYNC_TAG_INVALIDATE, SANITY_PROJECT, SANITY_PROJECT_CORS, SANITY_PROJECT_DATASET, SANITY_PROJECT_WEBHOOK, } from '../../constants.js';
2
+ import { SANITY_ACCESS_ROBOT, SANITY_ACCESS_ROLE, SANITY_FUNCTION_DOCUMENT, SANITY_FUNCTION_DURABLE, SANITY_FUNCTION_MEDIA_LIBRARY_ASSET, SANITY_FUNCTION_PUBSUB, SANITY_FUNCTION_SCHEDULED, SANITY_FUNCTION_SYNC_TAG_INVALIDATE, SANITY_PROJECT, SANITY_PROJECT_CORS, SANITY_PROJECT_DATASET, SANITY_PROJECT_WEBHOOK, } from '../../constants.js';
3
3
  import { styleText } from '../style-text.js';
4
4
  import { isCorsOriginResource, isDatasetResource, isRobotResource, isRoleResource, isWebhookResource, } from '../types.js';
5
5
  import { formatDateTime, formatDuration } from './dates.js';
@@ -27,8 +27,10 @@ const RESOURCE_CATEGORIES = {
27
27
  },
28
28
  [SANITY_FUNCTION_DOCUMENT]: functionCategory,
29
29
  [SANITY_FUNCTION_MEDIA_LIBRARY_ASSET]: functionCategory,
30
+ [SANITY_FUNCTION_PUBSUB]: functionCategory,
30
31
  [SANITY_FUNCTION_SCHEDULED]: functionCategory,
31
32
  [SANITY_FUNCTION_SYNC_TAG_INVALIDATE]: functionCategory,
33
+ [SANITY_FUNCTION_DURABLE]: functionCategory,
32
34
  [SANITY_PROJECT]: {
33
35
  label: 'Projects',
34
36
  displayNameAttribute: 'displayName',
@@ -215,11 +217,13 @@ export function formatStacksListing(stacks, currentStackId) {
215
217
  const IGNORED_PARAMS = {
216
218
  [SANITY_FUNCTION_DOCUMENT]: new Set(['src']),
217
219
  [SANITY_FUNCTION_MEDIA_LIBRARY_ASSET]: new Set(['src']),
220
+ [SANITY_FUNCTION_PUBSUB]: new Set(['src']),
218
221
  [SANITY_FUNCTION_SCHEDULED]: new Set(['src']),
219
222
  };
220
223
  const ASSET_RESOURCE_TYPES = new Set([
221
224
  SANITY_FUNCTION_DOCUMENT,
222
225
  SANITY_FUNCTION_MEDIA_LIBRARY_ASSET,
226
+ SANITY_FUNCTION_PUBSUB,
223
227
  SANITY_FUNCTION_SCHEDULED,
224
228
  ]);
225
229
  function stringifyUnknown(val) {
@@ -1,4 +1,4 @@
1
- import { isLocalFunctionResource, isScheduleEvent } from '../../utils/types.js';
1
+ import { hasEventSource, isLocalFunctionResource, isScheduleEvent, } from '../../utils/types.js';
2
2
  import { styleText } from '../style-text.js';
3
3
  function formatLabel(label) {
4
4
  return styleText('dim', `${label}:`);
@@ -46,7 +46,7 @@ export function arrayifyFunction(fn) {
46
46
  details.push(formatLabeledValue('memory', fn.memory));
47
47
  if (fn.timeout)
48
48
  details.push(formatLabeledValue('timeout', fn.timeout));
49
- if (fn.event) {
49
+ if (hasEventSource(fn) && fn.event) {
50
50
  const eventDetails = arrayifyEvent(fn.event);
51
51
  if (eventDetails) {
52
52
  details.push(formatLabel('event'));
@@ -1,4 +1,4 @@
1
- import { type BlueprintCorsOriginResource, type BlueprintDatasetResource, type BlueprintDocumentFunctionResource, type BlueprintDocumentWebhookResource, type BlueprintMediaLibraryAssetFunctionResource, type BlueprintProjectResource, type BlueprintResource, type BlueprintRobotResource, type BlueprintRoleResource, type BlueprintScheduledFunctionResource, type BlueprintStudioResource, type BlueprintSyncTagInvalidateFunctionResource } from '@sanity/blueprints';
1
+ import { type BlueprintCorsOriginResource, type BlueprintDatasetResource, type BlueprintDocumentFunctionResource, type BlueprintDocumentWebhookResource, type BlueprintDurableFunctionResource, type BlueprintMediaLibraryAssetFunctionResource, type BlueprintProjectResource, type BlueprintPubSubFunctionResource, type BlueprintResource, type BlueprintRobotResource, type BlueprintRoleResource, type BlueprintScheduledFunctionResource, type BlueprintStudioResource, type BlueprintSyncTagInvalidateFunctionResource } from '@sanity/blueprints';
2
2
  export type ScopeType = 'organization' | 'project';
3
3
  /** Result utility type */
4
4
  export type Result<T, E = string> = {
@@ -15,7 +15,11 @@ export interface ActionResponse {
15
15
  }
16
16
  /** @internal */
17
17
  export type FunctionGroqResource = BlueprintDocumentFunctionResource | BlueprintMediaLibraryAssetFunctionResource;
18
- export type FunctionResource = FunctionGroqResource | BlueprintScheduledFunctionResource | BlueprintSyncTagInvalidateFunctionResource;
18
+ export type FunctionResource = FunctionGroqResource | BlueprintPubSubFunctionResource | BlueprintScheduledFunctionResource | BlueprintSyncTagInvalidateFunctionResource | BlueprintDurableFunctionResource;
19
+ /** Function resources that declare an `event`; PubSub functions are triggered by other functions */
20
+ export type EventFunctionResource = Exclude<FunctionResource, BlueprintPubSubFunctionResource>;
21
+ /** The `event` of any function resource that declares one */
22
+ export type FunctionResourceEvent = EventFunctionResource['event'];
19
23
  /** Resource types that carry a deployable asset (have src: string) */
20
24
  export type AssetResource = FunctionResource | BlueprintStudioResource;
21
25
  /** @internal */
@@ -36,6 +40,7 @@ export interface DeployedResource extends BlueprintResourceRecord {
36
40
  externalId: string;
37
41
  }
38
42
  export declare function isLocalFunctionResource(r: BlueprintResource): r is FunctionResource;
43
+ export declare function hasEventSource(r: FunctionResource): r is EventFunctionResource;
39
44
  export declare function isScheduleEvent(e: unknown): e is BlueprintScheduledFunctionResource['event'];
40
45
  export declare function isCorsOriginResource(r: unknown): r is BlueprintCorsOriginResource;
41
46
  export declare function isProjectResource(r: unknown): r is BlueprintProjectResource;
@@ -43,6 +48,7 @@ export declare function isRobotResource(r: unknown): r is BlueprintRobotResource
43
48
  export declare function isRoleResource(r: unknown): r is BlueprintRoleResource;
44
49
  export declare function isDatasetResource(r: unknown): r is BlueprintDatasetResource;
45
50
  export declare function isStudioResource(r: BlueprintResource): r is BlueprintStudioResource;
51
+ export declare function isDurableFunctionResource(r: unknown): r is BlueprintDurableFunctionResource;
46
52
  export declare function isAssetResource(r: BlueprintResource): r is AssetResource;
47
53
  export declare function isWebhookResource(r: unknown): r is BlueprintDocumentWebhookResource;
48
54
  interface StackBase {
@@ -1,8 +1,11 @@
1
- import { validateCorsOrigin, validateDataset, validateDocumentWebhook, validateProject, validateRobot, validateRole, } from '@sanity/blueprints';
2
- import { SANITY_FUNCTION_PREFIX, SANITY_STUDIO } from '../constants.js';
1
+ import { validateCorsOrigin, validateDataset, validateDocumentWebhook, validateDurableFunction, validateProject, validateRobot, validateRole, } from '@sanity/blueprints';
2
+ import { SANITY_FUNCTION_PREFIX, SANITY_FUNCTION_PUBSUB, SANITY_STUDIO } from '../constants.js';
3
3
  export function isLocalFunctionResource(r) {
4
4
  return r.type.startsWith(SANITY_FUNCTION_PREFIX);
5
5
  }
6
+ export function hasEventSource(r) {
7
+ return r.type !== SANITY_FUNCTION_PUBSUB;
8
+ }
6
9
  // type narrowing with predicate functions
7
10
  export function isScheduleEvent(e) {
8
11
  return e !== null && typeof e === 'object' && ('hour' in e || 'expression' in e);
@@ -25,6 +28,9 @@ export function isDatasetResource(r) {
25
28
  export function isStudioResource(r) {
26
29
  return r.type === SANITY_STUDIO;
27
30
  }
31
+ export function isDurableFunctionResource(r) {
32
+ return validateDurableFunction(r).length === 0;
33
+ }
28
34
  export function isAssetResource(r) {
29
35
  return isLocalFunctionResource(r) || isStudioResource(r);
30
36
  }
@@ -148,6 +148,7 @@
148
148
  "media-library-asset-create",
149
149
  "media-library-asset-delete",
150
150
  "media-library-asset-update",
151
+ "pub-sub",
151
152
  "scheduled-function",
152
153
  "sync-tag-invalidate"
153
154
  ],
@@ -1805,6 +1806,7 @@
1805
1806
  "media-library-asset-create",
1806
1807
  "media-library-asset-delete",
1807
1808
  "media-library-asset-update",
1809
+ "pub-sub",
1808
1810
  "scheduled-function",
1809
1811
  "sync-tag-invalidate"
1810
1812
  ],
@@ -3125,5 +3127,5 @@
3125
3127
  ]
3126
3128
  }
3127
3129
  },
3128
- "version": "17.5.0"
3130
+ "version": "17.6.0"
3129
3131
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sanity/runtime-cli",
3
3
  "description": "Sanity's Runtime CLI for Blueprints and Functions",
4
- "version": "17.5.0",
4
+ "version": "17.6.0",
5
5
  "author": "Sanity Runtime Team",
6
6
  "type": "module",
7
7
  "license": "MIT",