@sanity/runtime-cli 14.8.1 → 14.8.2
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 +18 -18
- package/dist/actions/blueprints/assets.d.ts +2 -2
- package/dist/actions/blueprints/assets.js +1 -1
- package/dist/actions/blueprints/resources.js +33 -5
- package/dist/cores/blueprints/deploy.js +3 -3
- package/dist/utils/display/blueprints-formatting.d.ts +3 -2
- package/dist/utils/display/blueprints-formatting.js +3 -2
- package/dist/utils/display/resources-formatting.d.ts +2 -3
- package/dist/utils/display/resources-formatting.js +3 -3
- package/dist/utils/find-function.d.ts +3 -3
- package/dist/utils/find-function.js +3 -2
- package/dist/utils/validate/index.d.ts +2 -2
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ $ npm install -g @sanity/runtime-cli
|
|
|
20
20
|
$ sanity-run COMMAND
|
|
21
21
|
running command...
|
|
22
22
|
$ sanity-run (--version)
|
|
23
|
-
@sanity/runtime-cli/14.8.
|
|
23
|
+
@sanity/runtime-cli/14.8.2 linux-x64 node-v24.14.1
|
|
24
24
|
$ sanity-run --help [COMMAND]
|
|
25
25
|
USAGE
|
|
26
26
|
$ sanity-run COMMAND
|
|
@@ -101,7 +101,7 @@ EXAMPLES
|
|
|
101
101
|
$ sanity-run blueprints add function --name my-function --fn-type document-create --fn-type document-update --lang js
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
-
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.
|
|
104
|
+
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/blueprints/add.ts)_
|
|
105
105
|
|
|
106
106
|
## `sanity-run blueprints config`
|
|
107
107
|
|
|
@@ -140,7 +140,7 @@ EXAMPLES
|
|
|
140
140
|
$ sanity-run blueprints config --edit --project-id <projectId> --stack <name-or-id>
|
|
141
141
|
```
|
|
142
142
|
|
|
143
|
-
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.
|
|
143
|
+
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/blueprints/config.ts)_
|
|
144
144
|
|
|
145
145
|
## `sanity-run blueprints deploy`
|
|
146
146
|
|
|
@@ -179,7 +179,7 @@ EXAMPLES
|
|
|
179
179
|
$ sanity-run blueprints deploy --fn-installer npm
|
|
180
180
|
```
|
|
181
181
|
|
|
182
|
-
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.
|
|
182
|
+
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/blueprints/deploy.ts)_
|
|
183
183
|
|
|
184
184
|
## `sanity-run blueprints destroy`
|
|
185
185
|
|
|
@@ -215,7 +215,7 @@ EXAMPLES
|
|
|
215
215
|
$ sanity-run blueprints destroy --stack <name-or-id> --project-id <projectId> --force --no-wait
|
|
216
216
|
```
|
|
217
217
|
|
|
218
|
-
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.
|
|
218
|
+
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/blueprints/destroy.ts)_
|
|
219
219
|
|
|
220
220
|
## `sanity-run blueprints doctor`
|
|
221
221
|
|
|
@@ -242,7 +242,7 @@ DESCRIPTION
|
|
|
242
242
|
issues.
|
|
243
243
|
```
|
|
244
244
|
|
|
245
|
-
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.
|
|
245
|
+
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/blueprints/doctor.ts)_
|
|
246
246
|
|
|
247
247
|
## `sanity-run blueprints info`
|
|
248
248
|
|
|
@@ -274,7 +274,7 @@ EXAMPLES
|
|
|
274
274
|
$ sanity-run blueprints info --stack <name-or-id>
|
|
275
275
|
```
|
|
276
276
|
|
|
277
|
-
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.
|
|
277
|
+
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/blueprints/info.ts)_
|
|
278
278
|
|
|
279
279
|
## `sanity-run blueprints init [DIR]`
|
|
280
280
|
|
|
@@ -328,7 +328,7 @@ EXAMPLES
|
|
|
328
328
|
$ sanity-run blueprints init --blueprint-type <json|js|ts> --stack-name <stackName>
|
|
329
329
|
```
|
|
330
330
|
|
|
331
|
-
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.
|
|
331
|
+
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/blueprints/init.ts)_
|
|
332
332
|
|
|
333
333
|
## `sanity-run blueprints logs`
|
|
334
334
|
|
|
@@ -359,7 +359,7 @@ EXAMPLES
|
|
|
359
359
|
$ sanity-run blueprints logs --watch
|
|
360
360
|
```
|
|
361
361
|
|
|
362
|
-
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.
|
|
362
|
+
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/blueprints/logs.ts)_
|
|
363
363
|
|
|
364
364
|
## `sanity-run blueprints plan`
|
|
365
365
|
|
|
@@ -387,7 +387,7 @@ EXAMPLES
|
|
|
387
387
|
$ sanity-run blueprints plan
|
|
388
388
|
```
|
|
389
389
|
|
|
390
|
-
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.
|
|
390
|
+
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/blueprints/plan.ts)_
|
|
391
391
|
|
|
392
392
|
## `sanity-run blueprints stacks`
|
|
393
393
|
|
|
@@ -419,7 +419,7 @@ EXAMPLES
|
|
|
419
419
|
$ sanity-run blueprints stacks --organization-id <organizationId>
|
|
420
420
|
```
|
|
421
421
|
|
|
422
|
-
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.
|
|
422
|
+
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/blueprints/stacks.ts)_
|
|
423
423
|
|
|
424
424
|
## `sanity-run functions add`
|
|
425
425
|
|
|
@@ -472,7 +472,7 @@ EXAMPLES
|
|
|
472
472
|
$ sanity-run functions add --name my-function --type document-create --type document-update --lang js
|
|
473
473
|
```
|
|
474
474
|
|
|
475
|
-
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.
|
|
475
|
+
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/functions/add.ts)_
|
|
476
476
|
|
|
477
477
|
## `sanity-run functions dev`
|
|
478
478
|
|
|
@@ -508,7 +508,7 @@ EXAMPLES
|
|
|
508
508
|
$ sanity-run functions dev --timeout 60
|
|
509
509
|
```
|
|
510
510
|
|
|
511
|
-
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.
|
|
511
|
+
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/functions/dev.ts)_
|
|
512
512
|
|
|
513
513
|
## `sanity-run functions env add NAME KEY VALUE`
|
|
514
514
|
|
|
@@ -539,7 +539,7 @@ EXAMPLES
|
|
|
539
539
|
$ sanity-run functions env add MyFunction API_URL https://api.example.com/
|
|
540
540
|
```
|
|
541
541
|
|
|
542
|
-
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.
|
|
542
|
+
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/functions/env/add.ts)_
|
|
543
543
|
|
|
544
544
|
## `sanity-run functions env list NAME`
|
|
545
545
|
|
|
@@ -567,7 +567,7 @@ EXAMPLES
|
|
|
567
567
|
$ sanity-run functions env list MyFunction
|
|
568
568
|
```
|
|
569
569
|
|
|
570
|
-
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.
|
|
570
|
+
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/functions/env/list.ts)_
|
|
571
571
|
|
|
572
572
|
## `sanity-run functions env remove NAME KEY`
|
|
573
573
|
|
|
@@ -597,7 +597,7 @@ EXAMPLES
|
|
|
597
597
|
$ sanity-run functions env remove MyFunction API_URL
|
|
598
598
|
```
|
|
599
599
|
|
|
600
|
-
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.
|
|
600
|
+
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/functions/env/remove.ts)_
|
|
601
601
|
|
|
602
602
|
## `sanity-run functions logs [NAME]`
|
|
603
603
|
|
|
@@ -639,7 +639,7 @@ EXAMPLES
|
|
|
639
639
|
$ sanity-run functions logs <name> --delete
|
|
640
640
|
```
|
|
641
641
|
|
|
642
|
-
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.
|
|
642
|
+
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/functions/logs.ts)_
|
|
643
643
|
|
|
644
644
|
## `sanity-run functions test [NAME]`
|
|
645
645
|
|
|
@@ -697,7 +697,7 @@ EXAMPLES
|
|
|
697
697
|
$ sanity-run functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
|
|
698
698
|
```
|
|
699
699
|
|
|
700
|
-
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.
|
|
700
|
+
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v14.8.2/src/commands/functions/test.ts)_
|
|
701
701
|
|
|
702
702
|
## `sanity-run help [COMMAND]`
|
|
703
703
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BlueprintResource } from '@sanity/blueprints';
|
|
2
2
|
import AdmZip from 'adm-zip';
|
|
3
3
|
import type { Logger } from '../../utils/logger.js';
|
|
4
4
|
import type { AuthParams, InstallerType } from '../../utils/types.js';
|
|
5
5
|
export declare const ASSET_CHECK_URL: string;
|
|
6
6
|
export declare const ASSET_STASH_URL: string;
|
|
7
7
|
export declare function stashAsset({ resource, auth, logger, installer, }: {
|
|
8
|
-
resource:
|
|
8
|
+
resource: BlueprintResource;
|
|
9
9
|
auth: AuthParams;
|
|
10
10
|
logger: Logger;
|
|
11
11
|
installer?: InstallerType;
|
|
@@ -66,7 +66,7 @@ export async function stashAsset({ resource, auth, logger, installer, }) {
|
|
|
66
66
|
return { success: false, error: err instanceof Error ? err.message : `${err}` };
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
async function prepareStudioAsset({ resource }) {
|
|
69
|
+
async function prepareStudioAsset({ resource, }) {
|
|
70
70
|
if (!('src' in resource) || typeof resource.src !== 'string') {
|
|
71
71
|
return {
|
|
72
72
|
success: false,
|
|
@@ -15,6 +15,12 @@ export const handler = documentEventHandler(async ({ context, event }) => {
|
|
|
15
15
|
const time = new Date().toLocaleTimeString()
|
|
16
16
|
console.log(\`👋 Your Sanity Function was called at \${time}\`)
|
|
17
17
|
})`;
|
|
18
|
+
const DEFAULT_SCHEDULED_HELPER_FUNCTION_TEMPLATE = /*ts*/ `import { scheduledEventHandler } from '@sanity/functions'
|
|
19
|
+
|
|
20
|
+
export const handler = scheduledEventHandler(async ({ context }) => {
|
|
21
|
+
const time = new Date().toLocaleTimeString()
|
|
22
|
+
console.log(\`Your scheduled Sanity Function was called at \${time}\`)
|
|
23
|
+
})`;
|
|
18
24
|
/**
|
|
19
25
|
* Creates a new function resource file and adds it to the blueprint
|
|
20
26
|
*/
|
|
@@ -39,9 +45,24 @@ export async function createFunctionResource(options, logger) {
|
|
|
39
45
|
mkdirSync(functionDir, { recursive: true });
|
|
40
46
|
if (!['ts', 'js'].includes(lang))
|
|
41
47
|
throw Error(`Unsupported language: ${lang}`);
|
|
48
|
+
// type looks like 'document-publish', 'media-library-asset-delete' or 'scheduled-function'
|
|
49
|
+
// and we are guaranteed to have the same leading words (typeName below) for all provided type strings (via guards in the call site for this method).
|
|
50
|
+
// TODO: this substring convention is brittle - consider mapping EVENT_* constants to typeName values explicitly instead of relying on string splitting.
|
|
51
|
+
const typeName = type[0].substring(0, type[0].lastIndexOf('-'));
|
|
42
52
|
// Create index.<lang> with default template
|
|
43
53
|
const indexPath = join(functionDir, `index.${lang}`);
|
|
44
|
-
|
|
54
|
+
let template = DEFAULT_FUNCTION_TEMPLATE;
|
|
55
|
+
if (addHelpers) {
|
|
56
|
+
switch (typeName) {
|
|
57
|
+
case 'scheduled':
|
|
58
|
+
template = DEFAULT_SCHEDULED_HELPER_FUNCTION_TEMPLATE;
|
|
59
|
+
break;
|
|
60
|
+
default:
|
|
61
|
+
template = DEFAULT_HELPER_FUNCTION_TEMPLATE;
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
writeFileSync(indexPath, template);
|
|
45
66
|
if (addHelpers && blueprintFilePath) {
|
|
46
67
|
try {
|
|
47
68
|
await writeOrUpdateNodeDependency(blueprintFilePath, '@sanity/functions', logger);
|
|
@@ -56,9 +77,6 @@ export async function createFunctionResource(options, logger) {
|
|
|
56
77
|
throw new Error(`Failed to install dependencies using \`${installCommand}\``);
|
|
57
78
|
}
|
|
58
79
|
}
|
|
59
|
-
// type looks like 'document-publish', 'media-library-asset-delete' or 'scheduled-function'
|
|
60
|
-
// and we are guaranteed to have the same leading words (typeName below) for all provided type strings (via guards in the call site for this method).
|
|
61
|
-
const typeName = type[0].substring(0, type[0].lastIndexOf('-'));
|
|
62
80
|
const eventsOn = type.map((t) => t.substring(t.lastIndexOf('-') + 1));
|
|
63
81
|
// Create resource definition
|
|
64
82
|
let resourceJson;
|
|
@@ -84,7 +102,17 @@ export async function createFunctionResource(options, logger) {
|
|
|
84
102
|
},
|
|
85
103
|
};
|
|
86
104
|
break;
|
|
87
|
-
|
|
105
|
+
case 'scheduled':
|
|
106
|
+
resourceJson = {
|
|
107
|
+
name,
|
|
108
|
+
src: `functions/${name}`,
|
|
109
|
+
type: 'sanity.function.cron',
|
|
110
|
+
event: {
|
|
111
|
+
expression: '0 0 * * *',
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
break;
|
|
115
|
+
// TODO: add sync tag invalidate funx
|
|
88
116
|
}
|
|
89
117
|
if (!resourceJson) {
|
|
90
118
|
throw new Error('Could not create function resource based on selections');
|
|
@@ -152,9 +152,9 @@ async function preDeploy(resource, options) {
|
|
|
152
152
|
clearTimeout(assetTimeoutTimer);
|
|
153
153
|
}
|
|
154
154
|
if (result.success && result.assetId) {
|
|
155
|
-
resource
|
|
156
|
-
fnSpinner.succeed(`${
|
|
157
|
-
log(` Source: ${
|
|
155
|
+
const resourceWithAsset = { ...resource, src: result.assetId };
|
|
156
|
+
fnSpinner.succeed(`${resourceWithAsset.name} ${niceId(result.assetId)}`);
|
|
157
|
+
log(` Source: ${resourceWithAsset.src}`);
|
|
158
158
|
if (result.hash) {
|
|
159
159
|
if (result.hash.length > 24) {
|
|
160
160
|
log.verbose(` Hash: ${result.hash.slice(0, 8)}...${result.hash.slice(-12)}`);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BlueprintResource } from '@sanity/blueprints';
|
|
2
|
+
import type { Blueprint } from '@sanity/blueprints-parser';
|
|
2
3
|
import type { DeploymentPlan } from '../../actions/blueprints/stacks.js';
|
|
3
4
|
import { type BlueprintResourceRecord, type Stack, type StackSummary } from '../types.js';
|
|
4
5
|
export declare function formatTitle(title: string, name: string): string;
|
|
5
6
|
export declare function formatDeployedResourceTree(resources: BlueprintResourceRecord[] | undefined, verbose?: boolean): string;
|
|
6
|
-
export declare function formatResourceTree(resources:
|
|
7
|
+
export declare function formatResourceTree(resources: BlueprintResource[] | undefined, verbose?: boolean): string;
|
|
7
8
|
export declare function formatStackInfo(stack: Stack | StackSummary | Blueprint, isCurrentStack?: boolean): string;
|
|
8
9
|
export declare function formatStacksListing(stacks: StackSummary[], currentStackId?: string): string;
|
|
9
10
|
export declare function hasActionableChanges(deploymentPlan: DeploymentPlan): boolean;
|
|
@@ -62,10 +62,11 @@ const categoryByLabel = Object.values(RESOURCE_CATEGORIES).reduce((acc, curr) =>
|
|
|
62
62
|
}, {});
|
|
63
63
|
function resourceName(res, displayNameAttribute) {
|
|
64
64
|
const nameParts = [styleText(['bold', 'green'], res.name)];
|
|
65
|
+
const resAsAny = res;
|
|
65
66
|
const displayName = displayNameAttribute &&
|
|
66
67
|
displayNameAttribute in res &&
|
|
67
|
-
typeof
|
|
68
|
-
|
|
68
|
+
typeof resAsAny[displayNameAttribute] === 'string' &&
|
|
69
|
+
resAsAny[displayNameAttribute];
|
|
69
70
|
if (displayName && displayName !== res.name)
|
|
70
71
|
nameParts.push(styleText('green', `"${displayName}"`));
|
|
71
72
|
return nameParts.join(' ');
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { BlueprintCorsOriginResource, BlueprintDatasetResource, BlueprintDocumentWebhookResource, BlueprintRobotResource, BlueprintRoleResource } from '@sanity/blueprints';
|
|
2
|
-
import type { Resource } from '@sanity/blueprints-parser';
|
|
1
|
+
import type { BlueprintCorsOriginResource, BlueprintDatasetResource, BlueprintDocumentWebhookResource, BlueprintResource, BlueprintRobotResource, BlueprintRoleResource } from '@sanity/blueprints';
|
|
3
2
|
import type { TreeInput } from 'array-treeify';
|
|
4
|
-
export declare function arrayifyFunction(fn:
|
|
3
|
+
export declare function arrayifyFunction(fn: BlueprintResource): TreeInput;
|
|
5
4
|
export declare function arrayifyCors(resource: BlueprintCorsOriginResource): TreeInput;
|
|
6
5
|
export declare function arrayifyRobot(resource: BlueprintRobotResource): TreeInput;
|
|
7
6
|
export declare function arrayifyRole(resource: BlueprintRoleResource): TreeInput;
|
|
@@ -33,11 +33,11 @@ function arrayifyEvent(event) {
|
|
|
33
33
|
}
|
|
34
34
|
export function arrayifyFunction(fn) {
|
|
35
35
|
const details = [formatLabeledValue('type', fn.type)];
|
|
36
|
-
if (fn.memory)
|
|
36
|
+
if ('memory' in fn && fn.memory)
|
|
37
37
|
details.push(formatLabeledValue('memory', fn.memory));
|
|
38
|
-
if (fn.timeout)
|
|
38
|
+
if ('timeout' in fn && fn.timeout)
|
|
39
39
|
details.push(formatLabeledValue('timeout', fn.timeout));
|
|
40
|
-
if (fn.event) {
|
|
40
|
+
if ('event' in fn && fn.event) {
|
|
41
41
|
const eventDetails = arrayifyEvent(fn.event);
|
|
42
42
|
if (eventDetails) {
|
|
43
43
|
details.push(formatLabel('event'));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Blueprint } from '@sanity/blueprints
|
|
2
|
-
import type
|
|
1
|
+
import type { Blueprint } from '@sanity/blueprints';
|
|
2
|
+
import { type DeployedResource, type FunctionResource, type Stack } from './types.js';
|
|
3
3
|
export declare function getFunctionNames(resources: Array<{
|
|
4
4
|
type?: string;
|
|
5
5
|
name?: string;
|
|
6
6
|
}> | undefined): string[];
|
|
7
|
-
export declare function findFunctionInBlueprint(blueprint: Blueprint, name: string): FunctionResource;
|
|
7
|
+
export declare function findFunctionInBlueprint(blueprint: Pick<Blueprint, 'resources'>, name: string): FunctionResource;
|
|
8
8
|
export declare function findFunctionInStack(stack: Stack, name: string): DeployedResource;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SANITY_FUNCTION_PREFIX } from '../constants.js';
|
|
2
|
+
import { isLocalFunctionResource, } from './types.js';
|
|
2
3
|
export function getFunctionNames(resources) {
|
|
3
4
|
return (resources
|
|
4
5
|
?.filter((r) => r?.type?.startsWith(SANITY_FUNCTION_PREFIX))
|
|
@@ -6,13 +7,13 @@ export function getFunctionNames(resources) {
|
|
|
6
7
|
.filter((name) => typeof name === 'string') ?? []);
|
|
7
8
|
}
|
|
8
9
|
export function findFunctionInBlueprint(blueprint, name) {
|
|
9
|
-
const func = blueprint?.resources?.find((r) => r
|
|
10
|
+
const func = blueprint?.resources?.filter(isLocalFunctionResource).find((r) => r.name === name);
|
|
10
11
|
if (!func)
|
|
11
12
|
throw Error(`Unable to find function ${name}`);
|
|
12
13
|
return func;
|
|
13
14
|
}
|
|
14
15
|
export function findFunctionInStack(stack, name) {
|
|
15
|
-
const func = stack?.resources?.find((r) => r
|
|
16
|
+
const func = stack?.resources?.filter(isLocalFunctionResource).find((r) => r.name === name);
|
|
16
17
|
if (!func)
|
|
17
18
|
throw Error(`Unable to find function: "${name}"`);
|
|
18
19
|
if (!isDeployedResource(func))
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type BlueprintResource } from '@sanity/blueprints';
|
|
2
2
|
import type { BlueprintParserError } from '../types.js';
|
|
3
3
|
export * as validate from './resource.js';
|
|
4
|
-
export declare function validateResources(resources:
|
|
4
|
+
export declare function validateResources(resources: BlueprintResource[]): BlueprintParserError[];
|
package/oclif.manifest.json
CHANGED