@digital-gravy/etch-public-api 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -163,6 +163,25 @@ interface EtchBlocksApi {
163
163
  /** Whether the block currently has the given CSS class. */
164
164
  hasClass(blockId: string, className: string): boolean;
165
165
  }
166
+ /**
167
+ * A loop parameter reference, e.g. `$count`. Resolved to a concrete value
168
+ * before the query runs.
169
+ */
170
+ type LoopParamRef = `$${string}`;
171
+ /**
172
+ * A numeric query value, or a loop-parameter expression that resolves to one:
173
+ * a bare reference (`$count`) or a reference with a numeric fallback
174
+ * (`$count ?? 10`). Plain numeric strings (e.g. `"10"`) are not accepted —
175
+ * pass the number itself.
176
+ */
177
+ type NumericParam = number | LoopParamRef | `$${string} ?? ${number}`;
178
+ /**
179
+ * A boolean query value, or a loop-parameter expression that resolves to one:
180
+ * a bare reference (`$sticky`) or a reference with a boolean fallback
181
+ * (`$sticky ?? false`). WordPress also accepts its integer-boolean convention
182
+ * (`0`/`1`) for these args.
183
+ */
184
+ type BooleanParam = boolean | 0 | 1 | LoopParamRef | `$${string} ?? ${boolean}`;
166
185
  /**
167
186
  * A `WP_Query` meta-query clause. Extensible — additional keys are allowed.
168
187
  * @see https://developer.wordpress.org/reference/classes/wp_query/#custom-field-post-meta-parameters
@@ -204,13 +223,13 @@ interface WpQueryArgs {
204
223
  /** Post type(s) to query. */
205
224
  post_type?: string | string[];
206
225
  /** Number of posts per page (`-1` for all). */
207
- posts_per_page?: number | string;
226
+ posts_per_page?: NumericParam;
208
227
  /** Number of posts to skip. */
209
- offset?: number | string;
228
+ offset?: NumericParam;
210
229
  /** Page of results to return. */
211
- paged?: number | string;
230
+ paged?: NumericParam;
212
231
  /** Alias of `paged` used in some contexts. */
213
- page?: number | string;
232
+ page?: NumericParam;
214
233
  /** Field to order results by. */
215
234
  orderby?: "date" | "title" | "menu_order" | "rand" | "ID" | "author" | "name" | "modified" | "parent" | "comment_count" | (string & {});
216
235
  /** Sort direction. */
