@sanity/runtime-cli 1.3.1 → 1.4.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.
Files changed (59) hide show
  1. package/README.md +11 -14
  2. package/dist/actions/blueprints/logs.d.ts +1 -0
  3. package/dist/actions/blueprints/logs.js +3 -2
  4. package/dist/actions/blueprints/operations.d.ts +1 -0
  5. package/dist/actions/blueprints/operations.js +3 -2
  6. package/dist/actions/blueprints/read-blueprint.d.ts +16 -7
  7. package/dist/actions/blueprints/read-blueprint.js +56 -10
  8. package/dist/actions/blueprints/stacks.d.ts +6 -6
  9. package/dist/actions/blueprints/stacks.js +10 -14
  10. package/dist/actions/blueprints/stash-asset.d.ts +1 -0
  11. package/dist/actions/blueprints/stash-asset.js +2 -5
  12. package/dist/actions/functions/invoke.d.ts +6 -2
  13. package/dist/actions/functions/invoke.js +9 -11
  14. package/dist/actions/functions/logs.d.ts +6 -1
  15. package/dist/actions/functions/logs.js +10 -10
  16. package/dist/commands/blueprints/deploy.js +19 -18
  17. package/dist/commands/blueprints/info.js +18 -38
  18. package/dist/commands/blueprints/logs.d.ts +0 -1
  19. package/dist/commands/blueprints/logs.js +12 -41
  20. package/dist/commands/blueprints/plan.js +14 -4
  21. package/dist/commands/functions/invoke.js +19 -2
  22. package/dist/commands/functions/logs.js +26 -2
  23. package/dist/config.js +6 -5
  24. package/dist/server/static/api.d.ts +10 -0
  25. package/dist/server/static/api.js +38 -43
  26. package/dist/server/static/components/api-base.d.ts +9 -0
  27. package/dist/server/static/components/api-base.js +6 -7
  28. package/dist/server/static/components/function-list.d.ts +1 -0
  29. package/dist/server/static/components/function-list.js +44 -48
  30. package/dist/server/static/components/network-spinner.d.ts +1 -0
  31. package/dist/server/static/components/network-spinner.js +6 -7
  32. package/dist/server/static/components/payload-panel.d.ts +1 -0
  33. package/dist/server/static/components/payload-panel.js +32 -36
  34. package/dist/server/static/components/response-panel.d.ts +1 -0
  35. package/dist/server/static/components/response-panel.js +50 -64
  36. package/dist/server/static/static/api.js +53 -0
  37. package/dist/server/static/static/components/api-base.js +10 -0
  38. package/dist/server/static/static/components/function-list.js +54 -0
  39. package/dist/server/static/static/components/network-spinner.js +71 -0
  40. package/dist/server/static/static/components/payload-panel.js +45 -0
  41. package/dist/server/static/static/components/response-panel.js +83 -0
  42. package/dist/server/static/static/vendor/vendor.bundle.js +26879 -0
  43. package/dist/server/static/vendor/vendor.bundle.d.ts +1815 -0
  44. package/dist/server/static/vendor/vendor.bundle.js +913 -1029
  45. package/dist/utils/child-process-wrapper.d.ts +1 -0
  46. package/dist/utils/display/blueprints-formatting.js +2 -2
  47. package/dist/utils/get-headers.d.ts +8 -0
  48. package/dist/utils/get-headers.js +9 -0
  49. package/dist/utils/get-token.d.ts +3 -1
  50. package/dist/utils/get-token.js +2 -2
  51. package/dist/utils/types.d.ts +44 -30
  52. package/dist/utils/types.js +8 -1
  53. package/dist/utils/vendor/parser-validator.d.ts +8 -0
  54. package/dist/utils/vendor/parser-validator.js +514 -0
  55. package/oclif.manifest.json +1 -11
  56. package/package.json +11 -12
  57. /package/dist/server/static/{components → static/components}/app.css +0 -0
  58. /package/dist/server/static/{index.html → static/index.html} +0 -0
  59. /package/dist/server/static/{sanity-logo-sm.svg → static/sanity-logo-sm.svg} +0 -0
@@ -0,0 +1 @@
1
+ export {};
@@ -18,8 +18,8 @@ export function formatResourceTree(resources, logger) {
18
18
  return;
19
19
  }
20
20
  logger(`${blue('Stack Resources')} [${resources.length}]`);
21
- const functionResources = resources.filter((r) => r.kind === 'function');
22
- const otherResources = resources.filter((r) => r.kind !== 'function');
21
+ const functionResources = resources.filter((r) => r.type?.startsWith('sanity.function.') || r.kind === 'function');
22
+ const otherResources = resources.filter((r) => !r.type?.startsWith('sanity.function.') && r.kind !== 'function');
23
23
  const hasOtherResources = otherResources.length > 0;
