@jay-framework/wix-data 0.15.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 +151 -0
- package/dist/actions/get-categories.jay-action +12 -0
- package/dist/actions/get-item-by-slug.jay-action +9 -0
- package/dist/actions/query-items.jay-action +19 -0
- package/dist/index.client.js +244 -0
- package/dist/index.d.ts +633 -0
- package/dist/index.js +1561 -0
- package/package.json +63 -0
- package/plugin.yaml +39 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,633 @@
|
|
|
1
|
+
import { WixClient } from '@wix/sdk';
|
|
2
|
+
import * as _jay_framework_fullstack_component from '@jay-framework/fullstack-component';
|
|
3
|
+
import { PageProps, DynamicContractProps, UrlParams } from '@jay-framework/fullstack-component';
|
|
4
|
+
import { items, collections } from '@wix/data';
|
|
5
|
+
import { DataCollection } from '@wix/auto_sdk_data_collections';
|
|
6
|
+
import { BuildDescriptors } from '@wix/sdk-types';
|
|
7
|
+
import * as _jay_framework_runtime from '@jay-framework/runtime';
|
|
8
|
+
import * as _jay_framework_component from '@jay-framework/component';
|
|
9
|
+
import { WixDataItem } from '@wix/wix-data-items-sdk';
|
|
10
|
+
import { PluginSetupContext, PluginSetupResult, PluginReferencesContext, PluginReferencesResult } from '@jay-framework/stack-server-runtime';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Wix Data Plugin Configuration Types
|
|
14
|
+
*
|
|
15
|
+
* Defines the structure for wix-data.config.yaml
|
|
16
|
+
*/
|
|
17
|
+
interface WixDataConfig {
|
|
18
|
+
collections: CollectionConfig[];
|
|
19
|
+
}
|
|
20
|
+
interface CollectionConfig {
|
|
21
|
+
/** Wix Data collection ID */
|
|
22
|
+
collectionId: string;
|
|
23
|
+
/**
|
|
24
|
+
* Whether this collection is visible (generates contracts).
|
|
25
|
+
* Default: false (hidden) - must be explicitly enabled.
|
|
26
|
+
*/
|
|
27
|
+
visible?: boolean;
|
|
28
|
+
/** URL path prefix (e.g., "/blog" for blog posts) */
|
|
29
|
+
pathPrefix: string;
|
|
30
|
+
/** Field to use as URL slug (required for routing) */
|
|
31
|
+
slugField: string;
|
|
32
|
+
/** Reference field configurations */
|
|
33
|
+
references?: ReferenceConfig[];
|
|
34
|
+
/** Category configuration (for category pages) */
|
|
35
|
+
category?: CategoryConfig;
|
|
36
|
+
/** Components to generate with optional field whitelists */
|
|
37
|
+
components: ComponentsConfig;
|
|
38
|
+
}
|
|
39
|
+
interface ReferenceConfig {
|
|
40
|
+
/** Reference field name in the collection */
|
|
41
|
+
fieldName: string;
|
|
42
|
+
/**
|
|
43
|
+
* How to handle the reference:
|
|
44
|
+
* - 'embed': Fetch referenced item(s) and include full data
|
|
45
|
+
* - 'link': Include only the reference ID (default)
|
|
46
|
+
*/
|
|
47
|
+
mode: 'embed' | 'link';
|
|
48
|
+
/**
|
|
49
|
+
* Nested reference configurations for multi-level embeds.
|
|
50
|
+
* Only applicable when mode is 'embed'.
|
|
51
|
+
* Allows embedding references within the referenced collection.
|
|
52
|
+
*/
|
|
53
|
+
references?: ReferenceConfig[];
|
|
54
|
+
}
|
|
55
|
+
interface CategoryConfig {
|
|
56
|
+
/** Multi-reference field that links to category collection */
|
|
57
|
+
referenceField: string;
|
|
58
|
+
/** Field in category collection to use as slug for URLs */
|
|
59
|
+
categorySlugField: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Component configuration - either a boolean or an object with field whitelist.
|
|
63
|
+
* - `true`: Generate component with all applicable fields
|
|
64
|
+
* - `false` or omitted: Don't generate component
|
|
65
|
+
* - `{ fields: [...] }`: Generate component with only whitelisted fields
|
|
66
|
+
*/
|
|
67
|
+
type ComponentConfig = boolean | {
|
|
68
|
+
/** Whitelist of field keys to include. If omitted, all fields included. */
|
|
69
|
+
fields?: string[];
|
|
70
|
+
};
|
|
71
|
+
interface ComponentsConfig {
|
|
72
|
+
/** Generate item page component */
|
|
73
|
+
itemPage?: ComponentConfig;
|
|
74
|
+
/** Generate index page component (list all items) */
|
|
75
|
+
indexPage?: ComponentConfig;
|
|
76
|
+
/** Generate category page component (items by category) */
|
|
77
|
+
categoryPage?: ComponentConfig;
|
|
78
|
+
/** Generate table widget component */
|
|
79
|
+
tableWidget?: ComponentConfig;
|
|
80
|
+
/** Generate card widget component */
|
|
81
|
+
cardWidget?: ComponentConfig;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Validated configuration with collection schemas loaded
|
|
85
|
+
*/
|
|
86
|
+
interface ResolvedWixDataConfig extends WixDataConfig {
|
|
87
|
+
/** Collection schemas fetched from Wix Data API */
|
|
88
|
+
schemas: Map<string, CollectionSchema>;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Collection schema from Wix Data API
|
|
92
|
+
*/
|
|
93
|
+
interface CollectionSchema {
|
|
94
|
+
_id: string;
|
|
95
|
+
displayName?: string;
|
|
96
|
+
fields: FieldSchema[];
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Field schema from Wix Data API
|
|
100
|
+
*/
|
|
101
|
+
interface FieldSchema {
|
|
102
|
+
key: string;
|
|
103
|
+
displayName?: string;
|
|
104
|
+
type: WixDataFieldType;
|
|
105
|
+
required?: boolean;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Wix Data field types
|
|
109
|
+
* @see https://dev.wix.com/docs/sdk/backend-modules/data/collections/data-types-in-wix-data
|
|
110
|
+
*/
|
|
111
|
+
type WixDataFieldType = 'TEXT' | 'NUMBER' | 'BOOLEAN' | 'DATE' | 'DATETIME' | 'TIME' | 'RICH_TEXT' | 'URL' | 'IMAGE' | 'VIDEO' | 'AUDIO' | 'DOCUMENT' | 'REFERENCE' | 'MULTI_REFERENCE' | 'ARRAY' | 'OBJECT' | 'TAGS' | 'ADDRESS' | 'RICH_CONTENT';
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Configuration Loader for Wix Data Plugin
|
|
115
|
+
*
|
|
116
|
+
* Loads wix-data config from /config/wix-data.yaml.
|
|
117
|
+
* If no config exists, generates a default config from the Wix Data API and saves it.
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Load the wix-data configuration.
|
|
122
|
+
*
|
|
123
|
+
* - If config file exists: load and parse it
|
|
124
|
+
* - If config file doesn't exist: generate default config from Wix API and save it
|
|
125
|
+
*
|
|
126
|
+
* @param wixClient - Authenticated Wix client for fetching collections
|
|
127
|
+
*/
|
|
128
|
+
declare function loadConfig(wixClient: WixClient): Promise<WixDataConfig>;
|
|
129
|
+
/**
|
|
130
|
+
* Validate a collection configuration
|
|
131
|
+
*/
|
|
132
|
+
declare function validateCollectionConfig(config: CollectionConfig): string[];
|
|
133
|
+
/**
|
|
134
|
+
* Validate the entire configuration
|
|
135
|
+
*/
|
|
136
|
+
declare function validateConfig(config: WixDataConfig): string[];
|
|
137
|
+
/**
|
|
138
|
+
* Get visible collections from config
|
|
139
|
+
*/
|
|
140
|
+
declare function getVisibleCollections(config: WixDataConfig): CollectionConfig[];
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Processed Schema
|
|
144
|
+
*
|
|
145
|
+
* Intermediate representation of a collection schema with processed fields.
|
|
146
|
+
* Created once from Wix Data API response and reused by all contract generators.
|
|
147
|
+
*/
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Processed field with normalized types
|
|
151
|
+
*/
|
|
152
|
+
interface ProcessedField {
|
|
153
|
+
key: string;
|
|
154
|
+
displayName?: string;
|
|
155
|
+
jayType: string;
|
|
156
|
+
wixType: string;
|
|
157
|
+
/** Field category for filtering */
|
|
158
|
+
category: 'simple' | 'image' | 'media' | 'address' | 'reference' | 'multiReference' | 'richContent' | 'system';
|
|
159
|
+
/** Whether this reference should be embedded (full data fetched) */
|
|
160
|
+
embedded?: boolean;
|
|
161
|
+
/**
|
|
162
|
+
* For embedded references: the processed schema of the referenced collection.
|
|
163
|
+
* Enables generating full sub-contracts from the referenced collection's fields.
|
|
164
|
+
*/
|
|
165
|
+
embeddedSchema?: ProcessedSchema;
|
|
166
|
+
/** Reference configuration (for embedded refs, includes nested references) */
|
|
167
|
+
referenceConfig?: ReferenceConfig;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Processed schema ready for contract generation
|
|
171
|
+
*/
|
|
172
|
+
interface ProcessedSchema {
|
|
173
|
+
collectionId: string;
|
|
174
|
+
displayName?: string;
|
|
175
|
+
config: CollectionConfig;
|
|
176
|
+
/** All fields with processed metadata */
|
|
177
|
+
fields: ProcessedField[];
|
|
178
|
+
/** Whether this collection has category support */
|
|
179
|
+
hasCategory: boolean;
|
|
180
|
+
/** Category configuration if present */
|
|
181
|
+
category?: {
|
|
182
|
+
referenceField: string;
|
|
183
|
+
categorySlugField: string;
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Collection fetcher function type - used for fetching referenced collections
|
|
188
|
+
*/
|
|
189
|
+
type CollectionFetcher = (collectionId: string) => Promise<DataCollection | null>;
|
|
190
|
+
/**
|
|
191
|
+
* Process a DataCollection from Wix Data API into our intermediate representation.
|
|
192
|
+
*
|
|
193
|
+
* @param collection - DataCollection from Wix Data API
|
|
194
|
+
* @param config - Collection configuration
|
|
195
|
+
* @param collectionFetcher - Optional function to fetch collections for embedded references
|
|
196
|
+
*/
|
|
197
|
+
declare function processSchema(collection: DataCollection, config: CollectionConfig, collectionFetcher?: CollectionFetcher): Promise<ProcessedSchema>;
|
|
198
|
+
|
|
199
|
+
type ItemsClient = BuildDescriptors<typeof items, {}>;
|
|
200
|
+
type CollectionsClient = BuildDescriptors<typeof collections, {}>;
|
|
201
|
+
/**
|
|
202
|
+
* Wix Data Service interface
|
|
203
|
+
*
|
|
204
|
+
* Provides access to Wix Data APIs, configuration, and cached schemas.
|
|
205
|
+
*/
|
|
206
|
+
interface WixDataService {
|
|
207
|
+
/** Wix Data Items API client */
|
|
208
|
+
items: ItemsClient;
|
|
209
|
+
/** Wix Data Collections API client */
|
|
210
|
+
collections: CollectionsClient;
|
|
211
|
+
/** Plugin configuration */
|
|
212
|
+
config: WixDataConfig;
|
|
213
|
+
/**
|
|
214
|
+
* Get configuration for a specific collection
|
|
215
|
+
*/
|
|
216
|
+
getCollectionConfig(collectionId: string): CollectionConfig | undefined;
|
|
217
|
+
/**
|
|
218
|
+
* Get DataCollection from Wix API (cached)
|
|
219
|
+
*/
|
|
220
|
+
getCollection(collectionId: string): Promise<DataCollection | null>;
|
|
221
|
+
/**
|
|
222
|
+
* Get processed schema for a collection (cached)
|
|
223
|
+
* Returns null if collection not found
|
|
224
|
+
*/
|
|
225
|
+
getProcessedSchema(collectionId: string): Promise<ProcessedSchema | null>;
|
|
226
|
+
/**
|
|
227
|
+
* Get all processed schemas for collections matching a filter
|
|
228
|
+
*/
|
|
229
|
+
getProcessedSchemas(filter: (config: CollectionConfig) => boolean): Promise<ProcessedSchema[]>;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Server service marker for Wix Data.
|
|
233
|
+
* Use with `.withServices(WIX_DATA_SERVICE_MARKER)` in component definitions.
|
|
234
|
+
*/
|
|
235
|
+
declare const WIX_DATA_SERVICE_MARKER: _jay_framework_fullstack_component.ServiceMarker<WixDataService>;
|
|
236
|
+
/**
|
|
237
|
+
* Creates, registers, and returns a Wix Data service instance.
|
|
238
|
+
* Called during server initialization.
|
|
239
|
+
*
|
|
240
|
+
* @param wixClient - Authenticated Wix SDK client
|
|
241
|
+
* @param config - Plugin configuration
|
|
242
|
+
*/
|
|
243
|
+
declare function provideWixDataService(wixClient: WixClient, config: WixDataConfig): WixDataService;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Data passed from server to client during initialization
|
|
247
|
+
*/
|
|
248
|
+
interface WixDataInitData {
|
|
249
|
+
/** Collection IDs that are configured */
|
|
250
|
+
collections: string[];
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Client-side Wix Data context interface
|
|
254
|
+
* Exposes the Wix Data items API directly
|
|
255
|
+
*/
|
|
256
|
+
interface WixDataContext {
|
|
257
|
+
/** Wix Data Items API client */
|
|
258
|
+
items: typeof items;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Client context marker for Wix Data
|
|
262
|
+
*/
|
|
263
|
+
declare const WIX_DATA_CONTEXT: _jay_framework_runtime.ContextMarker<WixDataContext>;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* URL parameters for item page routes
|
|
267
|
+
* Supports dynamic routing like /blog/[slug]
|
|
268
|
+
*/
|
|
269
|
+
interface ItemPageParams extends UrlParams {
|
|
270
|
+
slug: string;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Data carried forward from slow to fast rendering
|
|
274
|
+
*/
|
|
275
|
+
interface ItemSlowCarryForward {
|
|
276
|
+
itemId: string;
|
|
277
|
+
collectionId: string;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Metadata from dynamic contract generator
|
|
281
|
+
*/
|
|
282
|
+
interface WixDataMetadata$3 {
|
|
283
|
+
collectionId: string;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Collection Item Full-Stack Component
|
|
287
|
+
*
|
|
288
|
+
* A shared headless component for item pages.
|
|
289
|
+
* Used by all collections that have itemPage: true in config.
|
|
290
|
+
*
|
|
291
|
+
* The component receives contract info via props (DynamicContractProps)
|
|
292
|
+
* to determine which collection to query.
|
|
293
|
+
*/
|
|
294
|
+
declare const collectionItem: _jay_framework_fullstack_component.JayStackComponentDefinition<object, object, object, object, [ItemSlowCarryForward, WixDataService], [], PageProps & DynamicContractProps<WixDataMetadata$3> & ItemPageParams, ItemPageParams, _jay_framework_component.JayComponentCore<PageProps & DynamicContractProps<WixDataMetadata$3> & ItemPageParams, object>> & {
|
|
295
|
+
withFastRender<NewCarryForward extends object>(fastRender: _jay_framework_fullstack_component.RenderFast<[ItemSlowCarryForward, WixDataService], PageProps & DynamicContractProps<WixDataMetadata$3> & ItemPageParams, object, NewCarryForward>): _jay_framework_fullstack_component.JayStackComponentDefinition<object, object, object, object, [ItemSlowCarryForward, WixDataService], [object, NewCarryForward], PageProps & DynamicContractProps<WixDataMetadata$3> & ItemPageParams, ItemPageParams, _jay_framework_component.JayComponentCore<PageProps & DynamicContractProps<WixDataMetadata$3> & ItemPageParams, object>> & {
|
|
296
|
+
withClientDefaults(fn: (props: PageProps & DynamicContractProps<WixDataMetadata$3> & ItemPageParams) => {
|
|
297
|
+
viewState: object;
|
|
298
|
+
carryForward?: any;
|
|
299
|
+
}): _jay_framework_fullstack_component.JayStackComponentDefinition<object, object, object, object, [ItemSlowCarryForward, WixDataService], [object, NewCarryForward], PageProps & DynamicContractProps<WixDataMetadata$3> & ItemPageParams, ItemPageParams, _jay_framework_component.JayComponentCore<PageProps & DynamicContractProps<WixDataMetadata$3> & ItemPageParams, object>> & /*elided*/ any;
|
|
300
|
+
withInteractive(comp: _jay_framework_component.ComponentConstructor<PageProps & DynamicContractProps<WixDataMetadata$3> & ItemPageParams, object, object, [object, NewCarryForward], _jay_framework_component.JayComponentCore<PageProps & DynamicContractProps<WixDataMetadata$3> & ItemPageParams, object>>): _jay_framework_fullstack_component.JayStackComponentDefinition<object, object, object, object, [ItemSlowCarryForward, WixDataService], [object, NewCarryForward], PageProps & DynamicContractProps<WixDataMetadata$3> & ItemPageParams, ItemPageParams, _jay_framework_component.JayComponentCore<PageProps & DynamicContractProps<WixDataMetadata$3> & ItemPageParams, object>>;
|
|
301
|
+
};
|
|
302
|
+
withInteractive(comp: _jay_framework_component.ComponentConstructor<PageProps & DynamicContractProps<WixDataMetadata$3> & ItemPageParams, object, object, [], _jay_framework_component.JayComponentCore<PageProps & DynamicContractProps<WixDataMetadata$3> & ItemPageParams, object>>): _jay_framework_fullstack_component.JayStackComponentDefinition<object, object, object, object, [ItemSlowCarryForward, WixDataService], [], PageProps & DynamicContractProps<WixDataMetadata$3> & ItemPageParams, ItemPageParams, _jay_framework_component.JayComponentCore<PageProps & DynamicContractProps<WixDataMetadata$3> & ItemPageParams, object>>;
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* URL parameters for list page routes
|
|
307
|
+
* Optional category slug for category pages
|
|
308
|
+
*/
|
|
309
|
+
interface ListPageParams extends UrlParams {
|
|
310
|
+
category?: string;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Data carried forward from slow to fast rendering
|
|
314
|
+
*/
|
|
315
|
+
interface ListSlowCarryForward {
|
|
316
|
+
collectionId: string;
|
|
317
|
+
categoryId?: string;
|
|
318
|
+
categoryField?: string;
|
|
319
|
+
/** Current offset (number of items already loaded) */
|
|
320
|
+
offset: number;
|
|
321
|
+
totalCount: number;
|
|
322
|
+
pathPrefix: string;
|
|
323
|
+
slugField: string;
|
|
324
|
+
/** Field whitelist - undefined means all fields */
|
|
325
|
+
fieldWhitelist?: string[];
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Data carried forward from fast to interactive
|
|
329
|
+
*/
|
|
330
|
+
interface ListFastCarryForward {
|
|
331
|
+
collectionId: string;
|
|
332
|
+
categoryId?: string;
|
|
333
|
+
categoryField?: string;
|
|
334
|
+
/** Current offset (number of items already loaded) */
|
|
335
|
+
offset: number;
|
|
336
|
+
totalCount: number;
|
|
337
|
+
pathPrefix: string;
|
|
338
|
+
slugField: string;
|
|
339
|
+
/** Field whitelist - undefined means all fields */
|
|
340
|
+
fieldWhitelist?: string[];
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Metadata from dynamic contract generator
|
|
344
|
+
*/
|
|
345
|
+
interface WixDataMetadata$2 {
|
|
346
|
+
collectionId: string;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Collection List Full-Stack Component
|
|
350
|
+
*
|
|
351
|
+
* A shared headless component for list pages (index and category).
|
|
352
|
+
* Used by all collections that have indexPage or categoryPage: true in config.
|
|
353
|
+
*
|
|
354
|
+
* Uses queryItems action for client-side "load more" functionality.
|
|
355
|
+
*/
|
|
356
|
+
declare const collectionList: _jay_framework_fullstack_component.JayStackComponentDefinition<object, object, object, object, [ListSlowCarryForward, WixDataService], [object, ListFastCarryForward], PageProps & DynamicContractProps<WixDataMetadata$2> & ListPageParams, ListPageParams, _jay_framework_component.JayComponentCore<PageProps & DynamicContractProps<WixDataMetadata$2> & ListPageParams, object>>;
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Props for table widget
|
|
360
|
+
*/
|
|
361
|
+
interface TableWidgetProps extends PageProps {
|
|
362
|
+
pageSize?: number;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Data carried forward from slow to fast rendering
|
|
366
|
+
*/
|
|
367
|
+
interface TableSlowCarryForward {
|
|
368
|
+
collectionId: string;
|
|
369
|
+
columns: string[];
|
|
370
|
+
pageSize: number;
|
|
371
|
+
totalCount: number;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Data carried forward from fast to interactive
|
|
375
|
+
*/
|
|
376
|
+
interface TableFastCarryForward {
|
|
377
|
+
collectionId: string;
|
|
378
|
+
columns: string[];
|
|
379
|
+
pageSize: number;
|
|
380
|
+
totalCount: number;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Metadata from dynamic contract generator
|
|
384
|
+
*/
|
|
385
|
+
interface WixDataMetadata$1 {
|
|
386
|
+
collectionId: string;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Collection Table Full-Stack Component
|
|
390
|
+
*
|
|
391
|
+
* A shared headless component for table widgets.
|
|
392
|
+
* Provides sortable columns and pagination.
|
|
393
|
+
*/
|
|
394
|
+
declare const collectionTable: _jay_framework_fullstack_component.JayStackComponentDefinition<object, object, object, object, [TableSlowCarryForward, WixDataService], [object, TableFastCarryForward, WixDataContext], TableWidgetProps & DynamicContractProps<WixDataMetadata$1>, {}, _jay_framework_component.JayComponentCore<TableWidgetProps & DynamicContractProps<WixDataMetadata$1>, object>>;
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Props for card widget
|
|
398
|
+
*/
|
|
399
|
+
interface CardWidgetProps extends PageProps {
|
|
400
|
+
/** Item ID to display */
|
|
401
|
+
itemId?: string;
|
|
402
|
+
/** Item slug to display (alternative to itemId) */
|
|
403
|
+
slug?: string;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Data carried forward
|
|
407
|
+
*/
|
|
408
|
+
interface CardCarryForward {
|
|
409
|
+
itemId: string;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Metadata from dynamic contract generator
|
|
413
|
+
*/
|
|
414
|
+
interface WixDataMetadata {
|
|
415
|
+
collectionId: string;
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Collection Card Full-Stack Component
|
|
419
|
+
*
|
|
420
|
+
* A shared headless component for card widgets.
|
|
421
|
+
* Displays a single item from a collection in a card format.
|
|
422
|
+
*
|
|
423
|
+
* Usage:
|
|
424
|
+
* ```html
|
|
425
|
+
* <script type="application/jay-headless"
|
|
426
|
+
* plugin="@jay-framework/wix-data"
|
|
427
|
+
* contract="card/BlogPostsCard"
|
|
428
|
+
* key="featuredPost"
|
|
429
|
+
* itemId="abc123"
|
|
430
|
+
* ></script>
|
|
431
|
+
* ```
|
|
432
|
+
*/
|
|
433
|
+
declare const collectionCard: _jay_framework_fullstack_component.JayStackComponentDefinition<object, object, object, object, [CardCarryForward, WixDataService], [], CardWidgetProps & DynamicContractProps<WixDataMetadata>, {}, _jay_framework_component.JayComponentCore<CardWidgetProps & DynamicContractProps<WixDataMetadata>, object>> & {
|
|
434
|
+
withFastRender<NewCarryForward extends object>(fastRender: _jay_framework_fullstack_component.RenderFast<[CardCarryForward, WixDataService], CardWidgetProps & DynamicContractProps<WixDataMetadata>, object, NewCarryForward>): _jay_framework_fullstack_component.JayStackComponentDefinition<object, object, object, object, [CardCarryForward, WixDataService], [object, NewCarryForward], CardWidgetProps & DynamicContractProps<WixDataMetadata>, {}, _jay_framework_component.JayComponentCore<CardWidgetProps & DynamicContractProps<WixDataMetadata>, object>> & {
|
|
435
|
+
withClientDefaults(fn: (props: CardWidgetProps & DynamicContractProps<WixDataMetadata>) => {
|
|
436
|
+
viewState: object;
|
|
437
|
+
carryForward?: any;
|
|
438
|
+
}): _jay_framework_fullstack_component.JayStackComponentDefinition<object, object, object, object, [CardCarryForward, WixDataService], [object, NewCarryForward], CardWidgetProps & DynamicContractProps<WixDataMetadata>, {}, _jay_framework_component.JayComponentCore<CardWidgetProps & DynamicContractProps<WixDataMetadata>, object>> & /*elided*/ any;
|
|
439
|
+
withInteractive(comp: _jay_framework_component.ComponentConstructor<CardWidgetProps & DynamicContractProps<WixDataMetadata>, object, object, [object, NewCarryForward], _jay_framework_component.JayComponentCore<CardWidgetProps & DynamicContractProps<WixDataMetadata>, object>>): _jay_framework_fullstack_component.JayStackComponentDefinition<object, object, object, object, [CardCarryForward, WixDataService], [object, NewCarryForward], CardWidgetProps & DynamicContractProps<WixDataMetadata>, {}, _jay_framework_component.JayComponentCore<CardWidgetProps & DynamicContractProps<WixDataMetadata>, object>>;
|
|
440
|
+
};
|
|
441
|
+
withInteractive(comp: _jay_framework_component.ComponentConstructor<CardWidgetProps & DynamicContractProps<WixDataMetadata>, object, object, [], _jay_framework_component.JayComponentCore<CardWidgetProps & DynamicContractProps<WixDataMetadata>, object>>): _jay_framework_fullstack_component.JayStackComponentDefinition<object, object, object, object, [CardCarryForward, WixDataService], [], CardWidgetProps & DynamicContractProps<WixDataMetadata>, {}, _jay_framework_component.JayComponentCore<CardWidgetProps & DynamicContractProps<WixDataMetadata>, object>>;
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Input for queryItems action
|
|
446
|
+
*/
|
|
447
|
+
interface QueryItemsInput {
|
|
448
|
+
/** Collection ID to query */
|
|
449
|
+
collectionId: string;
|
|
450
|
+
/** Maximum number of items to return (default: 20) */
|
|
451
|
+
limit?: number;
|
|
452
|
+
/** Number of items to skip (for pagination) */
|
|
453
|
+
offset?: number;
|
|
454
|
+
/** Field to sort by */
|
|
455
|
+
sortField?: string;
|
|
456
|
+
/** Sort direction */
|
|
457
|
+
sortDirection?: 'ASC' | 'DESC';
|
|
458
|
+
/** Filter conditions (field -> value) */
|
|
459
|
+
filter?: Record<string, unknown>;
|
|
460
|
+
/** Filter by category ID (for hasSome query on category field) */
|
|
461
|
+
categoryId?: string;
|
|
462
|
+
/** Category reference field name (required if categoryId is provided) */
|
|
463
|
+
categoryField?: string;
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Output for queryItems action
|
|
467
|
+
*/
|
|
468
|
+
interface QueryItemsOutput {
|
|
469
|
+
/** List of items */
|
|
470
|
+
items: WixDataItem[];
|
|
471
|
+
/** Total number of items matching query */
|
|
472
|
+
totalCount: number;
|
|
473
|
+
/** Current offset */
|
|
474
|
+
offset: number;
|
|
475
|
+
/** Whether there are more results */
|
|
476
|
+
hasMore: boolean;
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Input for getItemBySlug action
|
|
480
|
+
*/
|
|
481
|
+
interface GetItemBySlugInput {
|
|
482
|
+
/** Collection ID */
|
|
483
|
+
collectionId: string;
|
|
484
|
+
/** Item slug value */
|
|
485
|
+
slug: string;
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Output for getItemBySlug action
|
|
489
|
+
*/
|
|
490
|
+
interface GetItemBySlugOutput {
|
|
491
|
+
/** Item data (flat object with _id and all fields), or null if not found */
|
|
492
|
+
item: WixDataItem | null;
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Input for getCategories action
|
|
496
|
+
*/
|
|
497
|
+
interface GetCategoriesInput {
|
|
498
|
+
/** Collection ID that has category references */
|
|
499
|
+
collectionId: string;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Category item
|
|
503
|
+
*/
|
|
504
|
+
interface CategoryItem {
|
|
505
|
+
_id: string;
|
|
506
|
+
slug: string;
|
|
507
|
+
title: string;
|
|
508
|
+
itemCount: number;
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Output for getCategories action
|
|
512
|
+
*/
|
|
513
|
+
interface GetCategoriesOutput {
|
|
514
|
+
/** List of categories */
|
|
515
|
+
categories: CategoryItem[];
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Query items from a collection.
|
|
519
|
+
*
|
|
520
|
+
* Supports pagination, sorting, and filtering.
|
|
521
|
+
*
|
|
522
|
+
* @example
|
|
523
|
+
* ```typescript
|
|
524
|
+
* const results = await queryItems({
|
|
525
|
+
* collectionId: 'BlogPosts',
|
|
526
|
+
* limit: 20,
|
|
527
|
+
* sortField: 'publishDate',
|
|
528
|
+
* sortDirection: 'DESC',
|
|
529
|
+
* filter: { status: 'published' }
|
|
530
|
+
* });
|
|
531
|
+
* ```
|
|
532
|
+
*/
|
|
533
|
+
declare const queryItems: _jay_framework_fullstack_component.JayAction<QueryItemsInput, QueryItemsOutput> & _jay_framework_fullstack_component.JayActionDefinition<QueryItemsInput, QueryItemsOutput, [WixDataService]>;
|
|
534
|
+
/**
|
|
535
|
+
* Get a single item by its slug.
|
|
536
|
+
*
|
|
537
|
+
* Uses the slugField configured for the collection.
|
|
538
|
+
*
|
|
539
|
+
* @example
|
|
540
|
+
* ```typescript
|
|
541
|
+
* const result = await getItemBySlug({
|
|
542
|
+
* collectionId: 'BlogPosts',
|
|
543
|
+
* slug: 'my-first-post'
|
|
544
|
+
* });
|
|
545
|
+
* ```
|
|
546
|
+
*/
|
|
547
|
+
declare const getItemBySlug: _jay_framework_fullstack_component.JayAction<GetItemBySlugInput, GetItemBySlugOutput> & _jay_framework_fullstack_component.JayActionDefinition<GetItemBySlugInput, GetItemBySlugOutput, [WixDataService]>;
|
|
548
|
+
/**
|
|
549
|
+
* Get categories for a collection.
|
|
550
|
+
*
|
|
551
|
+
* Returns distinct category values from the configured category reference field.
|
|
552
|
+
*
|
|
553
|
+
* @example
|
|
554
|
+
* ```typescript
|
|
555
|
+
* const result = await getCategories({
|
|
556
|
+
* collectionId: 'BlogPosts'
|
|
557
|
+
* });
|
|
558
|
+
* // Returns: { categories: [{ _id: '...', slug: 'tech', title: 'Technology', itemCount: 15 }, ...] }
|
|
559
|
+
* ```
|
|
560
|
+
*/
|
|
561
|
+
declare const getCategories: _jay_framework_fullstack_component.JayAction<GetCategoriesInput, GetCategoriesOutput> & _jay_framework_fullstack_component.JayActionDefinition<GetCategoriesInput, GetCategoriesOutput, [WixDataService]>;
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Contract Generation Utilities
|
|
565
|
+
*
|
|
566
|
+
* Shared building blocks for contract YAML generation.
|
|
567
|
+
*/
|
|
568
|
+
|
|
569
|
+
/** Filter for fields suitable for card/list display (excludes system, references, rich content) */
|
|
570
|
+
declare function isCardField(f: ProcessedField): boolean;
|
|
571
|
+
/** Filter for simple fields suitable for table display */
|
|
572
|
+
declare function isTableField(f: ProcessedField): boolean;
|
|
573
|
+
/** Filter for non-system fields */
|
|
574
|
+
declare function isContentField(f: ProcessedField): boolean;
|
|
575
|
+
declare function toPascalCase(str: string): string;
|
|
576
|
+
|
|
577
|
+
declare const init: _jay_framework_fullstack_component.JayInit<WixDataInitData>;
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* Setup and references handlers for wix-data plugin (Design Log #87).
|
|
581
|
+
*
|
|
582
|
+
* Setup: Validates wix-server-client is configured; config auto-generated during init.
|
|
583
|
+
* References: Generates collection schema data for agent discovery.
|
|
584
|
+
*/
|
|
585
|
+
|
|
586
|
+
declare function setupWixData(ctx: PluginSetupContext): Promise<PluginSetupResult>;
|
|
587
|
+
declare function generateWixDataReferences(ctx: PluginReferencesContext): Promise<PluginReferencesResult>;
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Item Contract Generator
|
|
591
|
+
*
|
|
592
|
+
* Generates contracts for item pages from Wix Data collection schemas.
|
|
593
|
+
*/
|
|
594
|
+
/**
|
|
595
|
+
* Generator for item page contracts.
|
|
596
|
+
* Creates one contract per visible collection that has itemPage: true in config.
|
|
597
|
+
*/
|
|
598
|
+
declare const generator$3: _jay_framework_fullstack_component.DynamicContractGenerator<[WixDataService]>;
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* List Contract Generator
|
|
602
|
+
*
|
|
603
|
+
* Generates contracts for list pages (index and category) from Wix Data collection schemas.
|
|
604
|
+
*/
|
|
605
|
+
/**
|
|
606
|
+
* Generator for list page contracts.
|
|
607
|
+
* Creates one contract per visible collection that has indexPage or categoryPage enabled.
|
|
608
|
+
*/
|
|
609
|
+
declare const generator$2: _jay_framework_fullstack_component.DynamicContractGenerator<[WixDataService]>;
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Table Contract Generator
|
|
613
|
+
*
|
|
614
|
+
* Generates contracts for table widgets from Wix Data collection schemas.
|
|
615
|
+
*/
|
|
616
|
+
/**
|
|
617
|
+
* Generator for table widget contracts.
|
|
618
|
+
* Creates one contract per visible collection that has tableWidget: true in config.
|
|
619
|
+
*/
|
|
620
|
+
declare const generator$1: _jay_framework_fullstack_component.DynamicContractGenerator<[WixDataService]>;
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* Card Contract Generator
|
|
624
|
+
*
|
|
625
|
+
* Generates contracts for card widgets from Wix Data collection schemas.
|
|
626
|
+
*/
|
|
627
|
+
/**
|
|
628
|
+
* Generator for card widget contracts.
|
|
629
|
+
* Creates one contract per visible collection that has cardWidget: true in config.
|
|
630
|
+
*/
|
|
631
|
+
declare const generator: _jay_framework_fullstack_component.DynamicContractGenerator<[WixDataService]>;
|
|
632
|
+
|
|
633
|
+
export { type CategoryConfig, type CategoryItem, type CollectionConfig, type CollectionFetcher, type CollectionSchema, type ComponentsConfig, type FieldSchema, type GetCategoriesInput, type GetCategoriesOutput, type GetItemBySlugInput, type GetItemBySlugOutput, type ProcessedField, type ProcessedSchema, type QueryItemsInput, type QueryItemsOutput, type ReferenceConfig, type ResolvedWixDataConfig, WIX_DATA_CONTEXT, WIX_DATA_SERVICE_MARKER, type WixDataConfig, type WixDataContext, type WixDataFieldType, type WixDataInitData, type WixDataService, generator as cardContractGenerator, collectionCard, collectionItem, collectionList, collectionTable, generateWixDataReferences, getCategories, getItemBySlug, getVisibleCollections, init, isCardField, isContentField, isTableField, generator$3 as itemContractGenerator, generator$2 as listContractGenerator, loadConfig, processSchema, provideWixDataService, queryItems, setupWixData, generator$1 as tableContractGenerator, toPascalCase, validateCollectionConfig, validateConfig };
|