@@ -218,7 +237,7 @@ interface WpQueryArgs {
218
237
  /** Post status to include. */
219
238
  post_status?: "publish" | "pending" | "draft" | "auto-draft" | "future" | "private" | "inherit" | "trash" | (string & {});
220
239
  /** Whether to ignore sticky posts. */
221
- ignore_sticky_posts?: boolean | 0 | 1 | (string & {});
240
+ ignore_sticky_posts?: BooleanParam;
222
241
  /** Author id (number) or username (string). */
223
242
  author?: number | string;
224
243
  /** Author by `user_nicename`. */
@@ -264,11 +283,11 @@ interface WpUsersArgs {
264
283
  /** Sort direction. */
265
284
  order?: "ASC" | "DESC" | (string & {});
266
285
  /** Number of users to return. */
267
- number?: number | string;
286
+ number?: NumericParam;
268
287
  /** Number of users to skip. */
269
- offset?: number | string;
288
+ offset?: NumericParam;
270
289
  /** Page of results to return. */
271
- paged?: number | string;
290
+ paged?: NumericParam;
272
291
  [key: string]: unknown;
273
292
  }
274
293
  /** Type-specific configuration of an {@link EtchLoop}, discriminated by `type`. */
@@ -881,4 +900,4 @@ declare function isEtchApiError(value: unknown): value is EtchApiError;
881
900
  */
882
901
  declare const ETCH_API_VERSION = "0.x";
883
902
 
884
- export { type ArrayComponentProperty, type BlockLoopBinding, type BlockPatch, type BooleanComponentProperty, type ClassComponentProperty, type ColorScheme, type ComponentPatch, type ComponentProperty, type ComponentPropertyBase, type ConditionComponentProperty, type ConnectOptions, type CustomField, type CustomFieldAssignment, type CustomFieldGroup, type CustomFieldType, ETCH_API_VERSION, type Etch, EtchApiError, type EtchApiErrorCode, type EtchBlockContext, type EtchBlockJson, type EtchBlockOptions, type EtchBlockScript, type EtchBlockType, type EtchBlocksApi, type EtchComponentsApi, type EtchFieldsApi, type EtchHistoryApi, type EtchLoop, type EtchLoopConfig, type EtchLoopObj, type EtchLoopsApi, type EtchNavigationApi, type EtchStylesApi, type EtchStylesheetsApi, type EtchUiApi, type FindBlocksPredicate, type GroupComponentProperty, type MetaQueryItem, type NavigationPlace, type NumberComponentProperty, type ObjectComponentProperty, type PostCustomFieldGroupEntry, type PostCustomFieldValueEntry, type PostCustomFieldValueResponse, type PostCustomFieldValuesResponse, type PostSummary, type PublicBlockJson, type PublicComponentJson, type PublicComponentSummary, type RepeaterComponentProperty, type ResolvedCustomField, type StringComponentProperty, type StylePatch, type StylesheetInput, type StylesheetPatch, type StylesheetSummary, type StylesheetType, type TaxQueryItem, type TemplateSummary, type WpQueryArgs, type WpTermsArgs, type WpUsersArgs, getEtch, isEtchApiError, isEtchAvailable };
903
+ export { type ArrayComponentProperty, type BlockLoopBinding, type BlockPatch, type BooleanComponentProperty, type BooleanParam, type ClassComponentProperty, type ColorScheme, type ComponentPatch, type ComponentProperty, type ComponentPropertyBase, type ConditionComponentProperty, type ConnectOptions, type CustomField, type CustomFieldAssignment, type CustomFieldGroup, type CustomFieldType, ETCH_API_VERSION, type Etch, EtchApiError, type EtchApiErrorCode, type EtchBlockContext, type EtchBlockJson, type EtchBlockOptions, type EtchBlockScript, type EtchBlockType, type EtchBlocksApi, type EtchComponentsApi, type EtchFieldsApi, type EtchHistoryApi, type EtchLoop, type EtchLoopConfig, type EtchLoopObj, type EtchLoopsApi, type EtchNavigationApi, type EtchStylesApi, type EtchStylesheetsApi, type EtchUiApi, type FindBlocksPredicate, type GroupComponentProperty, type LoopParamRef, type MetaQueryItem, type NavigationPlace, type NumberComponentProperty, type NumericParam, type ObjectComponentProperty, type PostCustomFieldGroupEntry, type PostCustomFieldValueEntry, type PostCustomFieldValueResponse, type PostCustomFieldValuesResponse, type PostSummary, type PublicBlockJson, type PublicComponentJson, type PublicComponentSummary, type RepeaterComponentProperty, type ResolvedCustomField, type StringComponentProperty, type StylePatch, type StylesheetInput, type StylesheetPatch, type StylesheetSummary, type StylesheetType, type TaxQueryItem, type TemplateSummary, type WpQueryArgs, type WpTermsArgs, type WpUsersArgs, getEtch, isEtchApiError, isEtchAvailable };
package/dist/index.d.ts CHANGED
@@ -163,6 +163,25 @@ interface EtchBlocksApi {
163
163
  /** Whether the block currently has the given CSS class. */
164
164
  hasClass(blockId: string, className: string): boolean;
165
165
  }
166
+ /**
167
+ * A loop parameter reference, e.g. `$count`. Resolved to a concrete value
168
+ * before the query runs.
169
+ */
170
+ type LoopParamRef = `$${string}`;
171
+ /**
172
+ * A numeric query value, or a loop-parameter expression that resolves to one:
173
+ * a bare reference (`$count`) or a reference with a numeric fallback
174
+ * (`$count ?? 10`). Plain numeric strings (e.g. `"10"`) are not accepted —
175
+ * pass the number itself.
176
+ */
177
+ type NumericParam = number | LoopParamRef | `$${string} ?? ${number}`;
178
+ /**
179
+ * A boolean query value, or a loop-parameter expression that resolves to one:
180
+ * a bare reference (`$sticky`) or a reference with a boolean fallback
181
+ * (`$sticky ?? false`). WordPress also accepts its integer-boolean convention
182
+ * (`0`/`1`) for these args.
183
+ */
184
+ type BooleanParam = boolean | 0 | 1 | LoopParamRef | `$${string} ?? ${boolean}`;
166
185
  /**
167
186
  * A `WP_Query` meta-query clause. Extensible — additional keys are allowed.
168
187
  * @see https://developer.wordpress.org/reference/classes/wp_query/#custom-field-post-meta-parameters
@@ -204,13 +223,13 @@ interface WpQueryArgs {
204
223
  /** Post type(s) to query. */
205
224
  post_type?: string | string[];
206
225
  /** Number of posts per page (`-1` for all). */
207
- posts_per_page?: number | string;
226
+ posts_per_page?: NumericParam;
208
227
  /** Number of posts to skip. */
209
- offset?: number | string;
228
+ offset?: NumericParam;
210
229
  /** Page of results to return. */
211
- paged?: number | string;
230
+ paged?: NumericParam;
212
231
  /** Alias of `paged` used in some contexts. */
213
- page?: number | string;
232
+ page?: NumericParam;
214
233
  /** Field to order results by. */
215
234
  orderby?: "date" | "title" | "menu_order" | "rand" | "ID" | "author" | "name" | "modified" | "parent" | "comment_count" | (string & {});
216
235
  /** Sort direction. */
@@ -218,7 +237,7 @@ interface WpQueryArgs {
218
237
  /** Post status to include. */
219
238
  post_status?: "publish" | "pending" | "draft" | "auto-draft" | "future" | "private" | "inherit" | "trash" | (string & {});
220
239
  /** Whether to ignore sticky posts. */
221
- ignore_sticky_posts?: boolean | 0 | 1 | (string & {});
240
+ ignore_sticky_posts?: BooleanParam;
222
241
  /** Author id (number) or username (string). */
223
242
  author?: number | string;
224
243
  /** Author by `user_nicename`. */
@@ -264,11 +283,11 @@ interface WpUsersArgs {
264
283
  /** Sort direction. */
265
284
  order?: "ASC" | "DESC" | (string & {});
266
285
  /** Number of users to return. */
267
- number?: number | string;
286
+ number?: NumericParam;
268
287
  /** Number of users to skip. */
269
- offset?: number | string;
288
+ offset?: NumericParam;
270
289
  /** Page of results to return. */
271
- paged?: number | string;
290
+ paged?: NumericParam;
272
291
  [key: string]: unknown;
273
292
  }
274
293
  /** Type-specific configuration of an {@link EtchLoop}, discriminated by `type`. */
@@ -881,4 +900,4 @@ declare function isEtchApiError(value: unknown): value is EtchApiError;
881
900
  */
882
901
  declare const ETCH_API_VERSION = "0.x";
883
902
 
884
- export { type ArrayComponentProperty, type BlockLoopBinding, type BlockPatch, type BooleanComponentProperty, type ClassComponentProperty, type ColorScheme, type ComponentPatch, type ComponentProperty, type ComponentPropertyBase, type ConditionComponentProperty, type ConnectOptions, type CustomField, type CustomFieldAssignment, type CustomFieldGroup, type CustomFieldType, ETCH_API_VERSION, type Etch, EtchApiError, type EtchApiErrorCode, type EtchBlockContext, type EtchBlockJson, type EtchBlockOptions, type EtchBlockScript, type EtchBlockType, type EtchBlocksApi, type EtchComponentsApi, type EtchFieldsApi, type EtchHistoryApi, type EtchLoop, type EtchLoopConfig, type EtchLoopObj, type EtchLoopsApi, type EtchNavigationApi, type EtchStylesApi, type EtchStylesheetsApi, type EtchUiApi, type FindBlocksPredicate, type GroupComponentProperty, type MetaQueryItem, type NavigationPlace, type NumberComponentProperty, type ObjectComponentProperty, type PostCustomFieldGroupEntry, type PostCustomFieldValueEntry, type PostCustomFieldValueResponse, type PostCustomFieldValuesResponse, type PostSummary, type PublicBlockJson, type PublicComponentJson, type PublicComponentSummary, type RepeaterComponentProperty, type ResolvedCustomField, type StringComponentProperty, type StylePatch, type StylesheetInput, type StylesheetPatch, type StylesheetSummary, type StylesheetType, type TaxQueryItem, type TemplateSummary, type WpQueryArgs, type WpTermsArgs, type WpUsersArgs, getEtch, isEtchApiError, isEtchAvailable };
903
+ export { type ArrayComponentProperty, type BlockLoopBinding, type BlockPatch, type BooleanComponentProperty, type BooleanParam, type ClassComponentProperty, type ColorScheme, type ComponentPatch, type ComponentProperty, type ComponentPropertyBase, type ConditionComponentProperty, type ConnectOptions, type CustomField, type CustomFieldAssignment, type CustomFieldGroup, type CustomFieldType, ETCH_API_VERSION, type Etch, EtchApiError, type EtchApiErrorCode, type EtchBlockContext, type EtchBlockJson, type EtchBlockOptions, type EtchBlockScript, type EtchBlockType, type EtchBlocksApi, type EtchComponentsApi, type EtchFieldsApi, type EtchHistoryApi, type EtchLoop, type EtchLoopConfig, type EtchLoopObj, type EtchLoopsApi, type EtchNavigationApi, type EtchStylesApi, type EtchStylesheetsApi, type EtchUiApi, type FindBlocksPredicate, type GroupComponentProperty, type LoopParamRef, type MetaQueryItem, type NavigationPlace, type NumberComponentProperty, type NumericParam, type ObjectComponentProperty, type PostCustomFieldGroupEntry, type PostCustomFieldValueEntry, type PostCustomFieldValueResponse, type PostCustomFieldValuesResponse, type PostSummary, type PublicBlockJson, type PublicComponentJson, type PublicComponentSummary, type RepeaterComponentProperty, type ResolvedCustomField, type StringComponentProperty, type StylePatch, type StylesheetInput, type StylesheetPatch, type StylesheetSummary, type StylesheetType, type TaxQueryItem, type TemplateSummary, type WpQueryArgs, type WpTermsArgs, type WpUsersArgs, getEtch, isEtchApiError, isEtchAvailable };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digital-gravy/etch-public-api",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "MIT-licensed typed client and contract for the Etch builder scripting API (window.etch). Etch itself is a separate proprietary product governed by its own commercial terms.",
5
5
  "license": "MIT",
6
6
  "type": "module",