@vard-app/sdk 0.1.3 → 0.1.5

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.
@@ -1,113 +0,0 @@
1
- type VardVariableType = "string" | "richtext" | "color" | "image" | "boolean" | "list";
2
- type VardListItemSchema = Record<string, "string" | "richtext" | "color" | "image" | "boolean">;
3
- type InferListItem<S extends VardListItemSchema> = {
4
- [K in keyof S]: S[K] extends "string" ? string : S[K] extends "richtext" ? string : S[K] extends "color" ? string : S[K] extends "image" ? string : S[K] extends "boolean" ? boolean : never;
5
- };
6
- type VardRole = "owner" | "developer" | "member" | "viewer";
7
- interface VardVariableDefinition<T = unknown> {
8
- /** Dot-notation key, e.g. "hero.title" */
9
- key: string;
10
- /** Human-readable label shown in the client portal */
11
- label: string;
12
- type: VardVariableType;
13
- /** The default value baked into the codebase */
14
- defaultValue: T;
15
- /** Minimum role required to edit this variable. Defaults to "member". */
16
- editableBy: VardRole;
17
- /** Optional description shown as a hint in the client portal */
18
- description?: string;
19
- /** For list variables — the schema of each item */
20
- listItemSchema?: VardListItemSchema;
21
- /** Optional grouping for the dashboard UI */
22
- group?: string;
23
- /** Indicates this is a reusable content pool/collection */
24
- isCollection?: boolean;
25
- }
26
- interface VardStore {
27
- /** Returns a stored value for the given key, or undefined if not set */
28
- get(key: string): unknown;
29
- }
30
- interface VardOptions {
31
- /**
32
- * API Key for authentication. Read from VARD_API_KEY env var if not provided.
33
- * This is the preferred way to configure the SDK as it's tied to your workspace.
34
- */
35
- apiKey?: string;
36
- /**
37
- * Workspace ID (Legacy). Required only if not using an API Key.
38
- * Read from VARD_WORKSPACE_ID env var if not provided.
39
- */
40
- workspaceId?: string;
41
- /**
42
- * Provide a custom store implementation. Used internally by the Next.js
43
- * adapter and for testing. Defaults to a no-op in environments where
44
- * VARD_WORKSPACE_ID is unset (local dev without Vard).
45
- */
46
- store?: VardStore;
47
- }
48
- interface VardClient {
49
- /**
50
- * Access to global (project-wide) variables.
51
- * e.g., vard.global.string("contact.email", "...")
52
- */
53
- global: VardGlobalClient;
54
- /**
55
- * Define a reusable content pool/collection.
56
- */
57
- collection<S extends VardListItemSchema>(key: string, schema: S, fallback: InferListItem<S>[], options?: Omit<VardVariableOptions, "type">): InferListItem<S>[];
58
- /**
59
- * A plain string variable. e.g. a hero headline, a CTA label.
60
- *
61
- * @param key Dot-notation identifier, unique within the workspace
62
- * @param fallback Default value when no client value is stored
63
- * @param options Optional label, description, permission
64
- */
65
- string(key: string, fallback: string, options?: VardVariableOptions): string;
66
- /**
67
- * A rich text (markdown) variable. Rendered as HTML at build time.
68
- */
69
- richtext(key: string, fallback: string, options?: VardVariableOptions): string;
70
- /**
71
- * A CSS color string (hex, hsl, rgb).
72
- */
73
- color(key: string, fallback: string, options?: VardVariableOptions): string;
74
- /**
75
- * A URL pointing to an uploaded asset (image, video).
76
- */
77
- image(key: string, fallback: string, options?: VardVariableOptions): string;
78
- /**
79
- * A boolean feature flag. e.g. show/hide a section.
80
- */
81
- boolean(key: string, fallback: boolean, options?: Omit<VardVariableOptions, "type">): boolean;
82
- /**
83
- * An ordered list of typed objects. e.g. team members, testimonials.
84
- *
85
- * @param schema Defines the shape of each list item
86
- */
87
- list<S extends VardListItemSchema>(key: string, schema: S, fallback: InferListItem<S>[], options?: Omit<VardVariableOptions, "type">): InferListItem<S>[];
88
- /**
89
- * Returns all registered variable definitions. Used by the CLI scanner
90
- * and the build pipeline to sync definitions to the Vard API.
91
- */
92
- getDefinitions(): VardVariableDefinition[];
93
- /**
94
- * Access to the underlying store.
95
- */
96
- readonly store: VardStore;
97
- }
98
- interface VardGlobalClient {
99
- string(key: string, fallback: string, options?: Omit<VardVariableOptions, "group">): string;
100
- richtext(key: string, fallback: string, options?: Omit<VardVariableOptions, "group">): string;
101
- color(key: string, fallback: string, options?: Omit<VardVariableOptions, "group">): string;
102
- image(key: string, fallback: string, options?: Omit<VardVariableOptions, "group">): string;
103
- boolean(key: string, fallback: boolean, options?: Omit<VardVariableOptions, "type" | "group">): boolean;
104
- list<S extends VardListItemSchema>(key: string, schema: S, fallback: InferListItem<S>[], options?: Omit<VardVariableOptions, "type" | "group">): InferListItem<S>[];
105
- }
106
- interface VardVariableOptions {
107
- label?: string;
108
- description?: string;
109
- editableBy?: VardRole;
110
- group?: string;
111
- }
112
-
113
- export type { InferListItem as I, VardOptions as V, VardClient as a, VardStore as b, VardListItemSchema as c, VardRole as d, VardVariableDefinition as e, VardVariableOptions as f, VardVariableType as g };
@@ -1,113 +0,0 @@
1
- type VardVariableType = "string" | "richtext" | "color" | "image" | "boolean" | "list";
2
- type VardListItemSchema = Record<string, "string" | "richtext" | "color" | "image" | "boolean">;
3
- type InferListItem<S extends VardListItemSchema> = {
4
- [K in keyof S]: S[K] extends "string" ? string : S[K] extends "richtext" ? string : S[K] extends "color" ? string : S[K] extends "image" ? string : S[K] extends "boolean" ? boolean : never;
5
- };
6
- type VardRole = "owner" | "developer" | "member" | "viewer";
7
- interface VardVariableDefinition<T = unknown> {
8
- /** Dot-notation key, e.g. "hero.title" */
9
- key: string;
10
- /** Human-readable label shown in the client portal */
11
- label: string;
12
- type: VardVariableType;
13
- /** The default value baked into the codebase */
14
- defaultValue: T;
15
- /** Minimum role required to edit this variable. Defaults to "member". */
16
- editableBy: VardRole;
17
- /** Optional description shown as a hint in the client portal */
18
- description?: string;
19
- /** For list variables — the schema of each item */
20
- listItemSchema?: VardListItemSchema;
21
- /** Optional grouping for the dashboard UI */
22
- group?: string;
23
- /** Indicates this is a reusable content pool/collection */
24
- isCollection?: boolean;
25
- }
26
- interface VardStore {
27
- /** Returns a stored value for the given key, or undefined if not set */
28
- get(key: string): unknown;
29
- }
30
- interface VardOptions {
31
- /**
32
- * API Key for authentication. Read from VARD_API_KEY env var if not provided.
33
- * This is the preferred way to configure the SDK as it's tied to your workspace.
34
- */
35
- apiKey?: string;
36
- /**
37
- * Workspace ID (Legacy). Required only if not using an API Key.
38
- * Read from VARD_WORKSPACE_ID env var if not provided.
39
- */
40
- workspaceId?: string;
41
- /**
42
- * Provide a custom store implementation. Used internally by the Next.js
43
- * adapter and for testing. Defaults to a no-op in environments where
44
- * VARD_WORKSPACE_ID is unset (local dev without Vard).
45
- */
46
- store?: VardStore;
47
- }
48
- interface VardClient {
49
- /**
50
- * Access to global (project-wide) variables.
51
- * e.g., vard.global.string("contact.email", "...")
52
- */
53
- global: VardGlobalClient;
54
- /**
55
- * Define a reusable content pool/collection.
56
- */
57
- collection<S extends VardListItemSchema>(key: string, schema: S, fallback: InferListItem<S>[], options?: Omit<VardVariableOptions, "type">): InferListItem<S>[];
58
- /**
59
- * A plain string variable. e.g. a hero headline, a CTA label.
60
- *
61
- * @param key Dot-notation identifier, unique within the workspace
62
- * @param fallback Default value when no client value is stored
63
- * @param options Optional label, description, permission
64
- */
65
- string(key: string, fallback: string, options?: VardVariableOptions): string;
66
- /**
67
- * A rich text (markdown) variable. Rendered as HTML at build time.
68
- */
69
- richtext(key: string, fallback: string, options?: VardVariableOptions): string;
70
- /**
71
- * A CSS color string (hex, hsl, rgb).
72
- */
73
- color(key: string, fallback: string, options?: VardVariableOptions): string;
74
- /**
75
- * A URL pointing to an uploaded asset (image, video).
76
- */
77
- image(key: string, fallback: string, options?: VardVariableOptions): string;
78
- /**
79
- * A boolean feature flag. e.g. show/hide a section.
80
- */
81
- boolean(key: string, fallback: boolean, options?: Omit<VardVariableOptions, "type">): boolean;
82
- /**
83
- * An ordered list of typed objects. e.g. team members, testimonials.
84
- *
85
- * @param schema Defines the shape of each list item
86
- */
87
- list<S extends VardListItemSchema>(key: string, schema: S, fallback: InferListItem<S>[], options?: Omit<VardVariableOptions, "type">): InferListItem<S>[];
88
- /**
89
- * Returns all registered variable definitions. Used by the CLI scanner
90
- * and the build pipeline to sync definitions to the Vard API.
91
- */
92
- getDefinitions(): VardVariableDefinition[];
93
- /**
94
- * Access to the underlying store.
95
- */
96
- readonly store: VardStore;
97
- }
98
- interface VardGlobalClient {
99
- string(key: string, fallback: string, options?: Omit<VardVariableOptions, "group">): string;
100
- richtext(key: string, fallback: string, options?: Omit<VardVariableOptions, "group">): string;
101
- color(key: string, fallback: string, options?: Omit<VardVariableOptions, "group">): string;
102
- image(key: string, fallback: string, options?: Omit<VardVariableOptions, "group">): string;
103
- boolean(key: string, fallback: boolean, options?: Omit<VardVariableOptions, "type" | "group">): boolean;
104
- list<S extends VardListItemSchema>(key: string, schema: S, fallback: InferListItem<S>[], options?: Omit<VardVariableOptions, "type" | "group">): InferListItem<S>[];
105
- }
106
- interface VardVariableOptions {
107
- label?: string;
108
- description?: string;
109
- editableBy?: VardRole;
110
- group?: string;
111
- }
112
-
113
- export type { InferListItem as I, VardOptions as V, VardClient as a, VardStore as b, VardListItemSchema as c, VardRole as d, VardVariableDefinition as e, VardVariableOptions as f, VardVariableType as g };