24
24
  if (functionResources.length > 0) {
25
25
  logger(` ${hasOtherResources ? '├─' : '└─'} ${bold('Functions')} [${functionResources.length}]`);
@@ -0,0 +1,8 @@
1
+ import type { AuthParams } from './types.js';
2
+ export default function getHeaders({ token, projectId }: AuthParams): {
3
+ Accept: string;
4
+ 'Content-Type': string;
5
+ Authorization: string;
6
+ 'X-Sanity-Scope-Type': string;
7
+ 'X-Sanity-Scope-Id': string;
8
+ };
@@ -0,0 +1,9 @@
1
+ export default function getHeaders({ token, projectId }) {
2
+ return {
3
+ Accept: 'application/json',
4
+ 'Content-Type': 'application/json',
5
+ Authorization: `Bearer ${token}`,
6
+ 'X-Sanity-Scope-Type': 'project',
7
+ 'X-Sanity-Scope-Id': projectId,
8
+ };
9
+ }
@@ -1 +1,3 @@
1
- export default function getToken(isProd: boolean): string;
1
+ export default function getToken({ prod }: {
2
+ prod?: boolean;
3
+ }): string;
@@ -2,8 +2,8 @@ import { readFileSync } from 'node:fs';
2
2
  import { tmpdir, userInfo } from 'node:os';
3
3
  import { join } from 'node:path';
4
4
  import { xdgConfig } from 'xdg-basedir';
5
- export default function getToken(isProd) {
6
- const environmentDir = isProd ? 'sanity' : 'sanity-staging';
5
+ export default function getToken({ prod = true }) {
6
+ const environmentDir = prod ? 'sanity' : 'sanity-staging';
7
7
  const user = (userInfo().username || 'user').replace(/\\/g, '');
8
8
  const configDir = xdgConfig || join(tmpdir(), user, '.config');
9
9
  const configPath = join(configDir, environmentDir, 'config.json');
@@ -1,63 +1,48 @@
1
- /**
2
- * @internal
3
- */
1
+ /** @internal */
4
2
  export interface PayloadOptions {
5
3
  data: string | undefined;
6
4
  file: string | undefined;
7
5
  timeout?: number | undefined;
8
6
  }
9
- /**
10
- * @internal
11
- */
7
+ /** @internal */
12
8
  export interface InvocationResponse {
13
9
  error: undefined | unknown;
14
10
  json: object | undefined;
15
11
  logs: string | undefined;
16
12
  }
17
13
  type LogFunction = (input: string) => void;
18
- /**
19
- * @internal
20
- */
14
+ /** @internal */
21
15
  export interface BlueprintsContext {
22
16
  log: LogFunction;
23
17
  }
24
- /**
25
- * @internal
26
- */
18
+ /** @internal */
27
19
  export interface Blueprint {
28
- displayName: string;
29
- name: string;
30
- projectId: string;
20
+ blueprintVersion: string;
21
+ values: Record<string, unknown>;
22
+ outputs: Array<Record<string, unknown>>;
31
23
  resources: Array<BlueprintResource>;
32
24
  }
33
- /**
34
- * @internal
35
- */
25
+ /** @internal */
36
26
  export interface BlueprintDocument {
37
27
  resources: Array<BlueprintResource>;
38
28
  }
39
- /**
40
- * @internal
41
- */
29
+ /** @internal */
42
30
  export interface BlueprintJob {
43
31
  name: string;
44
32
  projectId: string;
45
33
  document: BlueprintDocument;
46
34
  }
47
- /**
48
- * @internal
49
- */
35
+ /** @internal */
50
36
  export interface BlueprintResource {
51
37
  id: string;
52
38
  displayName: string;
53
39
  name: string;
54
40
  kind: string;
41
+ type: string;
55
42
  src: string;
56
43
  externalId: string;
57
44
  }
58
- /**
59
- * @internal
60
- */
45
+ /** @internal */
61
46
  export interface BlueprintOperation {
62
47
  id: string;
63
48
  status: string;
@@ -68,16 +53,45 @@ export interface BlueprintStack {
68
53
  id: string;
69
54
  name: string;
70
55
  displayName: string;
56
+ projectId: string;
71
57
  resources: Array<BlueprintResource>;
72
58
  createdAt?: string;
73
59
  updatedAt?: string;
74
60
  recentOperation?: BlueprintOperation;
75
61
  }
76
- /**
77
- * @internal
78
- */
62
+ /** @internal */
63
+ export declare enum BlueprintErrorType {
64
+ MissingProject = "missing_project",
65
+ MissingStack = "missing_stack",
66
+ InvalidProperty = "invalid_property",
67
+ InvalidStack = "invalid_stack"
68
+ }
69
+ /** @internal */
70
+ export interface BlueprintError {
71
+ message: string;
72
+ type: BlueprintErrorType;
73
+ }
74
+ /** @internal */
79
75
  export interface BlueprintLog {
80
76
  timestamp: string;
81
77
  message: string;
82
78
  }
79
+ /** @internal */
80
+ export interface AuthParams {
81
+ token: string;
82
+ projectId: string;
83
+ }
84
+ /** @internal */
85
+ export interface FunctionLog {
86
+ eventId: string;
87
+ ingestionTime: string;
88
+ timestamp: string;
89
+ message: string;
90
+ }
91
+ /** @internal */
92
+ export interface FunctionLogGroup {
93
+ events: Array<FunctionLog>;
94
+ nextBackwardToken: string;
95
+ nextForwardToken: string;
96
+ }
83
97
  export {};
@@ -1 +1,8 @@
1
- export {};
1
+ /** @internal */
2
+ export var BlueprintErrorType;
3
+ (function (BlueprintErrorType) {
4
+ BlueprintErrorType["MissingProject"] = "missing_project";
5
+ BlueprintErrorType["MissingStack"] = "missing_stack";
6
+ BlueprintErrorType["InvalidProperty"] = "invalid_property";
7
+ BlueprintErrorType["InvalidStack"] = "invalid_stack";
8
+ })(BlueprintErrorType || (BlueprintErrorType = {}));
@@ -0,0 +1,8 @@
1
+ export { blueprintParserValidator as default };
2
+ declare function blueprintParserValidator(input: any, options?: {}): {
3
+ blueprint: any;
4
+ errors: any[];
5
+ } | {
6
+ blueprint: any;
7
+ errors?: undefined;
8
+ };