@sanity/runtime-cli 13.1.0 → 13.2.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 +18 -18
- package/dist/actions/blueprints/blueprint.d.ts +6 -3
- package/dist/actions/blueprints/blueprint.js +16 -7
- package/dist/actions/functions/dev.d.ts +1 -1
- package/dist/actions/functions/dev.js +2 -2
- package/dist/baseCommands.d.ts +4 -0
- package/dist/baseCommands.js +8 -0
- package/dist/commands/blueprints/add.js +1 -0
- package/dist/commands/blueprints/config.js +1 -0
- package/dist/commands/blueprints/deploy.js +1 -0
- package/dist/commands/blueprints/destroy.js +1 -0
- package/dist/commands/blueprints/doctor.js +1 -0
- package/dist/commands/blueprints/info.js +1 -0
- package/dist/commands/blueprints/init.js +1 -0
- package/dist/commands/blueprints/logs.js +1 -0
- package/dist/commands/blueprints/plan.js +1 -0
- package/dist/commands/blueprints/stacks.js +1 -0
- package/dist/commands/functions/add.js +1 -0
- package/dist/commands/functions/dev.js +1 -0
- package/dist/commands/functions/env/add.js +1 -0
- package/dist/commands/functions/env/list.js +1 -0
- package/dist/commands/functions/env/remove.js +1 -0
- package/dist/commands/functions/logs.js +1 -0
- package/dist/commands/functions/test.js +1 -0
- package/dist/cores/blueprints/doctor.js +3 -2
- package/dist/cores/blueprints/init.js +3 -2
- package/dist/cores/functions/dev.js +1 -1
- package/dist/cores/functions/logs.js +6 -1
- package/dist/cores/index.d.ts +4 -2
- package/dist/cores/index.js +4 -2
- package/dist/server/app.d.ts +1 -1
- package/dist/server/app.js +6 -4
- package/dist/server/handlers/invoke.d.ts +1 -1
- package/dist/server/handlers/invoke.js +2 -2
- package/dist/server/static/api.d.ts +41 -0
- package/dist/server/static/api.js +29 -6
- package/dist/server/static/components/filters.js +62 -56
- package/dist/server/static/components/function-list.js +1 -1
- package/dist/server/static/components/payload-panel.js +33 -4
- package/dist/server/static/components/run-panel.js +12 -4
- package/dist/server/static/vendor/vendor.bundle.js +1 -1
- package/dist/utils/functions/resource-to-arc.js +11 -2
- package/dist/utils/validate/index.d.ts +3 -0
- package/dist/utils/validate/index.js +35 -0
- package/oclif.manifest.json +120 -1
- package/package.json +2 -2
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/13.
|
|
23
|
+
@sanity/runtime-cli/13.2.0 linux-x64 node-v24.13.0
|
|
24
24
|
$ sanity-run --help [COMMAND]
|
|
25
25
|
USAGE
|
|
26
26
|
$ sanity-run COMMAND
|
|
@@ -98,7 +98,7 @@ EXAMPLES
|
|
|
98
98
|
$ sanity-run blueprints add function --name my-function --fn-type document-create --fn-type document-update --lang js
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v13.
|
|
101
|
+
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/src/commands/blueprints/add.ts)_
|
|
102
102
|
|
|
103
103
|
## `sanity-run blueprints config`
|
|
104
104
|
|
|
@@ -133,7 +133,7 @@ EXAMPLES
|
|
|
133
133
|
$ sanity-run blueprints config --edit --project-id <projectId> --stack-id <stackId>
|
|
134
134
|
```
|
|
135
135
|
|
|
136
|
-
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v13.
|
|
136
|
+
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/src/commands/blueprints/config.ts)_
|
|
137
137
|
|
|
138
138
|
## `sanity-run blueprints deploy`
|
|
139
139
|
|
|
@@ -163,7 +163,7 @@ EXAMPLES
|
|
|
163
163
|
$ sanity-run blueprints deploy --no-wait
|
|
164
164
|
```
|
|
165
165
|
|
|
166
|
-
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v13.
|
|
166
|
+
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/src/commands/blueprints/deploy.ts)_
|
|
167
167
|
|
|
168
168
|
## `sanity-run blueprints destroy`
|
|
169
169
|
|
|
@@ -195,7 +195,7 @@ EXAMPLES
|
|
|
195
195
|
$ sanity-run blueprints destroy --stack-id <stackId> --project-id <projectId> --force --no-wait
|
|
196
196
|
```
|
|
197
197
|
|
|
198
|
-
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v13.
|
|
198
|
+
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/src/commands/blueprints/destroy.ts)_
|
|
199
199
|
|
|
200
200
|
## `sanity-run blueprints doctor`
|
|
201
201
|
|
|
@@ -221,7 +221,7 @@ DESCRIPTION
|
|
|
221
221
|
issues.
|
|
222
222
|
```
|
|
223
223
|
|
|
224
|
-
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v13.
|
|
224
|
+
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/src/commands/blueprints/doctor.ts)_
|
|
225
225
|
|
|
226
226
|
## `sanity-run blueprints info`
|
|
227
227
|
|
|
@@ -251,7 +251,7 @@ EXAMPLES
|
|
|
251
251
|
$ sanity-run blueprints info --id <stackId>
|
|
252
252
|
```
|
|
253
253
|
|
|
254
|
-
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v13.
|
|
254
|
+
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/src/commands/blueprints/info.ts)_
|
|
255
255
|
|
|
256
256
|
## `sanity-run blueprints init [DIR]`
|
|
257
257
|
|
|
@@ -301,7 +301,7 @@ EXAMPLES
|
|
|
301
301
|
$ sanity-run blueprints init --blueprint-type <json|js|ts> --stack-name <stackName>
|
|
302
302
|
```
|
|
303
303
|
|
|
304
|
-
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v13.
|
|
304
|
+
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/src/commands/blueprints/init.ts)_
|
|
305
305
|
|
|
306
306
|
## `sanity-run blueprints logs`
|
|
307
307
|
|
|
@@ -329,7 +329,7 @@ EXAMPLES
|
|
|
329
329
|
$ sanity-run blueprints logs --watch
|
|
330
330
|
```
|
|
331
331
|
|
|
332
|
-
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v13.
|
|
332
|
+
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/src/commands/blueprints/logs.ts)_
|
|
333
333
|
|
|
334
334
|
## `sanity-run blueprints plan`
|
|
335
335
|
|
|
@@ -352,7 +352,7 @@ EXAMPLES
|
|
|
352
352
|
$ sanity-run blueprints plan
|
|
353
353
|
```
|
|
354
354
|
|
|
355
|
-
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v13.
|
|
355
|
+
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/src/commands/blueprints/plan.ts)_
|
|
356
356
|
|
|
357
357
|
## `sanity-run blueprints stacks`
|
|
358
358
|
|
|
@@ -381,7 +381,7 @@ EXAMPLES
|
|
|
381
381
|
$ sanity-run blueprints stacks --organization-id <organizationId>
|
|
382
382
|
```
|
|
383
383
|
|
|
384
|
-
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v13.
|
|
384
|
+
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/src/commands/blueprints/stacks.ts)_
|
|
385
385
|
|
|
386
386
|
## `sanity-run functions add`
|
|
387
387
|
|
|
@@ -430,7 +430,7 @@ EXAMPLES
|
|
|
430
430
|
$ sanity-run functions add --name my-function --type document-create --type document-update --lang js
|
|
431
431
|
```
|
|
432
432
|
|
|
433
|
-
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v13.
|
|
433
|
+
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/src/commands/functions/add.ts)_
|
|
434
434
|
|
|
435
435
|
## `sanity-run functions dev`
|
|
436
436
|
|
|
@@ -464,7 +464,7 @@ EXAMPLES
|
|
|
464
464
|
$ sanity-run functions dev --timeout 60
|
|
465
465
|
```
|
|
466
466
|
|
|
467
|
-
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v13.
|
|
467
|
+
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/src/commands/functions/dev.ts)_
|
|
468
468
|
|
|
469
469
|
## `sanity-run functions env add NAME KEY VALUE`
|
|
470
470
|
|
|
@@ -491,7 +491,7 @@ EXAMPLES
|
|
|
491
491
|
$ sanity-run functions env add MyFunction API_URL https://api.example.com/
|
|
492
492
|
```
|
|
493
493
|
|
|
494
|
-
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v13.
|
|
494
|
+
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/src/commands/functions/env/add.ts)_
|
|
495
495
|
|
|
496
496
|
## `sanity-run functions env list NAME`
|
|
497
497
|
|
|
@@ -515,7 +515,7 @@ EXAMPLES
|
|
|
515
515
|
$ sanity-run functions env list MyFunction
|
|
516
516
|
```
|
|
517
517
|
|
|
518
|
-
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v13.
|
|
518
|
+
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/src/commands/functions/env/list.ts)_
|
|
519
519
|
|
|
520
520
|
## `sanity-run functions env remove NAME KEY`
|
|
521
521
|
|
|
@@ -541,7 +541,7 @@ EXAMPLES
|
|
|
541
541
|
$ sanity-run functions env remove MyFunction API_URL
|
|
542
542
|
```
|
|
543
543
|
|
|
544
|
-
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v13.
|
|
544
|
+
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/src/commands/functions/env/remove.ts)_
|
|
545
545
|
|
|
546
546
|
## `sanity-run functions logs [NAME]`
|
|
547
547
|
|
|
@@ -580,7 +580,7 @@ EXAMPLES
|
|
|
580
580
|
$ sanity-run functions logs <name> --delete
|
|
581
581
|
```
|
|
582
582
|
|
|
583
|
-
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v13.
|
|
583
|
+
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/src/commands/functions/logs.ts)_
|
|
584
584
|
|
|
585
585
|
## `sanity-run functions test [NAME]`
|
|
586
586
|
|
|
@@ -634,7 +634,7 @@ EXAMPLES
|
|
|
634
634
|
$ sanity-run functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
|
|
635
635
|
```
|
|
636
636
|
|
|
637
|
-
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v13.
|
|
637
|
+
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/src/commands/functions/test.ts)_
|
|
638
638
|
|
|
639
639
|
## `sanity-run help [COMMAND]`
|
|
640
640
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { BlueprintResource } from '@sanity/blueprints';
|
|
2
2
|
import { type Blueprint } from '@sanity/blueprints-parser';
|
|
3
3
|
import type { Logger } from '../../utils/logger.js';
|
|
4
|
-
import type
|
|
5
|
-
import { type ScopeType } from '../../utils/types.js';
|
|
4
|
+
import { type BlueprintParserError, type ScopeType } from '../../utils/types.js';
|
|
6
5
|
import { type LocatedBlueprintsConfig } from './config.js';
|
|
7
6
|
declare const SUPPORTED_FILE_EXTENSIONS: readonly [".json", ".js", ".mjs", ".ts"];
|
|
8
7
|
type BlueprintFileExtension = (typeof SUPPORTED_FILE_EXTENSIONS)[number];
|
|
@@ -45,10 +44,14 @@ export interface ReadBlueprintResult {
|
|
|
45
44
|
}
|
|
46
45
|
/**
|
|
47
46
|
* Reads the blueprint file from disk and parses it. Greedily looks for Blueprint config
|
|
47
|
+
* @param logger The logger instance
|
|
48
|
+
* @param validate Validation options
|
|
48
49
|
* @param blueprintPath - The path of the blueprint file or directory- will search up the directory tree!
|
|
49
50
|
* @returns Known information about the Blueprint, config, and Stack
|
|
50
51
|
*/
|
|
51
|
-
export declare function readLocalBlueprint(logger: ReturnType<typeof Logger>,
|
|
52
|
+
export declare function readLocalBlueprint(logger: ReturnType<typeof Logger>, validate: {
|
|
53
|
+
resources: boolean;
|
|
54
|
+
}, blueprintPath?: string): Promise<ReadBlueprintResult>;
|
|
52
55
|
export declare function writeBlueprintToDisk({ blueprintFilePath, jsonContent, }: {
|
|
53
56
|
blueprintFilePath: string;
|
|
54
57
|
jsonContent?: Blueprint;
|
|
@@ -5,7 +5,8 @@ import { pathToFileURL } from 'node:url';
|
|
|
5
5
|
import blueprintParserValidator from '@sanity/blueprints-parser';
|
|
6
6
|
import { findUpSync } from 'find-up';
|
|
7
7
|
import { createJiti } from 'jiti';
|
|
8
|
-
import { isLocalFunctionResource } from '../../utils/types.js';
|
|
8
|
+
import { isLocalFunctionResource, } from '../../utils/types.js';
|
|
9
|
+
import { validateResources } from '../../utils/validate/index.js';
|
|
9
10
|
import { validateFunctionResource } from '../../utils/validate/resource.js';
|
|
10
11
|
import { backfillOrganizationId, backfillProjectBasedStackId, readConfigFile, } from './config.js';
|
|
11
12
|
const SUPPORTED_FILE_EXTENSIONS = ['.json', '.js', '.mjs', '.ts'];
|
|
@@ -65,10 +66,12 @@ export function findBlueprintFile(blueprintPath) {
|
|
|
65
66
|
}
|
|
66
67
|
/**
|
|
67
68
|
* Reads the blueprint file from disk and parses it. Greedily looks for Blueprint config
|
|
69
|
+
* @param logger The logger instance
|
|
70
|
+
* @param validate Validation options
|
|
68
71
|
* @param blueprintPath - The path of the blueprint file or directory- will search up the directory tree!
|
|
69
72
|
* @returns Known information about the Blueprint, config, and Stack
|
|
70
73
|
*/
|
|
71
|
-
export async function readLocalBlueprint(logger, blueprintPath) {
|
|
74
|
+
export async function readLocalBlueprint(logger, validate, blueprintPath) {
|
|
72
75
|
const blueprintFile = findBlueprintFile(blueprintPath);
|
|
73
76
|
if (!blueprintFile)
|
|
74
77
|
throw Error('Could not find Blueprint file! Use the `blueprints init` command.');
|
|
@@ -193,12 +196,18 @@ export async function readLocalBlueprint(logger, blueprintPath) {
|
|
|
193
196
|
const parserResult = blueprintParserValidator(rawBlueprint);
|
|
194
197
|
const parsedBlueprint = parserResult.result === 'valid' ? parserResult.blueprint : undefined;
|
|
195
198
|
const errors = parserResult.result !== 'valid' ? parserResult.errors : [];
|
|
196
|
-
//
|
|
199
|
+
// resource validation
|
|
197
200
|
if (parsedBlueprint?.resources) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
201
|
+
if (validate.resources) {
|
|
202
|
+
// validate function resources
|
|
203
|
+
errors.push(...validateResources(parsedBlueprint.resources));
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
// backwards compat: fallback to the previous validation if validation was not explicitly enabled
|
|
207
|
+
const functionResources = parsedBlueprint.resources.filter(isLocalFunctionResource);
|
|
208
|
+
const fnErrors = functionResources.map((r) => validateFunctionResource(r));
|
|
209
|
+
errors.push(...fnErrors.flat());
|
|
210
|
+
}
|
|
202
211
|
}
|
|
203
212
|
return {
|
|
204
213
|
fileInfo: { blueprintFilePath: foundFilePath, fileName, extension },
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Logger } from '../../utils/logger.js';
|
|
2
2
|
import type { InvokeExecutionOptions } from '../../utils/types.js';
|
|
3
|
-
export declare function dev(host: string, port: number, logger: ReturnType<typeof Logger>, executionOptions?: Partial<InvokeExecutionOptions>): Promise<void>;
|
|
3
|
+
export declare function dev(host: string, port: number, logger: ReturnType<typeof Logger>, validateResources: boolean, executionOptions?: Partial<InvokeExecutionOptions>): Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { app } from '../../server/app.js';
|
|
2
|
-
export async function dev(host, port, logger, executionOptions) {
|
|
3
|
-
app(host, Number(port), logger, executionOptions);
|
|
2
|
+
export async function dev(host, port, logger, validateResources, executionOptions) {
|
|
3
|
+
app(host, Number(port), logger, validateResources, executionOptions);
|
|
4
4
|
}
|
package/dist/baseCommands.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare const baseFlags: {
|
|
|
8
8
|
json: Interfaces.BooleanFlag<boolean>;
|
|
9
9
|
path: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
10
10
|
trace: Interfaces.BooleanFlag<boolean>;
|
|
11
|
+
'validate-resources': Interfaces.BooleanFlag<boolean>;
|
|
11
12
|
verbose: Interfaces.BooleanFlag<boolean>;
|
|
12
13
|
};
|
|
13
14
|
/**
|
|
@@ -27,6 +28,7 @@ export declare abstract class RuntimeCommand<T extends typeof Command> extends C
|
|
|
27
28
|
json: Interfaces.BooleanFlag<boolean>;
|
|
28
29
|
path: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
29
30
|
trace: Interfaces.BooleanFlag<boolean>;
|
|
31
|
+
'validate-resources': Interfaces.BooleanFlag<boolean>;
|
|
30
32
|
verbose: Interfaces.BooleanFlag<boolean>;
|
|
31
33
|
};
|
|
32
34
|
static enableJsonFlag: boolean;
|
|
@@ -52,6 +54,7 @@ export declare abstract class LocalBlueprintCommand<T extends typeof Command> ex
|
|
|
52
54
|
json: Interfaces.BooleanFlag<boolean>;
|
|
53
55
|
path: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
54
56
|
trace: Interfaces.BooleanFlag<boolean>;
|
|
57
|
+
'validate-resources': Interfaces.BooleanFlag<boolean>;
|
|
55
58
|
verbose: Interfaces.BooleanFlag<boolean>;
|
|
56
59
|
};
|
|
57
60
|
init(): Promise<void>;
|
|
@@ -75,6 +78,7 @@ export declare abstract class DeployedStackCommand<T extends typeof Command> ext
|
|
|
75
78
|
json: Interfaces.BooleanFlag<boolean>;
|
|
76
79
|
path: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
77
80
|
trace: Interfaces.BooleanFlag<boolean>;
|
|
81
|
+
'validate-resources': Interfaces.BooleanFlag<boolean>;
|
|
78
82
|
verbose: Interfaces.BooleanFlag<boolean>;
|
|
79
83
|
};
|
|
80
84
|
init(): Promise<void>;
|
package/dist/baseCommands.js
CHANGED
|
@@ -18,6 +18,12 @@ export const baseFlags = {
|
|
|
18
18
|
default: false,
|
|
19
19
|
hidden,
|
|
20
20
|
}),
|
|
21
|
+
'validate-resources': OclifFlags.boolean({
|
|
22
|
+
description: 'Validate resources',
|
|
23
|
+
default: false,
|
|
24
|
+
allowNo: true,
|
|
25
|
+
hidden, // TODO: reveal this once support is added in main CLI
|
|
26
|
+
}),
|
|
21
27
|
verbose: OclifFlags.boolean({
|
|
22
28
|
description: 'Verbose output',
|
|
23
29
|
default: false,
|
|
@@ -111,6 +117,7 @@ export class LocalBlueprintCommand extends RuntimeCommand {
|
|
|
111
117
|
const result = await initBlueprintConfig({
|
|
112
118
|
bin: this.config.bin,
|
|
113
119
|
log: Logger(this.log.bind(this), this.flags),
|
|
120
|
+
validateResources: this.flags['validate-resources'],
|
|
114
121
|
});
|
|
115
122
|
if (!result.ok) {
|
|
116
123
|
this.error(result.error);
|
|
@@ -148,6 +155,7 @@ export class DeployedStackCommand extends LocalBlueprintCommand {
|
|
|
148
155
|
log: Logger(this.log.bind(this), this.flags),
|
|
149
156
|
token: this.sanityToken,
|
|
150
157
|
validateToken: false,
|
|
158
|
+
validateResources: this.flags['validate-resources'],
|
|
151
159
|
});
|
|
152
160
|
if (!result.ok) {
|
|
153
161
|
this.error(result.error);
|
|
@@ -98,6 +98,7 @@ After adding a function, use 'functions dev' to test locally, then 'blueprints d
|
|
|
98
98
|
bin,
|
|
99
99
|
log: Logger(this.log.bind(this), this.flags),
|
|
100
100
|
blueprint,
|
|
101
|
+
validateResources: flags['validate-resources'],
|
|
101
102
|
flags: {
|
|
102
103
|
example: flags.example,
|
|
103
104
|
name: flags.name,
|
|
@@ -44,6 +44,7 @@ If you need to switch your Blueprint to a different Stack, use --edit --stack-id
|
|
|
44
44
|
log: Logger(this.log.bind(this), this.flags),
|
|
45
45
|
blueprint: this.blueprint,
|
|
46
46
|
token: this.sanityToken,
|
|
47
|
+
validateResources: this.flags['validate-resources'],
|
|
47
48
|
flags: this.flags,
|
|
48
49
|
});
|
|
49
50
|
if (!success)
|
|
@@ -29,6 +29,7 @@ Use --no-wait to queue the deployment and return immediately without waiting for
|
|
|
29
29
|
scopeId: this.scopeId,
|
|
30
30
|
deployedStack: this.deployedStack,
|
|
31
31
|
blueprint: this.blueprint,
|
|
32
|
+
validateResources: this.flags['validate-resources'],
|
|
32
33
|
flags: this.flags,
|
|
33
34
|
});
|
|
34
35
|
if (!success)
|
|
@@ -47,6 +47,7 @@ Use this to clean up test environments or decommission a Stack you no longer nee
|
|
|
47
47
|
log: Logger(this.log.bind(this), this.flags),
|
|
48
48
|
token: this.sanityToken,
|
|
49
49
|
blueprint: this.blueprint,
|
|
50
|
+
validateResources: this.flags['validate-resources'],
|
|
50
51
|
flags: this.flags,
|
|
51
52
|
});
|
|
52
53
|
if (!success)
|
|
@@ -25,6 +25,7 @@ Run this command when encountering errors with other Blueprint commands. Use --f
|
|
|
25
25
|
bin: this.config.bin,
|
|
26
26
|
log: Logger(this.log.bind(this), this.flags),
|
|
27
27
|
token,
|
|
28
|
+
validateResources: this.flags['validate-resources'],
|
|
28
29
|
flags: this.flags,
|
|
29
30
|
});
|
|
30
31
|
const { success, error } = result;
|
|
@@ -25,6 +25,7 @@ Run 'blueprints stacks' to see all available Stacks in your project or organizat
|
|
|
25
25
|
auth: this.auth,
|
|
26
26
|
stackId: this.stackId,
|
|
27
27
|
deployedStack: this.deployedStack,
|
|
28
|
+
validateResources: this.flags['validate-resources'],
|
|
28
29
|
flags: this.flags,
|
|
29
30
|
});
|
|
30
31
|
if (!success)
|
|
@@ -27,6 +27,7 @@ If you're not seeing expected logs, verify your Stack is deployed with 'blueprin
|
|
|
27
27
|
auth: this.auth,
|
|
28
28
|
stackId: this.stackId,
|
|
29
29
|
deployedStack: this.deployedStack,
|
|
30
|
+
validateResources: this.flags['validate-resources'],
|
|
30
31
|
flags: this.flags,
|
|
31
32
|
});
|
|
32
33
|
if (streaming)
|
|
@@ -13,6 +13,7 @@ Run 'blueprints plan' after making local changes to your Blueprint manifest to v
|
|
|
13
13
|
log: Logger(this.log.bind(this), this.flags),
|
|
14
14
|
token: this.sanityToken,
|
|
15
15
|
blueprint: this.blueprint,
|
|
16
|
+
validateResources: this.flags['validate-resources'],
|
|
16
17
|
flags: this.flags,
|
|
17
18
|
});
|
|
18
19
|
if (!success)
|
|
@@ -31,6 +31,7 @@ Use this to discover existing Stacks you can scope a local Blueprint to (using '
|
|
|
31
31
|
log: Logger(this.log.bind(this), this.flags),
|
|
32
32
|
token: this.sanityToken,
|
|
33
33
|
blueprint: this.blueprint,
|
|
34
|
+
validateResources: this.flags['validate-resources'],
|
|
34
35
|
flags: this.flags,
|
|
35
36
|
});
|
|
36
37
|
if (!success)
|
|
@@ -71,6 +71,7 @@ After adding, use 'functions dev' to test locally, then 'blueprints deploy' to p
|
|
|
71
71
|
bin: this.config.bin,
|
|
72
72
|
log: Logger(this.log.bind(this), this.flags),
|
|
73
73
|
blueprint: this.blueprint,
|
|
74
|
+
validateResources: this.flags['validate-resources'],
|
|
74
75
|
flags: this.flags,
|
|
75
76
|
});
|
|
76
77
|
if (!success)
|
|
@@ -37,6 +37,7 @@ To invoke a function with the CLI, use 'functions test'.`;
|
|
|
37
37
|
const { success, error, streaming } = await functionDevCore({
|
|
38
38
|
bin: this.config.bin,
|
|
39
39
|
log: Logger(this.log.bind(this), this.flags),
|
|
40
|
+
validateResources: this.flags['validate-resources'],
|
|
40
41
|
flags,
|
|
41
42
|
});
|
|
42
43
|
if (!success)
|
|
@@ -27,6 +27,7 @@ Environment variables are useful for API keys, configuration values, and other s
|
|
|
27
27
|
scopeId: this.scopeId,
|
|
28
28
|
token: this.sanityToken,
|
|
29
29
|
stackId: this.stackId,
|
|
30
|
+
validateResources: this.flags['validate-resources'],
|
|
30
31
|
});
|
|
31
32
|
if (!success)
|
|
32
33
|
this.error(error);
|
|
@@ -23,6 +23,7 @@ Use 'functions env add' to set variables or 'functions env remove' to delete the
|
|
|
23
23
|
scopeId: this.scopeId,
|
|
24
24
|
token: this.sanityToken,
|
|
25
25
|
stackId: this.stackId,
|
|
26
|
+
validateResources: this.flags['validate-resources'],
|
|
26
27
|
});
|
|
27
28
|
if (!success)
|
|
28
29
|
this.error(error);
|
|
@@ -66,6 +66,7 @@ Use --watch (-w) to stream logs in real-time. Use --delete to clear all logs for
|
|
|
66
66
|
token: this.sanityToken,
|
|
67
67
|
stackId: this.stackId,
|
|
68
68
|
helpText: LogsCommand.getHelpText(this.config.bin, 'functions logs'),
|
|
69
|
+
validateResources: this.flags['validate-resources'],
|
|
69
70
|
});
|
|
70
71
|
if (!success)
|
|
71
72
|
this.error(error);
|
|
@@ -176,6 +176,7 @@ Provide test data via --data (inline JSON), --file (JSON file), or --document-id
|
|
|
176
176
|
flags: this.flags,
|
|
177
177
|
blueprint: this.blueprint,
|
|
178
178
|
helpText: TestCommand.getHelpText(this.config.bin, 'functions test'),
|
|
179
|
+
validateResources: this.flags['validate-resources'],
|
|
179
180
|
});
|
|
180
181
|
if (!success)
|
|
181
182
|
this.error(error);
|
|
@@ -19,7 +19,7 @@ const diagLookup = {
|
|
|
19
19
|
userHasAccess: 'User has access to deployed "Stack"',
|
|
20
20
|
};
|
|
21
21
|
export async function blueprintDoctorCore(options) {
|
|
22
|
-
const { bin, log, token, flags: { verbose: v, path: p, fix }, } = options;
|
|
22
|
+
const { bin, log, token, validateResources, flags: { verbose: v, path: p, fix }, } = options;
|
|
23
23
|
const yikes = (s) => {
|
|
24
24
|
log.error(chalk.bgRedBright.whiteBright.bold(` ${s} `));
|
|
25
25
|
};
|
|
@@ -74,7 +74,7 @@ export async function blueprintDoctorCore(options) {
|
|
|
74
74
|
}
|
|
75
75
|
let blueprint;
|
|
76
76
|
try {
|
|
77
|
-
blueprint = await readLocalBlueprint(log, path);
|
|
77
|
+
blueprint = await readLocalBlueprint(log, { resources: options.validateResources || false }, path);
|
|
78
78
|
if (blueprint.errors.length === 0) {
|
|
79
79
|
log.verbose(`Blueprint has no errors`);
|
|
80
80
|
diagnostics.blueprintValid = true;
|
|
@@ -206,6 +206,7 @@ export async function blueprintDoctorCore(options) {
|
|
|
206
206
|
log,
|
|
207
207
|
token: tokenOrError.value,
|
|
208
208
|
blueprint,
|
|
209
|
+
validateResources,
|
|
209
210
|
flags: { edit: true, verbose: v },
|
|
210
211
|
});
|
|
211
212
|
}
|
|
@@ -16,7 +16,7 @@ import { blueprintConfigCore } from './config.js';
|
|
|
16
16
|
const SCOPE_PROJECT = 'project';
|
|
17
17
|
const SCOPE_ORGANIZATION = 'organization';
|
|
18
18
|
export async function blueprintInitCore(options) {
|
|
19
|
-
const { bin = 'sanity', log, token, knownProjectId, args, flags } = options;
|
|
19
|
+
const { bin = 'sanity', log, token, knownProjectId, args, flags, validateResources } = options;
|
|
20
20
|
const { dir: flagDir, example: flagExample, 'blueprint-type': flagBlueprintType, 'project-id': flagProjectId, 'organization-id': flagOrganizationId, 'stack-id': flagStackId, 'stack-name': flagStackName, verbose: v = false, } = flags;
|
|
21
21
|
const { dir: argDir } = args;
|
|
22
22
|
const userProvidedDirName = argDir || flagDir;
|
|
@@ -55,12 +55,13 @@ export async function blueprintInitCore(options) {
|
|
|
55
55
|
if (!overwrite)
|
|
56
56
|
return { success: false, error: 'Initialization cancelled.' };
|
|
57
57
|
}
|
|
58
|
-
const existingBlueprint = await readLocalBlueprint(log, existingBlueprintFile.blueprintFilePath);
|
|
58
|
+
const existingBlueprint = await readLocalBlueprint(log, { resources: validateResources || false }, existingBlueprintFile.blueprintFilePath);
|
|
59
59
|
return blueprintConfigCore({
|
|
60
60
|
blueprint: existingBlueprint,
|
|
61
61
|
bin,
|
|
62
62
|
log,
|
|
63
63
|
token,
|
|
64
|
+
validateResources,
|
|
64
65
|
flags: {
|
|
65
66
|
edit: true,
|
|
66
67
|
'project-id': flagProjectId,
|
|
@@ -7,7 +7,7 @@ export async function functionDevCore(options) {
|
|
|
7
7
|
? { timeout }
|
|
8
8
|
: undefined;
|
|
9
9
|
try {
|
|
10
|
-
await dev(host, Number(port), log, executionOptions);
|
|
10
|
+
await dev(host, Number(port), log, options.validateResources || false, executionOptions);
|
|
11
11
|
log(`Server is running on http://${host}:${port}\n`);
|
|
12
12
|
return {
|
|
13
13
|
success: true,
|
|
@@ -105,7 +105,12 @@ function formatLog(time, level, message, utc) {
|
|
|
105
105
|
const [dateString, timeString] = utc
|
|
106
106
|
? date.toISOString().slice(0, 19).split('T')
|
|
107
107
|
: [date.toLocaleDateString(), date.toLocaleTimeString()];
|
|
108
|
-
return [
|
|
108
|
+
return [
|
|
109
|
+
chalk.bold(dateString),
|
|
110
|
+
chalk.bold.blue(timeString),
|
|
111
|
+
logLevel(level.toUpperCase()),
|
|
112
|
+
message,
|
|
113
|
+
].join(' ');
|
|
109
114
|
}
|
|
110
115
|
function logLevel(level) {
|
|
111
116
|
if (level === 'ERROR')
|
package/dist/cores/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export interface CoreConfig {
|
|
|
8
8
|
bin: string;
|
|
9
9
|
/** The log output function. */
|
|
10
10
|
log: ReturnType<typeof Logger>;
|
|
11
|
+
/** Enable resource validation during parsing */
|
|
12
|
+
validateResources?: boolean;
|
|
11
13
|
}
|
|
12
14
|
export interface BlueprintConfig extends CoreConfig {
|
|
13
15
|
token: string;
|
|
@@ -43,7 +45,7 @@ type InitBlueprintConfigParams = CoreConfig & ({
|
|
|
43
45
|
validateToken?: false;
|
|
44
46
|
token?: string;
|
|
45
47
|
});
|
|
46
|
-
export declare function initBlueprintConfig({ bin, log, token, validateToken, }: InitBlueprintConfigParams): Promise<Result<BlueprintConfig>>;
|
|
47
|
-
export declare function initDeployedBlueprintConfig(config: Partial<BlueprintConfig> & Pick<BlueprintConfig, 'bin' | 'log' | 'token'> & {
|
|
48
|
+
export declare function initBlueprintConfig({ bin, log, token, validateResources, validateToken, }: InitBlueprintConfigParams): Promise<Result<BlueprintConfig>>;
|
|
49
|
+
export declare function initDeployedBlueprintConfig(config: Partial<BlueprintConfig> & Pick<BlueprintConfig, 'bin' | 'log' | 'token' | 'validateResources'> & {
|
|
48
50
|
validateToken?: boolean;
|
|
49
51
|
}): Promise<Result<DeployedBlueprintConfig>>;
|
package/dist/cores/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { niceId } from '../utils/display/presenters.js';
|
|
|
5
5
|
import { validTokenOrErrorMessage } from '../utils/validated-token.js';
|
|
6
6
|
export * as blueprintsCores from './blueprints/index.js';
|
|
7
7
|
export * as functionsCores from './functions/index.js';
|
|
8
|
-
export async function initBlueprintConfig({ bin, log, token, validateToken = true, }) {
|
|
8
|
+
export async function initBlueprintConfig({ bin, log, token, validateResources = false, validateToken = true, }) {
|
|
9
9
|
let checkedToken = token;
|
|
10
10
|
if (!token || (token && validateToken)) {
|
|
11
11
|
const tokenCheck = await validTokenOrErrorMessage(log, token);
|
|
@@ -17,7 +17,7 @@ export async function initBlueprintConfig({ bin, log, token, validateToken = tru
|
|
|
17
17
|
if (!checkedToken) {
|
|
18
18
|
return { ok: false, error: 'A valid token is required but was not provided.' };
|
|
19
19
|
}
|
|
20
|
-
const blueprint = await readLocalBlueprint(log);
|
|
20
|
+
const blueprint = await readLocalBlueprint(log, { resources: validateResources });
|
|
21
21
|
if (blueprint.errors.length > 0) {
|
|
22
22
|
log(presentBlueprintParserErrors(blueprint.errors));
|
|
23
23
|
return { ok: false, error: 'Blueprint file contains errors.' };
|
|
@@ -29,6 +29,7 @@ export async function initBlueprintConfig({ bin, log, token, validateToken = tru
|
|
|
29
29
|
blueprint,
|
|
30
30
|
log,
|
|
31
31
|
token: checkedToken,
|
|
32
|
+
validateResources,
|
|
32
33
|
},
|
|
33
34
|
};
|
|
34
35
|
}
|
|
@@ -67,6 +68,7 @@ export async function initDeployedBlueprintConfig(config) {
|
|
|
67
68
|
stackId,
|
|
68
69
|
auth,
|
|
69
70
|
deployedStack: stackResponse.stack,
|
|
71
|
+
validateResources: config.validateResources,
|
|
70
72
|
},
|
|
71
73
|
};
|
|
72
74
|
}
|
package/dist/server/app.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Logger } from '../utils/logger.js';
|
|
2
2
|
import { type InvokeExecutionOptions } from '../utils/types.js';
|
|
3
|
-
declare const app: (host: string, port: number, logger: ReturnType<typeof Logger>, executionOptions?: Partial<InvokeExecutionOptions>) => void;
|
|
3
|
+
declare const app: (host: string, port: number, logger: ReturnType<typeof Logger>, validateResources: boolean, executionOptions?: Partial<InvokeExecutionOptions>) => void;
|
|
4
4
|
declare function parseDocumentUrl(url: string): {
|
|
5
5
|
projectId: string;
|
|
6
6
|
dataset: string;
|
package/dist/server/app.js
CHANGED
|
@@ -7,13 +7,15 @@ import config from '../config.js';
|
|
|
7
7
|
import { isRecord } from '../utils/is-record.js';
|
|
8
8
|
import { isEventType, isGroqContextOptions, } from '../utils/types.js';
|
|
9
9
|
import { handleInvokeRequest } from './handlers/invoke.js';
|
|
10
|
-
const app = (host, port, logger, executionOptions) => {
|
|
10
|
+
const app = (host, port, logger, validateResources, executionOptions) => {
|
|
11
11
|
const requestListener = async (req, res) => {
|
|
12
12
|
res.setHeader('Content-Type', 'application/json');
|
|
13
13
|
switch (true) {
|
|
14
14
|
case req.url === '/blueprint': {
|
|
15
15
|
try {
|
|
16
|
-
const { parsedBlueprint, projectId, organizationId } = await readLocalBlueprint(logger
|
|
16
|
+
const { parsedBlueprint, projectId, organizationId } = await readLocalBlueprint(logger, {
|
|
17
|
+
resources: validateResources,
|
|
18
|
+
});
|
|
17
19
|
res.setHeader('Content-Type', 'application/json');
|
|
18
20
|
res.writeHead(200);
|
|
19
21
|
res.end(JSON.stringify({ parsedBlueprint, projectId, organizationId })); // Use blueprint directly
|
|
@@ -42,7 +44,7 @@ const app = (host, port, logger, executionOptions) => {
|
|
|
42
44
|
delete context.clientOptions.token;
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
|
-
const result = await handleInvokeRequest(functionName, event, metadata, context, logger, executionOptions);
|
|
47
|
+
const result = await handleInvokeRequest(functionName, event, metadata, context, logger, validateResources, executionOptions);
|
|
46
48
|
// Add Server-Timing header
|
|
47
49
|
const timingHeaders = [];
|
|
48
50
|
for (const [key, value] of Object.entries(result.timings)) {
|
|
@@ -230,7 +232,7 @@ const app = (host, port, logger, executionOptions) => {
|
|
|
230
232
|
const wss = new WebSocketServer({ port: 8974 });
|
|
231
233
|
wss.on('connection', async function connection(ws) {
|
|
232
234
|
ws.on('error', console.error);
|
|
233
|
-
const { fileInfo } = await readLocalBlueprint(logger);
|
|
235
|
+
const { fileInfo } = await readLocalBlueprint(logger, { resources: validateResources });
|
|
234
236
|
watchFile(fileInfo.blueprintFilePath, { interval: 2007 }, async () => {
|
|
235
237
|
ws.send('reload-blueprint');
|
|
236
238
|
});
|