@plasmicpkgs/wordpress 0.0.10 → 0.0.12
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/dist/index.d.ts +76 -3
- package/dist/index.esm.js +467 -25
- package/dist/index.esm.js.map +3 -3
- package/dist/index.js +465 -25
- package/dist/index.js.map +3 -3
- package/package.json +5 -3
package/dist/index.esm.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/index.ts", "../src/utils.ts", "../src/query-wordpress.ts"],
|
|
4
|
-
"sourcesContent": ["import registerFunction, {\n CustomFunctionMeta,\n} from \"@plasmicapp/host/registerFunction\";\nimport { queryWordpress, queryWordpressMeta } from \"./query-wordpress\";\n\nexport function registerWordpress(loader?: { registerFunction: any }) {\n function _registerFunction<T extends (...args: any[]) => any>(\n fn: T,\n meta: CustomFunctionMeta<T>\n ) {\n if (loader) {\n loader.registerFunction(fn, meta);\n } else {\n registerFunction(fn, meta);\n }\n }\n\n _registerFunction(queryWordpress, queryWordpressMeta);\n}\n\nexport { queryWordpress };\n\n// used by @plasmicpkgs/plasmic-wordpress\nexport { ensure as _ensure, queryOperators as _queryOperators } from \"./utils\";\nexport type { QueryOperator as _QueryOperator } from \"./utils\";\n", "export const queryOperators = [\n {\n value: \"search\",\n label: \"Search\",\n },\n {\n value: \"slug\",\n label: \"Filter by Slug\",\n },\n {\n value: \"author\",\n label: \"Filter by author\",\n },\n] as const;\n\nexport type QueryOperator = (typeof queryOperators)[number][\"value\"];\n\nexport function ensure<T>(x: T | null | undefined, message?: string): T {\n if (x === null || x === undefined) {\n debugger;\n throw new Error(message ?? `Value must not be undefined or null`);\n } else {\n return x;\n }\n}\n", "import { CustomFunctionMeta } from \"@plasmicapp/host/registerFunction\";\nimport { QueryOperator, queryOperators } from \"./utils\";\n\nexport interface QueryWordpressOpts {\n wordpressUrl?: string;\n queryType?: \"pages\" | \"posts\";\n queryOperator?: QueryOperator;\n filterValue?: string;\n limit?: number;\n}\n\nexport async function queryWordpress({\n wordpressUrl,\n queryType,\n queryOperator,\n filterValue,\n limit,\n}: QueryWordpressOpts): Promise<any> {\n if (!wordpressUrl || !queryType) {\n throw new Error(\"Wordpress URL and query type are required\");\n }\n const urlParams = new URLSearchParams();\n if (queryOperator && filterValue) {\n urlParams.append(queryOperator, filterValue);\n }\n if (limit) {\n urlParams.append(\"per_page\", limit.toString());\n }\n const urlWithSlash = wordpressUrl.endsWith(\"/\")\n ? wordpressUrl\n : `${wordpressUrl}/`;\n const url = new URL(`wp-json/wp/v2/${queryType}`, urlWithSlash);\n url.search = urlParams.toString();\n\n const resp = await fetch(url);\n return await resp.json();\n}\n\nexport const queryWordpressMeta: CustomFunctionMeta<typeof queryWordpress> = {\n name: \"queryWordpress\",\n displayName: \"Query WordPress\",\n importPath: \"@plasmicpkgs/wordpress\",\n params: [\n {\n name: \"opts\",\n type: \"object\",\n display: \"flatten\",\n fields: {\n wordpressUrl: {\n type: \"string\",\n },\n queryType: {\n type: \"choice\",\n options: [\"pages\", \"posts\"],\n },\n queryOperator: {\n type: \"choice\",\n options: Object.values(queryOperators).map((item) => ({\n label: item.label,\n value: item.value,\n })),\n },\n filterValue: {\n type: \"string\",\n },\n limit: {\n type: \"number\",\n },\n },\n },\n ],\n};\n"],
|
|
5
|
-
"mappings": "
|
|
3
|
+
"sources": ["../src/index.ts", "../src/utils.ts", "../src/where.ts", "../src/query-wordpress.ts"],
|
|
4
|
+
"sourcesContent": ["import registerFunction, {\n CustomFunctionMeta,\n} from \"@plasmicapp/host/registerFunction\";\nimport {\n _queryWordpress,\n queryWordpress,\n queryWordpressMeta,\n} from \"./query-wordpress\";\n\nexport function registerWordpress(loader?: { registerFunction: any }) {\n function _registerFunction<T extends (...args: any[]) => any>(\n fn: T,\n meta: CustomFunctionMeta<T>\n ) {\n if (loader) {\n loader.registerFunction(fn, meta);\n } else {\n registerFunction(fn, meta);\n }\n }\n\n _registerFunction(queryWordpress, queryWordpressMeta);\n}\n\nexport {\n // used by @plasmicpkgs/plasmic-wordpress\n _queryWordpress,\n queryWordpress,\n};\n\n// used by @plasmicpkgs/plasmic-wordpress\nexport { ensure as _ensure, queryOperators as _queryOperators } from \"./utils\";\nexport type { QueryOperator as _QueryOperator } from \"./utils\";\n", "export const queryOperators = [\n {\n value: \"search\",\n label: \"Search\",\n },\n {\n value: \"slug\",\n label: \"Filter by Slug\",\n },\n {\n value: \"author\",\n label: \"Filter by author\",\n },\n] as const;\n\nexport type QueryOperator = (typeof queryOperators)[number][\"value\"];\n\nexport function ensure<T>(x: T | null | undefined, message?: string): T {\n if (x === null || x === undefined) {\n debugger;\n throw new Error(message ?? `Value must not be undefined or null`);\n } else {\n return x;\n }\n}\n\nexport function cleanUrl(url: string): string {\n return url.replace(/\\/$/, \"\");\n}\n", "import type {\n Config,\n Field,\n ListItem,\n} from \"@react-awesome-query-builder/core\";\nimport type { RulesLogic } from \"json-logic-js\";\nimport { cleanUrl } from \"./utils\";\n\n/**\n * Predefined field configuration for WordPress Posts\n */\nexport const WORDPRESS_POST_FIELDS: Record<string, Field> = {\n id: {\n type: \"number\",\n label: \"ID\",\n operators: [\"equal\", \"not_equal\"],\n },\n date: {\n type: \"datetime\",\n label: \"Published Date\",\n operators: [\"less\", \"greater\"],\n defaultOperator: \"greater\", // this prevents \"equals\" operator from being shown by default\n },\n modified: {\n type: \"datetime\",\n label: \"Modified Date\",\n operators: [\"less\", \"greater\"],\n defaultOperator: \"greater\",\n },\n slug: {\n type: \"text\",\n label: \"Slug\",\n operators: [\"equal\"],\n },\n author: {\n type: \"number\",\n label: \"Author ID\",\n operators: [\"equal\", \"not_equal\"],\n },\n categories: {\n type: \"multiselect\",\n label: \"Category\",\n operators: [\"multiselect_contains\", \"multiselect_not_contains\"],\n defaultOperator: \"multiselect_contains\",\n fieldSettings: {\n listValues: [], // Will be populated dynamically\n },\n },\n tags: {\n type: \"multiselect\",\n label: \"Tag\",\n operators: [\"multiselect_contains\", \"multiselect_not_contains\"],\n defaultOperator: \"multiselect_contains\",\n fieldSettings: {\n listValues: [], // Will be populated dynamically\n },\n },\n sticky: {\n type: \"boolean\",\n label: \"Sticky\",\n operators: [\"equal\"],\n },\n search: {\n type: \"text\",\n label: \"Search\",\n operators: [\"equal\"],\n },\n search_columns: {\n type: \"multiselect\",\n label: \"Search Columns\",\n operators: [\"multiselect_contains\"],\n defaultOperator: \"multiselect_contains\",\n fieldSettings: {\n listValues: [\"post_title\", \"post_content\", \"post_excerpt\"],\n },\n },\n};\n\n/**\n * Predefined field configuration for WordPress Pages\n */\nexport const WORDPRESS_PAGE_FIELDS: Record<string, Field> = {\n id: WORDPRESS_POST_FIELDS.id,\n date: WORDPRESS_POST_FIELDS.date,\n modified: WORDPRESS_POST_FIELDS.modified,\n slug: WORDPRESS_POST_FIELDS.slug,\n author: WORDPRESS_POST_FIELDS.author,\n search: WORDPRESS_POST_FIELDS.search,\n search_columns: WORDPRESS_POST_FIELDS.search_columns,\n // Page-specific fields\n parent: {\n type: \"number\",\n label: \"Parent Page\",\n operators: [\"equal\", \"not_equal\"],\n },\n menu_order: {\n type: \"number\",\n label: \"Menu Order\",\n operators: [\"equal\"],\n },\n};\n\n/**\n * Fetch categories for multiselect dropdown to allow filtering by category\n */\nexport async function fetchCategories(\n wordpressUrl: string\n): Promise<Array<ListItem>> {\n try {\n const url = `${cleanUrl(\n wordpressUrl\n )}/wp-json/wp/v2/categories?per_page=100`;\n const resp = await fetch(url);\n if (!resp.ok) {\n return [];\n }\n\n const categories = await resp.json();\n const formatted = categories.map((cat: any) => ({\n value: cat.id,\n title: cat.name,\n }));\n\n return formatted;\n } catch (error) {\n console.error(\"Failed to fetch WordPress categories:\", error);\n return [];\n }\n}\n\n/**\n * Fetch tags for multiselect dropdown to allow filtering by tag\n */\nexport async function fetchTags(\n wordpressUrl: string\n): Promise<Array<ListItem>> {\n try {\n const url = `${cleanUrl(wordpressUrl)}/wp-json/wp/v2/tags?per_page=100`;\n const resp = await fetch(url);\n if (!resp.ok) {\n return [];\n }\n\n const tags = await resp.json();\n const formatted = tags.map((tag: any) => ({\n value: tag.id,\n title: tag.name,\n }));\n\n return formatted;\n } catch (error) {\n console.error(\"Failed to fetch WordPress tags:\", error);\n return [];\n }\n}\n\n/**\n * Build complete query builder configuration for WordPress\n */\nexport function buildWordPressConfig(\n queryType: \"posts\" | \"pages\",\n categories?: Array<{ value: number; title: string }>,\n tags?: Array<{ value: number; title: string }>\n): {\n fields: Config[\"fields\"];\n conjunctions: { AND: { label: string } };\n settings: { showNot: boolean; maxNesting: number };\n} {\n const fields =\n queryType === \"posts\"\n ? { ...WORDPRESS_POST_FIELDS }\n : { ...WORDPRESS_PAGE_FIELDS };\n\n if (queryType === \"posts\" && categories && tags) {\n fields.categories = {\n ...fields.categories,\n fieldSettings: { listValues: categories },\n };\n\n fields.tags = {\n ...fields.tags,\n fieldSettings: { listValues: tags },\n };\n }\n\n return {\n fields,\n\n // WordPress REST API doesn't support OR logic natively\n // Limit to AND-only combinations\n conjunctions: {\n AND: { label: \"AND\" },\n },\n settings: {\n showNot: false,\n // hides group controls (we don't want to support nested groups, because the only supported conjunction is AND)\n maxNesting: 1,\n },\n };\n}\n\nexport interface WordPressFilters {\n // Common\n search?: string;\n slug?: string;\n include?: number[];\n exclude?: number[];\n // Pagination\n page?: number;\n per_page?: number;\n offset?: number;\n // Ordering\n order?: \"asc\" | \"desc\";\n orderby?: string;\n // Posts-specific\n author?: number | number[];\n author_exclude?: number[];\n categories?: number[];\n tags?: number[];\n before?: string;\n after?: string;\n modified_before?: string;\n modified_after?: string;\n sticky?: boolean;\n // Pages-specific\n parent?: number[];\n parent_exclude?: number[];\n menu_order?: number;\n}\n\n/**\n * Convert RAQB JsonLogic to WordPress REST API query parameters\n */\nexport function rulesLogicToWordPressFilters(\n logic: RulesLogic | undefined\n): WordPressFilters {\n if (logic === null || logic === undefined) {\n return {};\n } else if (typeof logic !== \"object\") {\n throw new Error(`unexpected logic: ${JSON.stringify(logic)}`);\n } else if (\"and\" in logic) {\n return handleAndGroup(logic.and);\n }\n\n return handleCondition(logic);\n}\n\nfunction handleAndGroup(conditions: any[]): WordPressFilters {\n const filters: WordPressFilters = {};\n\n for (const condition of conditions) {\n const result = handleCondition(condition);\n Object.assign(filters, result);\n }\n\n return filters;\n}\n\nfunction handleCondition(condition: any, negated = false): WordPressFilters {\n // \"some\" clause generated by the multiselect operator (used for categories and tags)\n // Pattern: {\"some\": [{\"var\": \"categories\"}, {\"in\": [{\"var\": \"\"}, values]}]}\n if (\"some\" in condition) {\n const [fieldExpr, inExpr] = condition.some;\n if (\n \"var\" in fieldExpr &&\n \"in\" in inExpr &&\n Array.isArray(inExpr.in) &&\n inExpr.in.length === 2\n ) {\n const field = fieldExpr.var;\n const values = inExpr.in[1];\n return negated\n ? convertNotEqualOperator(field, values)\n : convertEqualOperator(field, values);\n }\n }\n\n if (\"!\" in condition) {\n return handleCondition(condition[\"!\"], true);\n }\n\n if (\"==\" in condition) {\n const [fieldExpr, value] = condition[\"==\"];\n if (\"var\" in fieldExpr) {\n return convertEqualOperator(fieldExpr.var, value);\n }\n }\n\n if (\"!=\" in condition) {\n const [fieldExpr, value] = condition[\"!=\"];\n if (\"var\" in fieldExpr) {\n return convertNotEqualOperator(fieldExpr.var, value);\n }\n }\n\n if (\"<\" in condition) {\n const [fieldExpr, value] = condition[\"<\"];\n if (\"var\" in fieldExpr) {\n return convertLessThanOperator(fieldExpr.var, value);\n }\n }\n\n if (\">\" in condition) {\n const [fieldExpr, right] = condition[\">\"];\n if (\"var\" in fieldExpr) {\n return convertGreaterThanOperator(fieldExpr.var, right);\n }\n }\n\n throw new Error(\n `Unsupported WordPress filter condition: ${JSON.stringify(condition)}`\n );\n}\n\nfunction convertEqualOperator(field: string, value: any): WordPressFilters {\n if (field === \"id\") {\n return { include: value };\n }\n return { [field]: value };\n}\n\nfunction convertNotEqualOperator(field: string, value: any): WordPressFilters {\n if (field === \"id\") {\n return { exclude: value };\n }\n return { [`${field}_exclude`]: value };\n}\n\nfunction convertLessThanOperator(field: string, value: any): WordPressFilters {\n if (field === \"date\") {\n return { before: value };\n }\n if (field === \"modified\") {\n return { modified_before: value };\n }\n console.warn(\n `WordPress: Less than operator not supported for field: ${field}`\n );\n return {};\n}\n\nfunction convertGreaterThanOperator(\n field: string,\n value: any\n): WordPressFilters {\n if (field === \"date\") {\n return { after: value };\n }\n if (field === \"modified\") {\n return { modified_after: value };\n }\n console.warn(\n `WordPress: Greater than operator not supported for field: ${field}`\n );\n return {};\n}\n", "import { CustomFunctionMeta } from \"@plasmicapp/host/registerFunction\";\nimport type { RulesLogic } from \"json-logic-js\";\nimport { cleanUrl, QueryOperator } from \"./utils\";\nimport {\n buildWordPressConfig,\n fetchCategories,\n fetchTags,\n rulesLogicToWordPressFilters,\n type WordPressFilters,\n} from \"./where\";\n\n/**\n * @deprecated These filter props are deprecated. Use `filterLogic` with the query builder instead.\n * Only used by the deprecated plasmic-wordpress package\n */\nexport interface QueryWordpressOldFilterProps {\n queryOperator?: QueryOperator;\n filterValue?: string;\n}\n\nexport interface QueryWordpressOpts {\n wordpressUrl?: string;\n queryType?: \"pages\" | \"posts\";\n\n /**\n * Filter logic using JSON Logic format to filter WordPress entries.\n * See {@link https://www.npmjs.com/package/@types/json-logic-js?activeTab=readme}\n */\n filterLogic?: RulesLogic;\n\n // Pagination\n limit?: number;\n page?: number;\n offset?: number;\n\n // Ordering\n reverseOrder?: boolean;\n orderby?: string;\n}\n\nexport interface QueryWordpressResponse {\n items: any[];\n total: number;\n totalPages: number;\n page: number;\n perPage: number;\n}\n\n/**\n * Query Wordpress with simplified filter props.\n *\n * @deprecated Use {@link queryWordpress} with `filterLogic` parameter instead.\n *\n * @example\n * ```ts\n * // Old way (deprecated)\n * _queryWordpress({\n * wordpressUrl: 'https://example.com',\n * queryType: 'posts',\n * queryOperator: 'status',\n * filterValue: 'publish'\n * });\n *\n * // New way\n * queryWordpress({\n * wordpressUrl: 'https://example.com',\n * queryType: 'posts',\n * filterLogic: { \"==\": [{ var: \"status\" }, \"publish\"] },\n * });\n * ```\n */\nexport async function _queryWordpress(\n opts: QueryWordpressOpts & QueryWordpressOldFilterProps\n): Promise<QueryWordpressResponse> {\n const {\n wordpressUrl,\n queryType,\n queryOperator,\n filterValue,\n filterLogic,\n limit,\n page,\n offset,\n reverseOrder,\n orderby,\n } = opts;\n\n if (!wordpressUrl || !queryType) {\n throw new Error(\"Wordpress URL and query type are required\");\n }\n\n const urlParams = new URLSearchParams();\n\n if (filterLogic) {\n const filters = rulesLogicToWordPressFilters(filterLogic);\n appendFiltersToParams(urlParams, filters);\n }\n // Legacy: Single filter support for backward compatibility (deprecated)\n // @deprecated - Use filterLogic instead\n else if (queryOperator && filterValue) {\n urlParams.append(queryOperator, filterValue);\n }\n\n // Pagination\n if (limit) {\n urlParams.append(\"per_page\", String(Math.min(limit, 100)));\n }\n if (page) {\n urlParams.append(\"page\", String(page));\n }\n if (offset) {\n urlParams.append(\"offset\", String(offset));\n }\n\n // Ordering\n if (reverseOrder) {\n urlParams.append(\"order\", \"asc\");\n }\n if (orderby) {\n urlParams.append(\"orderby\", orderby);\n }\n\n const url = new URL(`wp-json/wp/v2/${queryType}`, cleanUrl(wordpressUrl));\n url.search = urlParams.toString();\n\n const resp = await fetch(url);\n\n if (!resp.ok) {\n const errorText = await resp.text();\n let errorMessage = `WordPress API error (${resp.status})`;\n try {\n const errorJson = JSON.parse(errorText);\n errorMessage = errorJson.message || errorMessage;\n } catch {\n errorMessage += `: ${errorText}`;\n }\n throw new Error(errorMessage);\n }\n\n const items = await resp.json();\n\n // Extract pagination headers\n const total = parseInt(resp.headers.get(\"X-WP-Total\") || \"0\", 10);\n const totalPages = parseInt(resp.headers.get(\"X-WP-TotalPages\") || \"0\", 10);\n\n return {\n items,\n total,\n totalPages,\n page: page || 1,\n perPage: limit || 10,\n };\n}\n\n/**\n * Query WordPress posts or pages with optional filtering, pagination, and ordering.\n *\n * @param opts - Query options including URL, content type, filter logic, pagination, and ordering\n * @returns Promise resolving to the WordPress query response or raw items array for backward compatibility\n *\n * @example\n * ```ts\n * // Fetch all published posts\n * const result = await queryWordpress({\n * wordpressUrl: 'https://example.com',\n * queryType: 'posts'\n * });\n *\n * // Fetch with filters\n * const filtered = await queryWordpress({\n * wordpressUrl: 'https://example.com',\n * queryType: 'posts',\n * filterLogic: { \"==\": [{ var: \"status\" }, \"publish\"] },\n * });\n * ```\n */\nexport async function queryWordpress(\n opts: QueryWordpressOpts\n): Promise<QueryWordpressResponse | any> {\n return _queryWordpress(opts);\n}\n\nfunction appendFiltersToParams(\n params: URLSearchParams,\n filters: WordPressFilters\n): void {\n // Add all filter parameters\n for (const [key, value] of Object.entries(filters)) {\n if (value === undefined || value === null) {\n continue;\n }\n\n if (Array.isArray(value)) {\n // WordPress accepts comma-separated values for arrays\n params.append(key, value.join(\",\"));\n } else {\n params.append(key, String(value));\n }\n }\n}\n\nexport const queryWordpressMeta: CustomFunctionMeta<typeof queryWordpress> = {\n name: \"queryWordpress\",\n displayName: \"Query WordPress\",\n importPath: \"@plasmicpkgs/wordpress\",\n params: [\n {\n name: \"opts\",\n type: \"object\",\n display: \"flatten\",\n fields: {\n wordpressUrl: {\n type: \"string\",\n displayName: \"WordPress URL\",\n description:\n \"Base URL of your WordPress site (e.g., https://example.com)\",\n helpText: \"The root URL of your WordPress installation\",\n },\n queryType: {\n type: \"choice\",\n options: [\n { label: \"Posts\", value: \"posts\" },\n { label: \"Pages\", value: \"pages\" },\n ],\n displayName: \"Content Type\",\n description: \"Type of content to query\",\n defaultValue: \"posts\",\n },\n\n filterLogic: {\n type: \"queryBuilder\",\n displayName: \"Filters\",\n description: \"Filter fetched entries. Defaults to fetch all entries.\",\n config: (_: any, ctx: any) => {\n const { queryType, categories, tags } = ctx;\n if (!queryType) {\n return { fields: {} };\n }\n\n return buildWordPressConfig(queryType, categories, tags);\n },\n },\n\n // Pagination\n page: {\n type: \"number\",\n displayName: \"Page\",\n description: \"Page number for pagination (starts at 1)\",\n min: 1,\n defaultValueHint: 1,\n },\n limit: {\n type: \"number\",\n displayName: \"Items per page\",\n description: \"Maximum number of items to return (max: 100)\",\n min: 1,\n max: 100,\n defaultValueHint: 10,\n },\n offset: {\n type: \"number\",\n displayName: \"Offset\",\n description: \"Number of items to skip\",\n min: 0,\n hidden: (opts: any) => !!opts.page, // Hide if page is being used\n defaultValueHint: 0,\n },\n\n // Ordering\n // One of: author, date, id, include, modified, parent, relevance, slug, include_slugs, title\n orderby: {\n type: \"choice\",\n options: ([opts]) => [\n {\n label: \"Relevance (search results)\",\n value: \"relevance\",\n },\n {\n label: \"Publish date\",\n value: \"date\",\n },\n {\n label: \"Last modified date\",\n value: \"modified\",\n },\n {\n label: \"Title (A\u2013Z)\",\n value: \"title\",\n },\n {\n label: \"Slug (URL)\",\n value: \"slug\",\n },\n {\n label: \"Author\",\n value: \"author\",\n },\n {\n label: \"ID\",\n value: \"id\",\n },\n ...(opts?.queryType === \"pages\"\n ? [\n {\n label: \"Menu order\",\n value: \"menu_order\",\n },\n {\n label: \"Parent page\",\n value: \"parent\",\n },\n ]\n : []),\n ],\n displayName: \"Sort by\",\n description: \"Field to sort results by\",\n defaultValueHint: \"date\",\n },\n reverseOrder: {\n type: \"boolean\",\n displayName: \"Reverse order\",\n description: \"Reverse the order of the results\",\n defaultValueHint: false,\n },\n },\n },\n ],\n fnContext: (wordpressOpts?: QueryWordpressOpts) => {\n const { wordpressUrl, queryType } = wordpressOpts ?? {};\n if (!wordpressUrl || !queryType) {\n return {\n dataKey: \"\",\n fetcher: async () => ({ categories: [], tags: [] }),\n };\n }\n\n return {\n dataKey: `${wordpressUrl}:${queryType}`,\n fetcher: async () => {\n if (queryType === \"posts\") {\n const [categories, tags] = await Promise.all([\n fetchCategories(wordpressUrl),\n fetchTags(wordpressUrl),\n ]);\n\n return { categories, tags, queryType };\n }\n\n return { categories: [], tags: [], queryType };\n },\n };\n },\n};\n"],
|
|
5
|
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AAAA,QACpB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,WAAW,CAAC,kBAAuC;AACjD,UAAM,EAAE,cAAc,UAAU,IAAI,wCAAiB,CAAC;AACtD,QAAI,CAAC,gBAAgB,CAAC,WAAW;AAC/B,aAAO;AAAA,QACL,SAAS;AAAA,QACT,SAAS,MAAS;AAAI,mBAAE,YAAY,CAAC,GAAG,MAAM,CAAC,EAAE;AAAA;AAAA,MACnD;AAAA,IACF;AAEA,WAAO;AAAA,MACL,SAAS,GAAG,gBAAgB;AAAA,MAC5B,SAAS,MAAY;AACnB,YAAI,cAAc,SAAS;AACzB,gBAAM,CAAC,YAAY,IAAI,IAAI,MAAM,QAAQ,IAAI;AAAA,YAC3C,gBAAgB,YAAY;AAAA,YAC5B,UAAU,YAAY;AAAA,UACxB,CAAC;AAED,iBAAO,EAAE,YAAY,MAAM,UAAU;AAAA,QACvC;AAEA,eAAO,EAAE,YAAY,CAAC,GAAG,MAAM,CAAC,GAAG,UAAU;AAAA,MAC/C;AAAA,IACF;AAAA,EACF;AACF;;;AHvVO,SAAS,kBAAkB,QAAoC;AACpE,WAAS,kBACP,IACA,MACA;AACA,QAAI,QAAQ;AACV,aAAO,iBAAiB,IAAI,IAAI;AAAA,IAClC,OAAO;AACL,uBAAiB,IAAI,IAAI;AAAA,IAC3B;AAAA,EACF;AAEA,oBAAkB,gBAAgB,kBAAkB;AACtD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
9
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
10
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __spreadValues = (a, b) => {
|
|
14
|
+
for (var prop in b || (b = {}))
|
|
15
|
+
if (__hasOwnProp.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
if (__getOwnPropSymbols)
|
|
18
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
+
if (__propIsEnum.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
8
25
|
var __export = (target, all) => {
|
|
9
26
|
for (var name in all)
|
|
10
27
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -52,6 +69,7 @@ var src_exports = {};
|
|
|
52
69
|
__export(src_exports, {
|
|
53
70
|
_ensure: () => ensure,
|
|
54
71
|
_queryOperators: () => queryOperators,
|
|
72
|
+
_queryWordpress: () => _queryWordpress,
|
|
55
73
|
queryWordpress: () => queryWordpress,
|
|
56
74
|
registerWordpress: () => registerWordpress
|
|
57
75
|
});
|
|
@@ -81,33 +99,344 @@ function ensure(x, message) {
|
|
|
81
99
|
return x;
|
|
82
100
|
}
|
|
83
101
|
}
|
|
102
|
+
function cleanUrl(url) {
|
|
103
|
+
return url.replace(/\/$/, "");
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// src/where.ts
|
|
107
|
+
var WORDPRESS_POST_FIELDS = {
|
|
108
|
+
id: {
|
|
109
|
+
type: "number",
|
|
110
|
+
label: "ID",
|
|
111
|
+
operators: ["equal", "not_equal"]
|
|
112
|
+
},
|
|
113
|
+
date: {
|
|
114
|
+
type: "datetime",
|
|
115
|
+
label: "Published Date",
|
|
116
|
+
operators: ["less", "greater"],
|
|
117
|
+
defaultOperator: "greater"
|
|
118
|
+
// this prevents "equals" operator from being shown by default
|
|
119
|
+
},
|
|
120
|
+
modified: {
|
|
121
|
+
type: "datetime",
|
|
122
|
+
label: "Modified Date",
|
|
123
|
+
operators: ["less", "greater"],
|
|
124
|
+
defaultOperator: "greater"
|
|
125
|
+
},
|
|
126
|
+
slug: {
|
|
127
|
+
type: "text",
|
|
128
|
+
label: "Slug",
|
|
129
|
+
operators: ["equal"]
|
|
130
|
+
},
|
|
131
|
+
author: {
|
|
132
|
+
type: "number",
|
|
133
|
+
label: "Author ID",
|
|
134
|
+
operators: ["equal", "not_equal"]
|
|
135
|
+
},
|
|
136
|
+
categories: {
|
|
137
|
+
type: "multiselect",
|
|
138
|
+
label: "Category",
|
|
139
|
+
operators: ["multiselect_contains", "multiselect_not_contains"],
|
|
140
|
+
defaultOperator: "multiselect_contains",
|
|
141
|
+
fieldSettings: {
|
|
142
|
+
listValues: []
|
|
143
|
+
// Will be populated dynamically
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
tags: {
|
|
147
|
+
type: "multiselect",
|
|
148
|
+
label: "Tag",
|
|
149
|
+
operators: ["multiselect_contains", "multiselect_not_contains"],
|
|
150
|
+
defaultOperator: "multiselect_contains",
|
|
151
|
+
fieldSettings: {
|
|
152
|
+
listValues: []
|
|
153
|
+
// Will be populated dynamically
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
sticky: {
|
|
157
|
+
type: "boolean",
|
|
158
|
+
label: "Sticky",
|
|
159
|
+
operators: ["equal"]
|
|
160
|
+
},
|
|
161
|
+
search: {
|
|
162
|
+
type: "text",
|
|
163
|
+
label: "Search",
|
|
164
|
+
operators: ["equal"]
|
|
165
|
+
},
|
|
166
|
+
search_columns: {
|
|
167
|
+
type: "multiselect",
|
|
168
|
+
label: "Search Columns",
|
|
169
|
+
operators: ["multiselect_contains"],
|
|
170
|
+
defaultOperator: "multiselect_contains",
|
|
171
|
+
fieldSettings: {
|
|
172
|
+
listValues: ["post_title", "post_content", "post_excerpt"]
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
var WORDPRESS_PAGE_FIELDS = {
|
|
177
|
+
id: WORDPRESS_POST_FIELDS.id,
|
|
178
|
+
date: WORDPRESS_POST_FIELDS.date,
|
|
179
|
+
modified: WORDPRESS_POST_FIELDS.modified,
|
|
180
|
+
slug: WORDPRESS_POST_FIELDS.slug,
|
|
181
|
+
author: WORDPRESS_POST_FIELDS.author,
|
|
182
|
+
search: WORDPRESS_POST_FIELDS.search,
|
|
183
|
+
search_columns: WORDPRESS_POST_FIELDS.search_columns,
|
|
184
|
+
// Page-specific fields
|
|
185
|
+
parent: {
|
|
186
|
+
type: "number",
|
|
187
|
+
label: "Parent Page",
|
|
188
|
+
operators: ["equal", "not_equal"]
|
|
189
|
+
},
|
|
190
|
+
menu_order: {
|
|
191
|
+
type: "number",
|
|
192
|
+
label: "Menu Order",
|
|
193
|
+
operators: ["equal"]
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
function fetchCategories(wordpressUrl) {
|
|
197
|
+
return __async(this, null, function* () {
|
|
198
|
+
try {
|
|
199
|
+
const url = `${cleanUrl(
|
|
200
|
+
wordpressUrl
|
|
201
|
+
)}/wp-json/wp/v2/categories?per_page=100`;
|
|
202
|
+
const resp = yield fetch(url);
|
|
203
|
+
if (!resp.ok) {
|
|
204
|
+
return [];
|
|
205
|
+
}
|
|
206
|
+
const categories = yield resp.json();
|
|
207
|
+
const formatted = categories.map((cat) => ({
|
|
208
|
+
value: cat.id,
|
|
209
|
+
title: cat.name
|
|
210
|
+
}));
|
|
211
|
+
return formatted;
|
|
212
|
+
} catch (error) {
|
|
213
|
+
console.error("Failed to fetch WordPress categories:", error);
|
|
214
|
+
return [];
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
function fetchTags(wordpressUrl) {
|
|
219
|
+
return __async(this, null, function* () {
|
|
220
|
+
try {
|
|
221
|
+
const url = `${cleanUrl(wordpressUrl)}/wp-json/wp/v2/tags?per_page=100`;
|
|
222
|
+
const resp = yield fetch(url);
|
|
223
|
+
if (!resp.ok) {
|
|
224
|
+
return [];
|
|
225
|
+
}
|
|
226
|
+
const tags = yield resp.json();
|
|
227
|
+
const formatted = tags.map((tag) => ({
|
|
228
|
+
value: tag.id,
|
|
229
|
+
title: tag.name
|
|
230
|
+
}));
|
|
231
|
+
return formatted;
|
|
232
|
+
} catch (error) {
|
|
233
|
+
console.error("Failed to fetch WordPress tags:", error);
|
|
234
|
+
return [];
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
function buildWordPressConfig(queryType, categories, tags) {
|
|
239
|
+
const fields = queryType === "posts" ? __spreadValues({}, WORDPRESS_POST_FIELDS) : __spreadValues({}, WORDPRESS_PAGE_FIELDS);
|
|
240
|
+
if (queryType === "posts" && categories && tags) {
|
|
241
|
+
fields.categories = __spreadProps(__spreadValues({}, fields.categories), {
|
|
242
|
+
fieldSettings: { listValues: categories }
|
|
243
|
+
});
|
|
244
|
+
fields.tags = __spreadProps(__spreadValues({}, fields.tags), {
|
|
245
|
+
fieldSettings: { listValues: tags }
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
return {
|
|
249
|
+
fields,
|
|
250
|
+
// WordPress REST API doesn't support OR logic natively
|
|
251
|
+
// Limit to AND-only combinations
|
|
252
|
+
conjunctions: {
|
|
253
|
+
AND: { label: "AND" }
|
|
254
|
+
},
|
|
255
|
+
settings: {
|
|
256
|
+
showNot: false,
|
|
257
|
+
// hides group controls (we don't want to support nested groups, because the only supported conjunction is AND)
|
|
258
|
+
maxNesting: 1
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
function rulesLogicToWordPressFilters(logic) {
|
|
263
|
+
if (logic === null || logic === void 0) {
|
|
264
|
+
return {};
|
|
265
|
+
} else if (typeof logic !== "object") {
|
|
266
|
+
throw new Error(`unexpected logic: ${JSON.stringify(logic)}`);
|
|
267
|
+
} else if ("and" in logic) {
|
|
268
|
+
return handleAndGroup(logic.and);
|
|
269
|
+
}
|
|
270
|
+
return handleCondition(logic);
|
|
271
|
+
}
|
|
272
|
+
function handleAndGroup(conditions) {
|
|
273
|
+
const filters = {};
|
|
274
|
+
for (const condition of conditions) {
|
|
275
|
+
const result = handleCondition(condition);
|
|
276
|
+
Object.assign(filters, result);
|
|
277
|
+
}
|
|
278
|
+
return filters;
|
|
279
|
+
}
|
|
280
|
+
function handleCondition(condition, negated = false) {
|
|
281
|
+
if ("some" in condition) {
|
|
282
|
+
const [fieldExpr, inExpr] = condition.some;
|
|
283
|
+
if ("var" in fieldExpr && "in" in inExpr && Array.isArray(inExpr.in) && inExpr.in.length === 2) {
|
|
284
|
+
const field = fieldExpr.var;
|
|
285
|
+
const values = inExpr.in[1];
|
|
286
|
+
return negated ? convertNotEqualOperator(field, values) : convertEqualOperator(field, values);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
if ("!" in condition) {
|
|
290
|
+
return handleCondition(condition["!"], true);
|
|
291
|
+
}
|
|
292
|
+
if ("==" in condition) {
|
|
293
|
+
const [fieldExpr, value] = condition["=="];
|
|
294
|
+
if ("var" in fieldExpr) {
|
|
295
|
+
return convertEqualOperator(fieldExpr.var, value);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
if ("!=" in condition) {
|
|
299
|
+
const [fieldExpr, value] = condition["!="];
|
|
300
|
+
if ("var" in fieldExpr) {
|
|
301
|
+
return convertNotEqualOperator(fieldExpr.var, value);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
if ("<" in condition) {
|
|
305
|
+
const [fieldExpr, value] = condition["<"];
|
|
306
|
+
if ("var" in fieldExpr) {
|
|
307
|
+
return convertLessThanOperator(fieldExpr.var, value);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
if (">" in condition) {
|
|
311
|
+
const [fieldExpr, right] = condition[">"];
|
|
312
|
+
if ("var" in fieldExpr) {
|
|
313
|
+
return convertGreaterThanOperator(fieldExpr.var, right);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
throw new Error(
|
|
317
|
+
`Unsupported WordPress filter condition: ${JSON.stringify(condition)}`
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
function convertEqualOperator(field, value) {
|
|
321
|
+
if (field === "id") {
|
|
322
|
+
return { include: value };
|
|
323
|
+
}
|
|
324
|
+
return { [field]: value };
|
|
325
|
+
}
|
|
326
|
+
function convertNotEqualOperator(field, value) {
|
|
327
|
+
if (field === "id") {
|
|
328
|
+
return { exclude: value };
|
|
329
|
+
}
|
|
330
|
+
return { [`${field}_exclude`]: value };
|
|
331
|
+
}
|
|
332
|
+
function convertLessThanOperator(field, value) {
|
|
333
|
+
if (field === "date") {
|
|
334
|
+
return { before: value };
|
|
335
|
+
}
|
|
336
|
+
if (field === "modified") {
|
|
337
|
+
return { modified_before: value };
|
|
338
|
+
}
|
|
339
|
+
console.warn(
|
|
340
|
+
`WordPress: Less than operator not supported for field: ${field}`
|
|
341
|
+
);
|
|
342
|
+
return {};
|
|
343
|
+
}
|
|
344
|
+
function convertGreaterThanOperator(field, value) {
|
|
345
|
+
if (field === "date") {
|
|
346
|
+
return { after: value };
|
|
347
|
+
}
|
|
348
|
+
if (field === "modified") {
|
|
349
|
+
return { modified_after: value };
|
|
350
|
+
}
|
|
351
|
+
console.warn(
|
|
352
|
+
`WordPress: Greater than operator not supported for field: ${field}`
|
|
353
|
+
);
|
|
354
|
+
return {};
|
|
355
|
+
}
|
|
84
356
|
|
|
85
357
|
// src/query-wordpress.ts
|
|
86
|
-
function
|
|
87
|
-
return __async(this,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
358
|
+
function _queryWordpress(opts) {
|
|
359
|
+
return __async(this, null, function* () {
|
|
360
|
+
const {
|
|
361
|
+
wordpressUrl,
|
|
362
|
+
queryType,
|
|
363
|
+
queryOperator,
|
|
364
|
+
filterValue,
|
|
365
|
+
filterLogic,
|
|
366
|
+
limit,
|
|
367
|
+
page,
|
|
368
|
+
offset,
|
|
369
|
+
reverseOrder,
|
|
370
|
+
orderby
|
|
371
|
+
} = opts;
|
|
94
372
|
if (!wordpressUrl || !queryType) {
|
|
95
373
|
throw new Error("Wordpress URL and query type are required");
|
|
96
374
|
}
|
|
97
375
|
const urlParams = new URLSearchParams();
|
|
98
|
-
if (
|
|
376
|
+
if (filterLogic) {
|
|
377
|
+
const filters = rulesLogicToWordPressFilters(filterLogic);
|
|
378
|
+
appendFiltersToParams(urlParams, filters);
|
|
379
|
+
} else if (queryOperator && filterValue) {
|
|
99
380
|
urlParams.append(queryOperator, filterValue);
|
|
100
381
|
}
|
|
101
382
|
if (limit) {
|
|
102
|
-
urlParams.append("per_page",
|
|
383
|
+
urlParams.append("per_page", String(Math.min(limit, 100)));
|
|
103
384
|
}
|
|
104
|
-
|
|
105
|
-
|
|
385
|
+
if (page) {
|
|
386
|
+
urlParams.append("page", String(page));
|
|
387
|
+
}
|
|
388
|
+
if (offset) {
|
|
389
|
+
urlParams.append("offset", String(offset));
|
|
390
|
+
}
|
|
391
|
+
if (reverseOrder) {
|
|
392
|
+
urlParams.append("order", "asc");
|
|
393
|
+
}
|
|
394
|
+
if (orderby) {
|
|
395
|
+
urlParams.append("orderby", orderby);
|
|
396
|
+
}
|
|
397
|
+
const url = new URL(`wp-json/wp/v2/${queryType}`, cleanUrl(wordpressUrl));
|
|
106
398
|
url.search = urlParams.toString();
|
|
107
399
|
const resp = yield fetch(url);
|
|
108
|
-
|
|
400
|
+
if (!resp.ok) {
|
|
401
|
+
const errorText = yield resp.text();
|
|
402
|
+
let errorMessage = `WordPress API error (${resp.status})`;
|
|
403
|
+
try {
|
|
404
|
+
const errorJson = JSON.parse(errorText);
|
|
405
|
+
errorMessage = errorJson.message || errorMessage;
|
|
406
|
+
} catch (e) {
|
|
407
|
+
errorMessage += `: ${errorText}`;
|
|
408
|
+
}
|
|
409
|
+
throw new Error(errorMessage);
|
|
410
|
+
}
|
|
411
|
+
const items = yield resp.json();
|
|
412
|
+
const total = parseInt(resp.headers.get("X-WP-Total") || "0", 10);
|
|
413
|
+
const totalPages = parseInt(resp.headers.get("X-WP-TotalPages") || "0", 10);
|
|
414
|
+
return {
|
|
415
|
+
items,
|
|
416
|
+
total,
|
|
417
|
+
totalPages,
|
|
418
|
+
page: page || 1,
|
|
419
|
+
perPage: limit || 10
|
|
420
|
+
};
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
function queryWordpress(opts) {
|
|
424
|
+
return __async(this, null, function* () {
|
|
425
|
+
return _queryWordpress(opts);
|
|
109
426
|
});
|
|
110
427
|
}
|
|
428
|
+
function appendFiltersToParams(params, filters) {
|
|
429
|
+
for (const [key, value] of Object.entries(filters)) {
|
|
430
|
+
if (value === void 0 || value === null) {
|
|
431
|
+
continue;
|
|
432
|
+
}
|
|
433
|
+
if (Array.isArray(value)) {
|
|
434
|
+
params.append(key, value.join(","));
|
|
435
|
+
} else {
|
|
436
|
+
params.append(key, String(value));
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
111
440
|
var queryWordpressMeta = {
|
|
112
441
|
name: "queryWordpress",
|
|
113
442
|
displayName: "Query WordPress",
|
|
@@ -119,28 +448,139 @@ var queryWordpressMeta = {
|
|
|
119
448
|
display: "flatten",
|
|
120
449
|
fields: {
|
|
121
450
|
wordpressUrl: {
|
|
122
|
-
type: "string"
|
|
451
|
+
type: "string",
|
|
452
|
+
displayName: "WordPress URL",
|
|
453
|
+
description: "Base URL of your WordPress site (e.g., https://example.com)",
|
|
454
|
+
helpText: "The root URL of your WordPress installation"
|
|
123
455
|
},
|
|
124
456
|
queryType: {
|
|
125
457
|
type: "choice",
|
|
126
|
-
options: [
|
|
458
|
+
options: [
|
|
459
|
+
{ label: "Posts", value: "posts" },
|
|
460
|
+
{ label: "Pages", value: "pages" }
|
|
461
|
+
],
|
|
462
|
+
displayName: "Content Type",
|
|
463
|
+
description: "Type of content to query",
|
|
464
|
+
defaultValue: "posts"
|
|
127
465
|
},
|
|
128
|
-
|
|
129
|
-
type: "
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
466
|
+
filterLogic: {
|
|
467
|
+
type: "queryBuilder",
|
|
468
|
+
displayName: "Filters",
|
|
469
|
+
description: "Filter fetched entries. Defaults to fetch all entries.",
|
|
470
|
+
config: (_, ctx) => {
|
|
471
|
+
const { queryType, categories, tags } = ctx;
|
|
472
|
+
if (!queryType) {
|
|
473
|
+
return { fields: {} };
|
|
474
|
+
}
|
|
475
|
+
return buildWordPressConfig(queryType, categories, tags);
|
|
476
|
+
}
|
|
134
477
|
},
|
|
135
|
-
|
|
136
|
-
|
|
478
|
+
// Pagination
|
|
479
|
+
page: {
|
|
480
|
+
type: "number",
|
|
481
|
+
displayName: "Page",
|
|
482
|
+
description: "Page number for pagination (starts at 1)",
|
|
483
|
+
min: 1,
|
|
484
|
+
defaultValueHint: 1
|
|
137
485
|
},
|
|
138
486
|
limit: {
|
|
139
|
-
type: "number"
|
|
487
|
+
type: "number",
|
|
488
|
+
displayName: "Items per page",
|
|
489
|
+
description: "Maximum number of items to return (max: 100)",
|
|
490
|
+
min: 1,
|
|
491
|
+
max: 100,
|
|
492
|
+
defaultValueHint: 10
|
|
493
|
+
},
|
|
494
|
+
offset: {
|
|
495
|
+
type: "number",
|
|
496
|
+
displayName: "Offset",
|
|
497
|
+
description: "Number of items to skip",
|
|
498
|
+
min: 0,
|
|
499
|
+
hidden: (opts) => !!opts.page,
|
|
500
|
+
// Hide if page is being used
|
|
501
|
+
defaultValueHint: 0
|
|
502
|
+
},
|
|
503
|
+
// Ordering
|
|
504
|
+
// One of: author, date, id, include, modified, parent, relevance, slug, include_slugs, title
|
|
505
|
+
orderby: {
|
|
506
|
+
type: "choice",
|
|
507
|
+
options: ([opts]) => [
|
|
508
|
+
{
|
|
509
|
+
label: "Relevance (search results)",
|
|
510
|
+
value: "relevance"
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
label: "Publish date",
|
|
514
|
+
value: "date"
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
label: "Last modified date",
|
|
518
|
+
value: "modified"
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
label: "Title (A\u2013Z)",
|
|
522
|
+
value: "title"
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
label: "Slug (URL)",
|
|
526
|
+
value: "slug"
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
label: "Author",
|
|
530
|
+
value: "author"
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
label: "ID",
|
|
534
|
+
value: "id"
|
|
535
|
+
},
|
|
536
|
+
...(opts == null ? void 0 : opts.queryType) === "pages" ? [
|
|
537
|
+
{
|
|
538
|
+
label: "Menu order",
|
|
539
|
+
value: "menu_order"
|
|
540
|
+
},
|
|
541
|
+
{
|
|
542
|
+
label: "Parent page",
|
|
543
|
+
value: "parent"
|
|
544
|
+
}
|
|
545
|
+
] : []
|
|
546
|
+
],
|
|
547
|
+
displayName: "Sort by",
|
|
548
|
+
description: "Field to sort results by",
|
|
549
|
+
defaultValueHint: "date"
|
|
550
|
+
},
|
|
551
|
+
reverseOrder: {
|
|
552
|
+
type: "boolean",
|
|
553
|
+
displayName: "Reverse order",
|
|
554
|
+
description: "Reverse the order of the results",
|
|
555
|
+
defaultValueHint: false
|
|
140
556
|
}
|
|
141
557
|
}
|
|
142
558
|
}
|
|
143
|
-
]
|
|
559
|
+
],
|
|
560
|
+
fnContext: (wordpressOpts) => {
|
|
561
|
+
const { wordpressUrl, queryType } = wordpressOpts != null ? wordpressOpts : {};
|
|
562
|
+
if (!wordpressUrl || !queryType) {
|
|
563
|
+
return {
|
|
564
|
+
dataKey: "",
|
|
565
|
+
fetcher: () => __async(void 0, null, function* () {
|
|
566
|
+
return { categories: [], tags: [] };
|
|
567
|
+
})
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
return {
|
|
571
|
+
dataKey: `${wordpressUrl}:${queryType}`,
|
|
572
|
+
fetcher: () => __async(void 0, null, function* () {
|
|
573
|
+
if (queryType === "posts") {
|
|
574
|
+
const [categories, tags] = yield Promise.all([
|
|
575
|
+
fetchCategories(wordpressUrl),
|
|
576
|
+
fetchTags(wordpressUrl)
|
|
577
|
+
]);
|
|
578
|
+
return { categories, tags, queryType };
|
|
579
|
+
}
|
|
580
|
+
return { categories: [], tags: [], queryType };
|
|
581
|
+
})
|
|
582
|
+
};
|
|
583
|
+
}
|
|
144
584
|
};
|
|
145
585
|
|
|
146
586
|
// src/index.ts
|