@digital-gravy/etch-public-api 0.8.2 → 0.10.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/dist/index.d.cts +120 -5
- package/dist/index.d.ts +120 -5
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -340,15 +340,26 @@ interface EtchLoopBlockJson extends EtchBlockCommon {
|
|
|
340
340
|
type: 'etch/loop';
|
|
341
341
|
/** Variable name bound to the current item (e.g. `item`). */
|
|
342
342
|
itemId: string;
|
|
343
|
-
/**
|
|
343
|
+
/**
|
|
344
|
+
* What the block iterates over.
|
|
345
|
+
*
|
|
346
|
+
* On a `dataSources` runtime this is the whole binding and is **required**:
|
|
347
|
+
* any dynamic expression yielding a list — `data('products').items`, an
|
|
348
|
+
* enclosing loop's `item.tags`, `range(1, 10)`. On a `loops` runtime it is
|
|
349
|
+
* optional and means a sub-path within the loop bound by `loopId`.
|
|
350
|
+
*/
|
|
344
351
|
target?: string;
|
|
345
352
|
/** Variable name bound to the current index. */
|
|
346
353
|
indexId?: string;
|
|
347
|
-
/**
|
|
354
|
+
/**
|
|
355
|
+
* Id of a registered loop definition this block is bound to.
|
|
356
|
+
* **Requires the `loops` capability** — ignored where loops are not backed.
|
|
357
|
+
*/
|
|
348
358
|
loopId?: string;
|
|
349
359
|
/**
|
|
350
360
|
* Values for the bound loop's parameters. Every key must be a `$`-prefixed
|
|
351
361
|
* parameter reference (e.g. `$count`).
|
|
362
|
+
* **Requires the `loops` capability** — ignored where loops are not backed.
|
|
352
363
|
*/
|
|
353
364
|
loopParams?: Record<LoopParamRef, unknown>;
|
|
354
365
|
}
|
|
@@ -390,12 +401,32 @@ interface EtchRawHtmlBlockJson extends EtchBlockCommon {
|
|
|
390
401
|
/** The original, unsanitized HTML as authored. */
|
|
391
402
|
unsafe: string;
|
|
392
403
|
}
|
|
393
|
-
/**
|
|
404
|
+
/**
|
|
405
|
+
* A pass-through wrapper around a native Gutenberg block (`etch/passthrough`).
|
|
406
|
+
*
|
|
407
|
+
* **Not registered on every build** — this one is WordPress-only. Check
|
|
408
|
+
* `etch.environment.blockTypes` before authoring it; creating a block type the
|
|
409
|
+
* runtime does not register is rejected.
|
|
410
|
+
*/
|
|
394
411
|
interface EtchPassthroughBlockJson extends EtchBlockCommon {
|
|
395
412
|
type: 'etch/passthrough';
|
|
396
413
|
/** The wrapped Gutenberg block. */
|
|
397
414
|
gutenbergBlock: GutenbergBlock;
|
|
398
415
|
}
|
|
416
|
+
/**
|
|
417
|
+
* Renders whatever {@link EtchRenderBlockJson.target} resolves to, as long as it
|
|
418
|
+
* resolves to Etch block JSON — for content that only exists as data at render
|
|
419
|
+
* time, such as a content-type field. Its children are the resolved JSON, so it
|
|
420
|
+
* accepts no authored children.
|
|
421
|
+
*
|
|
422
|
+
* **Not registered on every build** — this one is Studio-only. Check
|
|
423
|
+
* `etch.environment.blockTypes` before authoring it.
|
|
424
|
+
*/
|
|
425
|
+
interface EtchRenderBlockJson extends EtchBlockCommon {
|
|
426
|
+
type: 'etch/render';
|
|
427
|
+
/** The dynamic expression to render, e.g. `post.content`. */
|
|
428
|
+
target: string;
|
|
429
|
+
}
|
|
399
430
|
/**
|
|
400
431
|
* A block as plain, structured-clone-safe JSON — the shape accepted by
|
|
401
432
|
* `blocks.create()` / `blocks.replace()`.
|
|
@@ -404,7 +435,7 @@ interface EtchPassthroughBlockJson extends EtchBlockCommon {
|
|
|
404
435
|
* payload does not match its declared `type` (e.g. an `etch/text` block missing
|
|
405
436
|
* `text`, or carrying an `etch/element`'s `tag`).
|
|
406
437
|
*/
|
|
407
|
-
type EtchBlockJson = EtchTextBlockJson | EtchElementBlockJson | EtchDynamicElementBlockJson | EtchDynamicImageBlockJson | EtchSvgBlockJson | EtchLoopBlockJson | EtchConditionBlockJson | EtchComponentBlockJson | EtchSlotContentBlockJson | EtchSlotPlaceholderBlockJson | EtchPostContentBlockJson | EtchRawHtmlBlockJson | EtchPassthroughBlockJson;
|
|
438
|
+
type EtchBlockJson = EtchTextBlockJson | EtchElementBlockJson | EtchDynamicElementBlockJson | EtchDynamicImageBlockJson | EtchSvgBlockJson | EtchLoopBlockJson | EtchConditionBlockJson | EtchComponentBlockJson | EtchSlotContentBlockJson | EtchSlotPlaceholderBlockJson | EtchPostContentBlockJson | EtchRawHtmlBlockJson | EtchPassthroughBlockJson | EtchRenderBlockJson;
|
|
408
439
|
/** Every known block `type` string (the discriminants of {@link EtchBlockJson}). */
|
|
409
440
|
type EtchBlockTypeName = EtchBlockJson['type'];
|
|
410
441
|
/** Read-only identity attached to every serialized (read) block. */
|
|
@@ -469,6 +500,12 @@ interface BlockPatch {
|
|
|
469
500
|
attributes?: Record<string, string | undefined>;
|
|
470
501
|
/** Replace the text content. Only valid on text blocks. */
|
|
471
502
|
text?: string;
|
|
503
|
+
/**
|
|
504
|
+
* Re-point what the block resolves at: the iterated expression of an
|
|
505
|
+
* `etch/loop` block, or the rendered expression of an `etch/render` block.
|
|
506
|
+
* Only valid on those two types.
|
|
507
|
+
*/
|
|
508
|
+
target?: string;
|
|
472
509
|
}
|
|
473
510
|
/**
|
|
474
511
|
* A portable, JSON-serializable snapshot of a block subtree produced by
|
|
@@ -642,6 +679,74 @@ interface EtchBlocksApi {
|
|
|
642
679
|
saveComponentEditModeAsync(): Promise<void>;
|
|
643
680
|
}
|
|
644
681
|
|
|
682
|
+
/**
|
|
683
|
+
* What this Etch runtime actually is, and which optional surfaces it backs.
|
|
684
|
+
*
|
|
685
|
+
* Etch ships as more than one product against **one** contract: `etch-wp` runs
|
|
686
|
+
* inside WordPress, `etch-studio` is standalone. They expose the same `etch`
|
|
687
|
+
* namespaces, but a namespace can be declared and not implemented — those
|
|
688
|
+
* methods throw `EtchApiError` with code `NOT_AVAILABLE`.
|
|
689
|
+
*
|
|
690
|
+
* `etch.environment` is how a caller finds that out **without** calling and
|
|
691
|
+
* catching. It is deliberately a description of the runtime rather than of the
|
|
692
|
+
* product: prefer `capabilities.loops` over `product === 'etch-wp'`, because
|
|
693
|
+
* capabilities move between products over time (the data manager, for one, is
|
|
694
|
+
* on its way to WordPress) while a product check silently rots the day they do.
|
|
695
|
+
*/
|
|
696
|
+
/** Which build of Etch is running. Identity — not a capability check. */
|
|
697
|
+
type EtchProduct = 'etch-wp' | 'etch-studio' | (string & {});
|
|
698
|
+
/**
|
|
699
|
+
* Optional surfaces a runtime may or may not back.
|
|
700
|
+
*
|
|
701
|
+
* `loops` and `dataSources` are the two dynamic-data models, and they decide
|
|
702
|
+
* how an `etch/loop` block is authored — check which one you are on before
|
|
703
|
+
* writing one:
|
|
704
|
+
*
|
|
705
|
+
* - `loops` — a registry of named loop definitions. A loop block binds to one
|
|
706
|
+
* by `loopId` (plus `$`-prefixed `loopParams`), and `target` is an optional
|
|
707
|
+
* sub-path within it.
|
|
708
|
+
* - `dataSources` — named, typed project sources (`json`, `api`, `js`), reached
|
|
709
|
+
* through a `data('key')` expression. A loop block carries **only** a
|
|
710
|
+
* required `target`, and that target is any *dynamic expression* yielding a
|
|
711
|
+
* list — a data source, a path into one (`data('products').items`), nested
|
|
712
|
+
* data from an enclosing loop (`item.tags`), or a generated list
|
|
713
|
+
* (`range(1, 10)`). There is no `loopId`/`loopParams`. This model supersedes
|
|
714
|
+
* `loops` and is expected on both products eventually.
|
|
715
|
+
*
|
|
716
|
+
* The rest:
|
|
717
|
+
*
|
|
718
|
+
* - `fields` — `etch.fields.*` is backed by a real field store.
|
|
719
|
+
* - `templates` — template posts exist and `navigation.goTo('templates')` works.
|
|
720
|
+
* - `wpMedia` — media ids resolve against the **WordPress media library**, so a
|
|
721
|
+
* URL can be turned into an id through `/wp/v2/media`. Without it the ids are
|
|
722
|
+
* the product's own asset store instead. Either way an `etch/dynamic-image`
|
|
723
|
+
* block binds the same: a numeric `mediaId` attribute.
|
|
724
|
+
*/
|
|
725
|
+
type EtchCapability = 'loops' | 'dataSources' | 'fields' | 'templates' | 'wpMedia';
|
|
726
|
+
/**
|
|
727
|
+
* Capability map. Every key is optional on purpose: a runtime older than a
|
|
728
|
+
* capability's introduction simply omits it, so **absent means unavailable**.
|
|
729
|
+
* Test with `=== true` rather than truthiness of a possibly-missing key.
|
|
730
|
+
*/
|
|
731
|
+
type EtchCapabilities = Readonly<Partial<Record<EtchCapability, boolean>>>;
|
|
732
|
+
/** Runtime self-description, exposed as `etch.environment`. */
|
|
733
|
+
interface EtchEnvironment {
|
|
734
|
+
/**
|
|
735
|
+
* Which build this is — identity, for display and diagnostics. Every
|
|
736
|
+
* behavioral decision belongs to {@link capabilities} instead; a product
|
|
737
|
+
* check goes wrong the moment a capability moves between products.
|
|
738
|
+
*/
|
|
739
|
+
readonly product: EtchProduct;
|
|
740
|
+
/** Which optional surfaces this runtime actually backs. */
|
|
741
|
+
readonly capabilities: EtchCapabilities;
|
|
742
|
+
/**
|
|
743
|
+
* Every block `type` this runtime can construct, sorted. Read this instead
|
|
744
|
+
* of assuming a block exists: `etch/passthrough` is WordPress-only and
|
|
745
|
+
* `etch/render` is Studio-only, and the list grows with each release.
|
|
746
|
+
*/
|
|
747
|
+
readonly blockTypes: readonly string[];
|
|
748
|
+
}
|
|
749
|
+
|
|
645
750
|
/**
|
|
646
751
|
* Global style (CSS rule) shapes and the `etch.styles` API surface.
|
|
647
752
|
*/
|
|
@@ -1490,6 +1595,16 @@ interface Etch {
|
|
|
1490
1595
|
readonly apiVersion: string;
|
|
1491
1596
|
/** The Etch builder (product) version, for capability checks. */
|
|
1492
1597
|
readonly version: string;
|
|
1598
|
+
/**
|
|
1599
|
+
* What this runtime is and which optional surfaces it backs. Read this
|
|
1600
|
+
* before using `loops`, `fields`, templates or WordPress media, and before
|
|
1601
|
+
* authoring a block type that may not exist here.
|
|
1602
|
+
*
|
|
1603
|
+
* Optional: runtimes older than the descriptor omit it. Treat a missing
|
|
1604
|
+
* `environment` as `etch-wp` on WordPress with everything available, which
|
|
1605
|
+
* is what every runtime that predates it was.
|
|
1606
|
+
*/
|
|
1607
|
+
readonly environment?: EtchEnvironment;
|
|
1493
1608
|
}
|
|
1494
1609
|
|
|
1495
1610
|
declare global {
|
|
@@ -1554,4 +1669,4 @@ declare function isEtchApiError(value: unknown): value is EtchApiError;
|
|
|
1554
1669
|
*/
|
|
1555
1670
|
declare const ETCH_API_VERSION = "0.x";
|
|
1556
1671
|
|
|
1557
|
-
export { type ArrayComponentProperty, type BlockLoopBinding, type BlockPatch, type BooleanComponentProperty, type BooleanParam, type BridgeConnectOptions, type ClassComponentProperty, type ColorScheme, type ComponentPatch, type ComponentProperty, type ComponentPropertyBase, type ConditionComponentProperty, type ConnectOptions, type CopyObject, type CustomField, type CustomFieldAssignment, type CustomFieldGroup, type CustomFieldType, ETCH_API_VERSION, type Etch, type EtchAiApi, EtchApiError, type EtchApiErrorCode, type EtchBlockCommon, type EtchBlockContext, type EtchBlockJson, type EtchBlockOptions, type EtchBlockScript, type EtchBlockType, type EtchBlockTypeName, type EtchBlocksApi, type EtchBridgeConnection, type EtchComponentBlockJson, type EtchComponentsApi, type EtchConditionBlockJson, type EtchDynamicElementBlockJson, type EtchDynamicImageBlockJson, type EtchElementBlockJson, type EtchFieldsApi, type EtchHistoryApi, type EtchHtmlAttributes, type EtchLoop, type EtchLoopBlockJson, type EtchLoopConfig, type EtchLoopObj, type EtchLoopsApi, type EtchNavigationApi, type EtchPassthroughBlockJson, type EtchPostContentBlockJson, type EtchRawHtmlBlockJson, type EtchSkillsApi, type EtchSlotContentBlockJson, type EtchSlotPlaceholderBlockJson, type EtchStylesApi, type EtchStylesheetsApi, type EtchSvgBlockJson, type EtchTextBlockJson, type EtchUiApi, type ExternalAiState, type FindBlocksPredicate, type GroupComponentProperty, type GutenbergBlock, 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 SelectOptionsString, type SkillDetail, type SkillSummary, type StringComponentProperty, type StyleListFilter, type StylePatch, type StyleSelectorType, type StyleSummary, type StylesheetInput, type StylesheetPatch, type StylesheetSummary, type StylesheetType, type TaxQueryItem, type TemplateSummary, type WpQueryArgs, type WpTermsArgs, type WpUsersArgs, getEtch, isEtchApiError, isEtchAvailable };
|
|
1672
|
+
export { type ArrayComponentProperty, type BlockLoopBinding, type BlockPatch, type BooleanComponentProperty, type BooleanParam, type BridgeConnectOptions, type ClassComponentProperty, type ColorScheme, type ComponentPatch, type ComponentProperty, type ComponentPropertyBase, type ConditionComponentProperty, type ConnectOptions, type CopyObject, type CustomField, type CustomFieldAssignment, type CustomFieldGroup, type CustomFieldType, ETCH_API_VERSION, type Etch, type EtchAiApi, EtchApiError, type EtchApiErrorCode, type EtchBlockCommon, type EtchBlockContext, type EtchBlockJson, type EtchBlockOptions, type EtchBlockScript, type EtchBlockType, type EtchBlockTypeName, type EtchBlocksApi, type EtchBridgeConnection, type EtchCapabilities, type EtchCapability, type EtchComponentBlockJson, type EtchComponentsApi, type EtchConditionBlockJson, type EtchDynamicElementBlockJson, type EtchDynamicImageBlockJson, type EtchElementBlockJson, type EtchEnvironment, type EtchFieldsApi, type EtchHistoryApi, type EtchHtmlAttributes, type EtchLoop, type EtchLoopBlockJson, type EtchLoopConfig, type EtchLoopObj, type EtchLoopsApi, type EtchNavigationApi, type EtchPassthroughBlockJson, type EtchPostContentBlockJson, type EtchProduct, type EtchRawHtmlBlockJson, type EtchRenderBlockJson, type EtchSkillsApi, type EtchSlotContentBlockJson, type EtchSlotPlaceholderBlockJson, type EtchStylesApi, type EtchStylesheetsApi, type EtchSvgBlockJson, type EtchTextBlockJson, type EtchUiApi, type ExternalAiState, type FindBlocksPredicate, type GroupComponentProperty, type GutenbergBlock, 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 SelectOptionsString, type SkillDetail, type SkillSummary, type StringComponentProperty, type StyleListFilter, type StylePatch, type StyleSelectorType, type StyleSummary, 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
|
@@ -340,15 +340,26 @@ interface EtchLoopBlockJson extends EtchBlockCommon {
|
|
|
340
340
|
type: 'etch/loop';
|
|
341
341
|
/** Variable name bound to the current item (e.g. `item`). */
|
|
342
342
|
itemId: string;
|
|
343
|
-
/**
|
|
343
|
+
/**
|
|
344
|
+
* What the block iterates over.
|
|
345
|
+
*
|
|
346
|
+
* On a `dataSources` runtime this is the whole binding and is **required**:
|
|
347
|
+
* any dynamic expression yielding a list — `data('products').items`, an
|
|
348
|
+
* enclosing loop's `item.tags`, `range(1, 10)`. On a `loops` runtime it is
|
|
349
|
+
* optional and means a sub-path within the loop bound by `loopId`.
|
|
350
|
+
*/
|
|
344
351
|
target?: string;
|
|
345
352
|
/** Variable name bound to the current index. */
|
|
346
353
|
indexId?: string;
|
|
347
|
-
/**
|
|
354
|
+
/**
|
|
355
|
+
* Id of a registered loop definition this block is bound to.
|
|
356
|
+
* **Requires the `loops` capability** — ignored where loops are not backed.
|
|
357
|
+
*/
|
|
348
358
|
loopId?: string;
|
|
349
359
|
/**
|
|
350
360
|
* Values for the bound loop's parameters. Every key must be a `$`-prefixed
|
|
351
361
|
* parameter reference (e.g. `$count`).
|
|
362
|
+
* **Requires the `loops` capability** — ignored where loops are not backed.
|
|
352
363
|
*/
|
|
353
364
|
loopParams?: Record<LoopParamRef, unknown>;
|
|
354
365
|
}
|
|
@@ -390,12 +401,32 @@ interface EtchRawHtmlBlockJson extends EtchBlockCommon {
|
|
|
390
401
|
/** The original, unsanitized HTML as authored. */
|
|
391
402
|
unsafe: string;
|
|
392
403
|
}
|
|
393
|
-
/**
|
|
404
|
+
/**
|
|
405
|
+
* A pass-through wrapper around a native Gutenberg block (`etch/passthrough`).
|
|
406
|
+
*
|
|
407
|
+
* **Not registered on every build** — this one is WordPress-only. Check
|
|
408
|
+
* `etch.environment.blockTypes` before authoring it; creating a block type the
|
|
409
|
+
* runtime does not register is rejected.
|
|
410
|
+
*/
|
|
394
411
|
interface EtchPassthroughBlockJson extends EtchBlockCommon {
|
|
395
412
|
type: 'etch/passthrough';
|
|
396
413
|
/** The wrapped Gutenberg block. */
|
|
397
414
|
gutenbergBlock: GutenbergBlock;
|
|
398
415
|
}
|
|
416
|
+
/**
|
|
417
|
+
* Renders whatever {@link EtchRenderBlockJson.target} resolves to, as long as it
|
|
418
|
+
* resolves to Etch block JSON — for content that only exists as data at render
|
|
419
|
+
* time, such as a content-type field. Its children are the resolved JSON, so it
|
|
420
|
+
* accepts no authored children.
|
|
421
|
+
*
|
|
422
|
+
* **Not registered on every build** — this one is Studio-only. Check
|
|
423
|
+
* `etch.environment.blockTypes` before authoring it.
|
|
424
|
+
*/
|
|
425
|
+
interface EtchRenderBlockJson extends EtchBlockCommon {
|
|
426
|
+
type: 'etch/render';
|
|
427
|
+
/** The dynamic expression to render, e.g. `post.content`. */
|
|
428
|
+
target: string;
|
|
429
|
+
}
|
|
399
430
|
/**
|
|
400
431
|
* A block as plain, structured-clone-safe JSON — the shape accepted by
|
|
401
432
|
* `blocks.create()` / `blocks.replace()`.
|
|
@@ -404,7 +435,7 @@ interface EtchPassthroughBlockJson extends EtchBlockCommon {
|
|
|
404
435
|
* payload does not match its declared `type` (e.g. an `etch/text` block missing
|
|
405
436
|
* `text`, or carrying an `etch/element`'s `tag`).
|
|
406
437
|
*/
|
|
407
|
-
type EtchBlockJson = EtchTextBlockJson | EtchElementBlockJson | EtchDynamicElementBlockJson | EtchDynamicImageBlockJson | EtchSvgBlockJson | EtchLoopBlockJson | EtchConditionBlockJson | EtchComponentBlockJson | EtchSlotContentBlockJson | EtchSlotPlaceholderBlockJson | EtchPostContentBlockJson | EtchRawHtmlBlockJson | EtchPassthroughBlockJson;
|
|
438
|
+
type EtchBlockJson = EtchTextBlockJson | EtchElementBlockJson | EtchDynamicElementBlockJson | EtchDynamicImageBlockJson | EtchSvgBlockJson | EtchLoopBlockJson | EtchConditionBlockJson | EtchComponentBlockJson | EtchSlotContentBlockJson | EtchSlotPlaceholderBlockJson | EtchPostContentBlockJson | EtchRawHtmlBlockJson | EtchPassthroughBlockJson | EtchRenderBlockJson;
|
|
408
439
|
/** Every known block `type` string (the discriminants of {@link EtchBlockJson}). */
|
|
409
440
|
type EtchBlockTypeName = EtchBlockJson['type'];
|
|
410
441
|
/** Read-only identity attached to every serialized (read) block. */
|
|
@@ -469,6 +500,12 @@ interface BlockPatch {
|
|
|
469
500
|
attributes?: Record<string, string | undefined>;
|
|
470
501
|
/** Replace the text content. Only valid on text blocks. */
|
|
471
502
|
text?: string;
|
|
503
|
+
/**
|
|
504
|
+
* Re-point what the block resolves at: the iterated expression of an
|
|
505
|
+
* `etch/loop` block, or the rendered expression of an `etch/render` block.
|
|
506
|
+
* Only valid on those two types.
|
|
507
|
+
*/
|
|
508
|
+
target?: string;
|
|
472
509
|
}
|
|
473
510
|
/**
|
|
474
511
|
* A portable, JSON-serializable snapshot of a block subtree produced by
|
|
@@ -642,6 +679,74 @@ interface EtchBlocksApi {
|
|
|
642
679
|
saveComponentEditModeAsync(): Promise<void>;
|
|
643
680
|
}
|
|
644
681
|
|
|
682
|
+
/**
|
|
683
|
+
* What this Etch runtime actually is, and which optional surfaces it backs.
|
|
684
|
+
*
|
|
685
|
+
* Etch ships as more than one product against **one** contract: `etch-wp` runs
|
|
686
|
+
* inside WordPress, `etch-studio` is standalone. They expose the same `etch`
|
|
687
|
+
* namespaces, but a namespace can be declared and not implemented — those
|
|
688
|
+
* methods throw `EtchApiError` with code `NOT_AVAILABLE`.
|
|
689
|
+
*
|
|
690
|
+
* `etch.environment` is how a caller finds that out **without** calling and
|
|
691
|
+
* catching. It is deliberately a description of the runtime rather than of the
|
|
692
|
+
* product: prefer `capabilities.loops` over `product === 'etch-wp'`, because
|
|
693
|
+
* capabilities move between products over time (the data manager, for one, is
|
|
694
|
+
* on its way to WordPress) while a product check silently rots the day they do.
|
|
695
|
+
*/
|
|
696
|
+
/** Which build of Etch is running. Identity — not a capability check. */
|
|
697
|
+
type EtchProduct = 'etch-wp' | 'etch-studio' | (string & {});
|
|
698
|
+
/**
|
|
699
|
+
* Optional surfaces a runtime may or may not back.
|
|
700
|
+
*
|
|
701
|
+
* `loops` and `dataSources` are the two dynamic-data models, and they decide
|
|
702
|
+
* how an `etch/loop` block is authored — check which one you are on before
|
|
703
|
+
* writing one:
|
|
704
|
+
*
|
|
705
|
+
* - `loops` — a registry of named loop definitions. A loop block binds to one
|
|
706
|
+
* by `loopId` (plus `$`-prefixed `loopParams`), and `target` is an optional
|
|
707
|
+
* sub-path within it.
|
|
708
|
+
* - `dataSources` — named, typed project sources (`json`, `api`, `js`), reached
|
|
709
|
+
* through a `data('key')` expression. A loop block carries **only** a
|
|
710
|
+
* required `target`, and that target is any *dynamic expression* yielding a
|
|
711
|
+
* list — a data source, a path into one (`data('products').items`), nested
|
|
712
|
+
* data from an enclosing loop (`item.tags`), or a generated list
|
|
713
|
+
* (`range(1, 10)`). There is no `loopId`/`loopParams`. This model supersedes
|
|
714
|
+
* `loops` and is expected on both products eventually.
|
|
715
|
+
*
|
|
716
|
+
* The rest:
|
|
717
|
+
*
|
|
718
|
+
* - `fields` — `etch.fields.*` is backed by a real field store.
|
|
719
|
+
* - `templates` — template posts exist and `navigation.goTo('templates')` works.
|
|
720
|
+
* - `wpMedia` — media ids resolve against the **WordPress media library**, so a
|
|
721
|
+
* URL can be turned into an id through `/wp/v2/media`. Without it the ids are
|
|
722
|
+
* the product's own asset store instead. Either way an `etch/dynamic-image`
|
|
723
|
+
* block binds the same: a numeric `mediaId` attribute.
|
|
724
|
+
*/
|
|
725
|
+
type EtchCapability = 'loops' | 'dataSources' | 'fields' | 'templates' | 'wpMedia';
|
|
726
|
+
/**
|
|
727
|
+
* Capability map. Every key is optional on purpose: a runtime older than a
|
|
728
|
+
* capability's introduction simply omits it, so **absent means unavailable**.
|
|
729
|
+
* Test with `=== true` rather than truthiness of a possibly-missing key.
|
|
730
|
+
*/
|
|
731
|
+
type EtchCapabilities = Readonly<Partial<Record<EtchCapability, boolean>>>;
|
|
732
|
+
/** Runtime self-description, exposed as `etch.environment`. */
|
|
733
|
+
interface EtchEnvironment {
|
|
734
|
+
/**
|
|
735
|
+
* Which build this is — identity, for display and diagnostics. Every
|
|
736
|
+
* behavioral decision belongs to {@link capabilities} instead; a product
|
|
737
|
+
* check goes wrong the moment a capability moves between products.
|
|
738
|
+
*/
|
|
739
|
+
readonly product: EtchProduct;
|
|
740
|
+
/** Which optional surfaces this runtime actually backs. */
|
|
741
|
+
readonly capabilities: EtchCapabilities;
|
|
742
|
+
/**
|
|
743
|
+
* Every block `type` this runtime can construct, sorted. Read this instead
|
|
744
|
+
* of assuming a block exists: `etch/passthrough` is WordPress-only and
|
|
745
|
+
* `etch/render` is Studio-only, and the list grows with each release.
|
|
746
|
+
*/
|
|
747
|
+
readonly blockTypes: readonly string[];
|
|
748
|
+
}
|
|
749
|
+
|
|
645
750
|
/**
|
|
646
751
|
* Global style (CSS rule) shapes and the `etch.styles` API surface.
|
|
647
752
|
*/
|
|
@@ -1490,6 +1595,16 @@ interface Etch {
|
|
|
1490
1595
|
readonly apiVersion: string;
|
|
1491
1596
|
/** The Etch builder (product) version, for capability checks. */
|
|
1492
1597
|
readonly version: string;
|
|
1598
|
+
/**
|
|
1599
|
+
* What this runtime is and which optional surfaces it backs. Read this
|
|
1600
|
+
* before using `loops`, `fields`, templates or WordPress media, and before
|
|
1601
|
+
* authoring a block type that may not exist here.
|
|
1602
|
+
*
|
|
1603
|
+
* Optional: runtimes older than the descriptor omit it. Treat a missing
|
|
1604
|
+
* `environment` as `etch-wp` on WordPress with everything available, which
|
|
1605
|
+
* is what every runtime that predates it was.
|
|
1606
|
+
*/
|
|
1607
|
+
readonly environment?: EtchEnvironment;
|
|
1493
1608
|
}
|
|
1494
1609
|
|
|
1495
1610
|
declare global {
|
|
@@ -1554,4 +1669,4 @@ declare function isEtchApiError(value: unknown): value is EtchApiError;
|
|
|
1554
1669
|
*/
|
|
1555
1670
|
declare const ETCH_API_VERSION = "0.x";
|
|
1556
1671
|
|
|
1557
|
-
export { type ArrayComponentProperty, type BlockLoopBinding, type BlockPatch, type BooleanComponentProperty, type BooleanParam, type BridgeConnectOptions, type ClassComponentProperty, type ColorScheme, type ComponentPatch, type ComponentProperty, type ComponentPropertyBase, type ConditionComponentProperty, type ConnectOptions, type CopyObject, type CustomField, type CustomFieldAssignment, type CustomFieldGroup, type CustomFieldType, ETCH_API_VERSION, type Etch, type EtchAiApi, EtchApiError, type EtchApiErrorCode, type EtchBlockCommon, type EtchBlockContext, type EtchBlockJson, type EtchBlockOptions, type EtchBlockScript, type EtchBlockType, type EtchBlockTypeName, type EtchBlocksApi, type EtchBridgeConnection, type EtchComponentBlockJson, type EtchComponentsApi, type EtchConditionBlockJson, type EtchDynamicElementBlockJson, type EtchDynamicImageBlockJson, type EtchElementBlockJson, type EtchFieldsApi, type EtchHistoryApi, type EtchHtmlAttributes, type EtchLoop, type EtchLoopBlockJson, type EtchLoopConfig, type EtchLoopObj, type EtchLoopsApi, type EtchNavigationApi, type EtchPassthroughBlockJson, type EtchPostContentBlockJson, type EtchRawHtmlBlockJson, type EtchSkillsApi, type EtchSlotContentBlockJson, type EtchSlotPlaceholderBlockJson, type EtchStylesApi, type EtchStylesheetsApi, type EtchSvgBlockJson, type EtchTextBlockJson, type EtchUiApi, type ExternalAiState, type FindBlocksPredicate, type GroupComponentProperty, type GutenbergBlock, 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 SelectOptionsString, type SkillDetail, type SkillSummary, type StringComponentProperty, type StyleListFilter, type StylePatch, type StyleSelectorType, type StyleSummary, type StylesheetInput, type StylesheetPatch, type StylesheetSummary, type StylesheetType, type TaxQueryItem, type TemplateSummary, type WpQueryArgs, type WpTermsArgs, type WpUsersArgs, getEtch, isEtchApiError, isEtchAvailable };
|
|
1672
|
+
export { type ArrayComponentProperty, type BlockLoopBinding, type BlockPatch, type BooleanComponentProperty, type BooleanParam, type BridgeConnectOptions, type ClassComponentProperty, type ColorScheme, type ComponentPatch, type ComponentProperty, type ComponentPropertyBase, type ConditionComponentProperty, type ConnectOptions, type CopyObject, type CustomField, type CustomFieldAssignment, type CustomFieldGroup, type CustomFieldType, ETCH_API_VERSION, type Etch, type EtchAiApi, EtchApiError, type EtchApiErrorCode, type EtchBlockCommon, type EtchBlockContext, type EtchBlockJson, type EtchBlockOptions, type EtchBlockScript, type EtchBlockType, type EtchBlockTypeName, type EtchBlocksApi, type EtchBridgeConnection, type EtchCapabilities, type EtchCapability, type EtchComponentBlockJson, type EtchComponentsApi, type EtchConditionBlockJson, type EtchDynamicElementBlockJson, type EtchDynamicImageBlockJson, type EtchElementBlockJson, type EtchEnvironment, type EtchFieldsApi, type EtchHistoryApi, type EtchHtmlAttributes, type EtchLoop, type EtchLoopBlockJson, type EtchLoopConfig, type EtchLoopObj, type EtchLoopsApi, type EtchNavigationApi, type EtchPassthroughBlockJson, type EtchPostContentBlockJson, type EtchProduct, type EtchRawHtmlBlockJson, type EtchRenderBlockJson, type EtchSkillsApi, type EtchSlotContentBlockJson, type EtchSlotPlaceholderBlockJson, type EtchStylesApi, type EtchStylesheetsApi, type EtchSvgBlockJson, type EtchTextBlockJson, type EtchUiApi, type ExternalAiState, type FindBlocksPredicate, type GroupComponentProperty, type GutenbergBlock, 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 SelectOptionsString, type SkillDetail, type SkillSummary, type StringComponentProperty, type StyleListFilter, type StylePatch, type StyleSelectorType, type StyleSummary, 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.
|
|
3
|
+
"version": "0.10.0",
|
|
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
|
"repository": {
|