@sanity/runtime-cli 14.11.0 → 14.12.1
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 +45 -43
- package/dist/actions/blueprints/blueprint.d.ts +49 -16
- package/dist/actions/blueprints/blueprint.js +97 -139
- package/dist/actions/blueprints/resolve.d.ts +51 -0
- package/dist/actions/blueprints/resolve.js +52 -0
- package/dist/actions/blueprints/resources.js +35 -12
- package/dist/actions/functions/dev.d.ts +1 -2
- package/dist/actions/functions/dev.js +2 -2
- package/dist/baseCommands.d.ts +47 -30
- package/dist/baseCommands.js +187 -72
- package/dist/commands/blueprints/add.d.ts +3 -2
- package/dist/commands/blueprints/add.js +3 -2
- package/dist/commands/blueprints/config.d.ts +3 -2
- package/dist/commands/blueprints/config.js +3 -2
- package/dist/commands/blueprints/deploy.d.ts +3 -2
- package/dist/commands/blueprints/deploy.js +4 -3
- package/dist/commands/blueprints/destroy.d.ts +3 -2
- package/dist/commands/blueprints/destroy.js +3 -2
- package/dist/commands/blueprints/doctor.d.ts +0 -1
- package/dist/commands/blueprints/doctor.js +2 -3
- package/dist/commands/blueprints/info.d.ts +4 -2
- package/dist/commands/blueprints/info.js +6 -3
- package/dist/commands/blueprints/init.d.ts +0 -1
- package/dist/commands/blueprints/init.js +1 -2
- package/dist/commands/blueprints/logs.d.ts +3 -2
- package/dist/commands/blueprints/logs.js +4 -3
- package/dist/commands/blueprints/plan.d.ts +3 -2
- package/dist/commands/blueprints/plan.js +5 -3
- package/dist/commands/blueprints/promote.d.ts +3 -2
- package/dist/commands/blueprints/promote.js +3 -2
- package/dist/commands/blueprints/stacks.d.ts +3 -2
- package/dist/commands/blueprints/stacks.js +3 -2
- package/dist/commands/functions/add.d.ts +3 -2
- package/dist/commands/functions/add.js +4 -3
- package/dist/commands/functions/build.d.ts +3 -2
- package/dist/commands/functions/build.js +3 -2
- package/dist/commands/functions/dev.d.ts +3 -2
- package/dist/commands/functions/dev.js +3 -2
- package/dist/commands/functions/env/add.d.ts +3 -2
- package/dist/commands/functions/env/add.js +3 -2
- package/dist/commands/functions/env/list.d.ts +3 -2
- package/dist/commands/functions/env/list.js +3 -2
- package/dist/commands/functions/env/remove.d.ts +3 -2
- package/dist/commands/functions/env/remove.js +3 -2
- package/dist/commands/functions/logs.d.ts +3 -2
- package/dist/commands/functions/logs.js +4 -3
- package/dist/commands/functions/test.d.ts +3 -2
- package/dist/commands/functions/test.js +3 -2
- package/dist/constants.d.ts +15 -2
- package/dist/constants.js +14 -10
- package/dist/cores/blueprints/config.js +9 -4
- package/dist/cores/blueprints/destroy.js +78 -56
- package/dist/cores/blueprints/doctor.js +19 -5
- package/dist/cores/blueprints/init.js +2 -2
- package/dist/cores/functions/add.js +11 -7
- package/dist/cores/functions/dev.js +1 -1
- package/dist/server/app.d.ts +1 -2
- package/dist/server/app.js +16 -8
- package/dist/server/handlers/invoke.d.ts +1 -2
- package/dist/server/handlers/invoke.js +4 -4
- package/dist/server/static/components/rule-panel.js +8 -10
- package/oclif.manifest.json +503 -73
- package/package.json +2 -2
package/dist/server/app.js
CHANGED
|
@@ -2,19 +2,25 @@ import { existsSync, readFileSync, watchFile } from 'node:fs';
|
|
|
2
2
|
import * as http from 'node:http';
|
|
3
3
|
import { default as mime } from 'mime-types';
|
|
4
4
|
import { WebSocketServer } from 'ws';
|
|
5
|
-
import {
|
|
5
|
+
import { findBlueprintFile, loadAndParseBlueprint } from '../actions/blueprints/blueprint.js';
|
|
6
|
+
import { readConfigFile } from '../actions/blueprints/config.js';
|
|
7
|
+
import { resolveIds } from '../actions/blueprints/resolve.js';
|
|
6
8
|
import config from '../config.js';
|
|
7
9
|
import { isRecord } from '../utils/is-record.js';
|
|
8
10
|
import { isEventType, isGroqContextOptions, } from '../utils/types.js';
|
|
9
11
|
import { handleInvokeRequest } from './handlers/invoke.js';
|
|
10
|
-
const app = (host, port,
|
|
12
|
+
const app = (host, port, validateResources, executionOptions) => {
|
|
11
13
|
const requestListener = async (req, res) => {
|
|
12
14
|
res.setHeader('Content-Type', 'application/json');
|
|
13
15
|
switch (true) {
|
|
14
16
|
case req.url === '/blueprint': {
|
|
15
17
|
try {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
+
const blueprint = await loadAndParseBlueprint(undefined, { validateResources });
|
|
19
|
+
const { parsedBlueprint, fileInfo, module: blueprintModule } = blueprint;
|
|
20
|
+
const blueprintConfig = readConfigFile(fileInfo.blueprintFilePath);
|
|
21
|
+
const { projectId, organizationId } = resolveIds({
|
|
22
|
+
module: blueprintModule,
|
|
23
|
+
config: blueprintConfig,
|
|
18
24
|
});
|
|
19
25
|
res.setHeader('Content-Type', 'application/json');
|
|
20
26
|
res.writeHead(200);
|
|
@@ -44,7 +50,7 @@ const app = (host, port, logger, validateResources, executionOptions) => {
|
|
|
44
50
|
delete context.clientOptions.token;
|
|
45
51
|
}
|
|
46
52
|
}
|
|
47
|
-
const result = await handleInvokeRequest(functionName, event, metadata, context,
|
|
53
|
+
const result = await handleInvokeRequest(functionName, event, metadata, context, validateResources, executionOptions);
|
|
48
54
|
// Add Server-Timing header
|
|
49
55
|
const timingHeaders = [];
|
|
50
56
|
for (const [key, value] of Object.entries(result.timings)) {
|
|
@@ -230,10 +236,12 @@ const app = (host, port, logger, validateResources, executionOptions) => {
|
|
|
230
236
|
const server = http.createServer(requestListener);
|
|
231
237
|
server.listen(port, host, () => { });
|
|
232
238
|
const wss = new WebSocketServer({ port: 8974 });
|
|
233
|
-
wss.on('connection',
|
|
239
|
+
wss.on('connection', function connection(ws) {
|
|
234
240
|
ws.on('error', console.error);
|
|
235
|
-
const
|
|
236
|
-
|
|
241
|
+
const fileInfo = findBlueprintFile();
|
|
242
|
+
if (!fileInfo)
|
|
243
|
+
return;
|
|
244
|
+
watchFile(fileInfo.blueprintFilePath, { interval: 2007 }, () => {
|
|
237
245
|
ws.send('reload-blueprint');
|
|
238
246
|
});
|
|
239
247
|
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { Logger } from '../../utils/logger.js';
|
|
2
1
|
import type { InvocationResponse, InvokeContextOptions, InvokeExecutionOptions, InvokePayloadMetadata } from '../../utils/types.js';
|
|
3
|
-
export declare function handleInvokeRequest(functionName: string, event: Record<string, unknown>, metadata: InvokePayloadMetadata, context: InvokeContextOptions,
|
|
2
|
+
export declare function handleInvokeRequest(functionName: string, event: Record<string, unknown>, metadata: InvokePayloadMetadata, context: InvokeContextOptions, validateResources: boolean, executionOptions?: Partial<InvokeExecutionOptions>): Promise<InvocationResponse & {
|
|
4
3
|
timings: Record<string, number>;
|
|
5
4
|
}>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { loadAndParseBlueprint } from '../../actions/blueprints/blueprint.js';
|
|
2
2
|
import { findFunctionInResources } from '../../utils/find-function.js';
|
|
3
3
|
import invoke from '../../utils/invoke-local.js';
|
|
4
|
-
export async function handleInvokeRequest(functionName, event, metadata, context,
|
|
4
|
+
export async function handleInvokeRequest(functionName, event, metadata, context, validateResources, executionOptions) {
|
|
5
5
|
const start = performance.now();
|
|
6
|
-
const
|
|
7
|
-
const resource = findFunctionInResources(
|
|
6
|
+
const { resources } = await loadAndParseBlueprint(undefined, { validateResources });
|
|
7
|
+
const resource = findFunctionInResources(resources, functionName);
|
|
8
8
|
const readBlueprintTime = performance.now() - start;
|
|
9
9
|
const payload = {
|
|
10
10
|
payload: event,
|
|
@@ -43,16 +43,14 @@ class RulePanel extends ApiBaseElement {
|
|
|
43
43
|
break
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
rule.dispatch(transaction)
|
|
55
|
-
}
|
|
46
|
+
const transaction = rule.state.update({
|
|
47
|
+
changes: {
|
|
48
|
+
from: 0,
|
|
49
|
+
insert: func.event ? JSON.stringify(func.event, null, 2) : '',
|
|
50
|
+
to: rule.state.doc.length,
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
rule.dispatch(transaction)
|
|
56
54
|
}
|
|
57
55
|
|
|
58
56
|
async connectedCallback() {
|