@webstudio-is/sdk 0.274.5 → 0.276.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/lib/schema.js CHANGED
@@ -91,8 +91,8 @@ var dataSourceVariableValue = z3.union([
91
91
  }),
92
92
  z3.object({
93
93
  type: z3.literal("json"),
94
- value: z3.unknown()
95
- })
94
+ value: z3.unknown().optional()
95
+ }).transform((value) => ({ ...value, value: value.value ?? null }))
96
96
  ]);
97
97
  var dataSource = z3.union([
98
98
  z3.object({
@@ -155,12 +155,29 @@ var deployment = z4.union([
155
155
 
156
156
  // src/schema/instances.ts
157
157
  import { z as z5 } from "zod";
158
+ var textChildValue = z5.string();
158
159
  var textChild = z5.object({
159
160
  type: z5.literal("text"),
160
- value: z5.string(),
161
+ value: textChildValue,
161
162
  placeholder: z5.boolean().optional()
162
163
  });
163
164
  var instanceId = z5.string();
165
+ var instanceComponent = z5.string().min(1);
166
+ var instanceTag = z5.string().min(1, "Tag cannot be empty").describe(
167
+ "Optional HTML tag override for component rendering. Omit for component defaults; never pass an empty string."
168
+ );
169
+ var instanceAttributes = z5.object({
170
+ component: instanceComponent,
171
+ tag: instanceTag.optional(),
172
+ label: z5.string().optional()
173
+ });
174
+ var instanceCreateInput = instanceAttributes.partial({
175
+ component: true
176
+ });
177
+ var instanceFilterInput = instanceAttributes.pick({
178
+ component: true,
179
+ tag: true
180
+ }).partial();
164
181
  var idChild = z5.object({
165
182
  type: z5.literal("id"),
166
183
  value: instanceId
@@ -173,9 +190,9 @@ var instanceChild = z5.union([idChild, textChild, expressionChild]);
173
190
  var instance = z5.object({
174
191
  type: z5.literal("instance"),
175
192
  id: instanceId,
176
- component: z5.string(),
177
- tag: z5.string().optional(),
178
- label: z5.string().optional(),
193
+ component: instanceAttributes.shape.component,
194
+ tag: instanceAttributes.shape.tag,
195
+ label: instanceAttributes.shape.label,
179
196
  children: z5.array(instanceChild)
180
197
  });
181
198
  var instances = z5.map(instanceId, instance);
@@ -322,6 +339,7 @@ var projectMeta = z6.object({
322
339
  contactEmail: z6.string().optional(),
323
340
  faviconAssetId: z6.string().optional(),
324
341
  code: z6.string().optional(),
342
+ agentInstructions: z6.string().optional(),
325
343
  auth: z6.string().optional()
326
344
  });
327
345
  var projectNewRedirectPath = z6.string().min(1, "Path is required").refine((data) => {
@@ -571,7 +589,7 @@ var insetUnitValue = z7.union([
571
589
  value: z7.literal("auto")
572
590
  })
573
591
  ]);
574
- var keyframeStyles = z7.record(styleValue);
592
+ var keyframeStyles = z7.record(z7.string(), styleValue);
575
593
  var animationKeyframe = z7.object({
576
594
  offset: z7.number().optional(),
577
595
  styles: keyframeStyles
@@ -777,6 +795,7 @@ var resource = z9.object({
777
795
  });
778
796
  var resourceRequest = z9.object({
779
797
  name: z9.string(),
798
+ control: z9.optional(z9.union([z9.literal("system"), z9.literal("graphql")])),
780
799
  method,
781
800
  url: z9.string(),
782
801
  searchParams: z9.array(
@@ -865,7 +884,12 @@ export {
865
884
  imageMeta,
866
885
  initialBreakpoints,
867
886
  instance,
887
+ instanceAttributes,
868
888
  instanceChild,
889
+ instanceComponent,
890
+ instanceCreateInput,
891
+ instanceFilterInput,
892
+ instanceTag,
869
893
  instances,
870
894
  page,
871
895
  pageAuth,
@@ -891,5 +915,6 @@ export {
891
915
  styleSources,
892
916
  styles,
893
917
  templates,
894
- textChild
918
+ textChild,
919
+ textChildValue
895
920
  };
@@ -16,5 +16,5 @@ export declare const coreMetas: {
16
16
  "ws:block": WsComponentMeta;
17
17
  "ws:block-template": WsComponentMeta;
18
18
  };
19
- export declare const isCoreComponent: (component: Instance["component"]) => component is "ws:root" | "ws:element" | "ws:collection" | "ws:descendant" | "ws:block" | "ws:block-template";
19
+ export declare const isCoreComponent: (component: Instance["component"]) => component is "ws:block" | "ws:block-template" | "ws:collection" | "ws:descendant" | "ws:element" | "ws:root";
20
20
  export declare const isComponentDetachable: (component: Instance["component"]) => boolean;
@@ -22,7 +22,9 @@ export * from "./resources-generator";
22
22
  export * from "./page-meta-generator";
23
23
  export * from "./url-pattern";
24
24
  export * from "./link-utils";
25
+ export * from "./json-ld";
25
26
  export * from "./css";
26
27
  export * from "./__generated__/tags";
28
+ export { getInputJsonSchemaAdditionalProperties, getInputJsonSchemaMetadata, getInputJsonSchemaProperties, inputJsonSchemaAcceptsType, toInputJsonSchemaObject, type InputJsonSchema, type InputJsonSchemaValue, type InputJsonSchemaMetadata, } from "./input-json-schema";
27
29
  export type { AnimationAction, AnimationActionScroll, AnimationActionView, AnimationKeyframe, KeyframeStyles, RangeUnit, RangeUnitValue, ScrollNamedRange, ScrollRangeValue, ViewNamedRange, ViewRangeValue, ScrollAnimation, ViewAnimation, InsetUnitValue, DurationUnitValue, IterationsUnitValue, TimeUnit, } from "./schema/animation-schema";
28
30
  export { animationAction, scrollAnimation, viewAnimation, rangeUnitValue, animationKeyframe, insetUnitValue, durationUnitValue, RANGE_UNITS, } from "./schema/animation-schema";
@@ -0,0 +1,15 @@
1
+ import type { JSONSchema } from "json-schema-typed";
2
+ export type InputJsonSchema = JSONSchema.Interface;
3
+ export type InputJsonSchemaValue = JSONSchema;
4
+ export type InputJsonSchemaMetadata = {
5
+ inputFields: readonly string[];
6
+ requiredInputFields: readonly string[];
7
+ inputFieldTypes: Partial<Record<string, "array">>;
8
+ };
9
+ export declare const toInputJsonSchemaObject: (schema: InputJsonSchemaValue | undefined) => InputJsonSchema | undefined;
10
+ export declare const inputJsonSchemaAcceptsType: (schema: InputJsonSchema, type: string, options?: {
11
+ treatUnconstrainedAsAny?: boolean;
12
+ }) => boolean;
13
+ export declare const getInputJsonSchemaProperties: (schema: InputJsonSchema | undefined) => Record<string, InputJsonSchema> | undefined;
14
+ export declare const getInputJsonSchemaAdditionalProperties: (schema: InputJsonSchema | undefined) => InputJsonSchema | undefined;
15
+ export declare const getInputJsonSchemaMetadata: (inputSchema: InputJsonSchema) => InputJsonSchemaMetadata;
@@ -0,0 +1,3 @@
1
+ export declare const isJsonObject: (value: unknown) => value is Record<string, unknown>;
2
+ export declare const appendJsonPath: (path: string, key: string | number) => string;
3
+ export declare const getJsonLdTypes: (value: unknown) => string[];
@@ -0,0 +1,31 @@
1
+ export type JsonLdPrimitive = string | number | boolean | null;
2
+ export type JsonLdData = JsonLdPrimitive | {
3
+ [key: string]: JsonLdData;
4
+ } | JsonLdData[];
5
+ export type JsonLdValue = {
6
+ [key: string]: JsonLdData;
7
+ } | JsonLdData[];
8
+ export type JsonLdStructuralDiagnostic = {
9
+ severity: "error";
10
+ code: "invalid-json" | "invalid-root" | "invalid-context" | "invalid-keyword-value" | "invalid-value-object";
11
+ path: string;
12
+ message: string;
13
+ };
14
+ export type JsonLdValidationResult = {
15
+ success: true;
16
+ value: JsonLdValue;
17
+ diagnostics: JsonLdStructuralDiagnostic[];
18
+ } | {
19
+ success: false;
20
+ value?: JsonLdValue;
21
+ diagnostics: JsonLdStructuralDiagnostic[];
22
+ };
23
+ export declare const escapeJsonLdScriptText: (value: string) => string;
24
+ export declare const parseJsonLd: (input: unknown) => {
25
+ success: true;
26
+ value: JsonLdValue;
27
+ } | {
28
+ success: false;
29
+ };
30
+ export declare const validateJsonLd: (input: unknown) => JsonLdValidationResult;
31
+ export declare const hasTopLevelJsonLdContext: (value: JsonLdValue) => boolean;
@@ -1,6 +1,7 @@
1
1
  export * from "./resource-loader";
2
2
  export * from "./to-string";
3
3
  export * from "./form-fields";
4
+ export * from "./json-ld";
4
5
  export declare const tagProperty = "data-ws-tag";
5
6
  export declare const getTagFromProps: (props: Record<string, unknown>) => string | undefined;
6
7
  export declare const indexProperty = "data-ws-index";