@nextlyhq/plugin-sdk 0.0.2-alpha.71 → 0.0.2-alpha.73
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/admin.d.ts +2 -2
- package/dist/admin.mjs +1 -1
- package/dist/blocks.d.ts +13 -19
- package/dist/blocks.mjs.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.mjs +3 -2
- package/dist/index.mjs.map +1 -1
- package/dist/testing/admin.d.ts +38 -0
- package/dist/testing/admin.mjs +35 -0
- package/dist/testing/admin.mjs.map +1 -0
- package/dist/testing.d.ts +2 -2
- package/dist/testing.mjs +1 -1
- package/dist/widgets.d.ts +3 -2
- package/package.json +16 -9
package/dist/admin.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { JsonObject, JsonValue, PluginAdminContributions, PluginAdminPage, PluginCollectionView, PluginDocumentView, PluginFieldTypeDocumentView, PluginMenuItem } from "nextly";
|
|
2
|
-
import { ActionGroup, ActionPlacement, AdminChromeLayer, ApiError, AutosaveStatus, BeforeDocumentAction, BulkAction, Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardProps, CardTitle, CellContext, CellRenderer, CellRendererDefinition, ChallengeResolveResult, ChallengeViewProps, Checkbox, ColumnProvider, ColumnTransform, ComponentPath, ConditionOperatorName, ConditionRange, ConditionRow, ConditionRowProps, ConditionSource, ConditionSourceOption, ConditionValue, CustomEditViewProps, DataTable, DataTableContext, DataTableProps, DataTableSelection, DataTableTarget, DataTableView, DataTableViewProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, DocumentAction, DocumentActionOutcome, DocumentActions, DocumentIdentity, DocumentLocale, DocumentLockGates, DocumentSaveState, DocumentStatus, DocumentViewProps, EDITABLE_VALIDATION_RULES, FieldDefaultOption, FieldDefaultValueInput, FieldDefaultValueInputProps, FieldOption, FieldOptionsEditor, FieldOptionsEditorProps, FieldShell, FieldShellProps, FieldShellRenderProps, FieldTypePicker, FieldTypePickerProps, FieldWidth, FormActions, FormActionsProps, FormSection, FormSectionProps, Grid, GridProps, InlineRichTextAttachment, InlineRichTextEditor, InlineRichTextRefusal, InlineRichTextSession, Input, Label, NextlyColumn, NextlyFieldSchema, NextlyFieldType, PILL_LABEL, PillState, PluginRouteInvalidation, PluginRouteMethod, PluginRouteRead, PluginRouteRequest, PluginRouteWrite, PluginRouteWriter, RichTextEditorKit, RowAction, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue, SingleDocument, Stack, StackProps, Stat, StatProps, SubmitRefusal, Switch, Textarea, UseDocumentCheckpointOptions, UseDocumentCheckpointResult, ValidationIssue, ValidationNumberField, ValidationNumberFieldProps, ValidationRuleValues, ValidationRulesEditor, ValidationRulesEditorProps, apiErrorMessage, drawsAnyValidationRule, isApiError, loadInlineRichTextEditor, loadRichTextEditorKit, navigateWithinAdmin as navigateTo, operatorTakesValue, operatorsForType, pillStateFromForm, registerBulkAction, registerCellRenderer, registerColumns, registerComponent, registerComponents, registerKnownPlugin, registerRowAction, toastMutationResult, transformColumns, useBeforeDocumentAction, useDocumentActions, useDocumentCheckpoint, useDocumentIdentity, useDocumentLocale, useDocumentStatus, useEntryFieldsPanel, usePluginClientConfig, usePluginFieldTypeEntries, usePluginRoute, usePluginRouteMutation, useReportUnsavedWork, useSingleDocument, useSuppressAdminChrome, useTrackedWrite, useUpdateSingleDocument, useUploadMedia, validationIssues, withOptionIds } from "@nextlyhq/admin";
|
|
3
|
-
export { type ActionGroup, type ActionPlacement, type AdminChromeLayer, type ApiError, type AutosaveStatus, type BeforeDocumentAction, type BulkAction, Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, type CardProps, CardTitle, type CellContext, type CellRenderer, type CellRendererDefinition, type ChallengeResolveResult, type ChallengeViewProps, Checkbox, type ColumnProvider, type ColumnTransform, type ComponentPath, type ConditionOperatorName, type ConditionRange, ConditionRow, type ConditionRowProps, type ConditionSource, type ConditionSourceOption, type ConditionValue, type CustomEditViewProps, DataTable, type DataTableContext, type DataTableProps, type DataTableSelection, type DataTableTarget, DataTableView, type DataTableViewProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, type DocumentAction, type DocumentActionOutcome, type DocumentActions, type DocumentIdentity, type DocumentLocale, type DocumentLockGates, type DocumentSaveState, type DocumentStatus, type DocumentViewProps, EDITABLE_VALIDATION_RULES, type FieldDefaultOption, FieldDefaultValueInput, type FieldDefaultValueInputProps, type FieldOption, FieldOptionsEditor, type FieldOptionsEditorProps, FieldShell, type FieldShellProps, type FieldShellRenderProps, FieldTypePicker, type FieldTypePickerProps, type FieldWidth, FormActions, type FormActionsProps, FormSection, type FormSectionProps, Grid, type GridProps, type InlineRichTextAttachment, type InlineRichTextEditor, type InlineRichTextRefusal, type InlineRichTextSession, Input, type JsonObject, type JsonValue, Label, type NextlyColumn, type NextlyFieldSchema, type NextlyFieldType, PILL_LABEL, type PillState, type PluginAdminContributions, type PluginAdminPage, type PluginCollectionView, type PluginDocumentView, type PluginFieldTypeDocumentView, type PluginMenuItem, type PluginRouteInvalidation, type PluginRouteMethod, type PluginRouteRead, type PluginRouteRequest, type PluginRouteWrite, type PluginRouteWriter, type RichTextEditorKit, type RowAction, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue, type SingleDocument, Stack, type StackProps, Stat, type StatProps, type SubmitRefusal, Switch, Textarea, type UseDocumentCheckpointOptions, type UseDocumentCheckpointResult, type ValidationIssue, ValidationNumberField, type ValidationNumberFieldProps, type ValidationRuleValues, ValidationRulesEditor, type ValidationRulesEditorProps, apiErrorMessage, drawsAnyValidationRule, isApiError, loadInlineRichTextEditor, loadRichTextEditorKit, navigateTo, operatorTakesValue, operatorsForType, pillStateFromForm, registerBulkAction, registerCellRenderer, registerColumns, registerComponent, registerComponents, registerKnownPlugin, registerRowAction, toastMutationResult, transformColumns, useBeforeDocumentAction, useDocumentActions, useDocumentCheckpoint, useDocumentIdentity, useDocumentLocale, useDocumentStatus, useEntryFieldsPanel, usePluginClientConfig, usePluginFieldTypeEntries, usePluginRoute, usePluginRouteMutation, useReportUnsavedWork, useSingleDocument, useSuppressAdminChrome, useTrackedWrite, useUpdateSingleDocument, useUploadMedia, validationIssues, withOptionIds };
|
|
2
|
+
import { ActionGroup, ActionPlacement, AdminChromeLayer, ApiError, AutosaveStatus, BeforeDocumentAction, BulkAction, Button, Card, CardAction, CardContent, CardDescription, CardEmptyContent, CardFooter, CardHeader, CardProps, CardState, CardTitle, CellContext, CellRenderer, CellRendererDefinition, ChallengeResolveResult, ChallengeViewProps, Checkbox, ColumnProvider, ColumnTransform, ComponentPath, ConditionOperatorName, ConditionRange, ConditionRow, ConditionRowProps, ConditionSource, ConditionSourceOption, ConditionValue, CustomEditViewProps, DataTable, DataTableContext, DataTableProps, DataTableSelection, DataTableTarget, DataTableView, DataTableViewProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, DocumentAction, DocumentActionOutcome, DocumentActions, DocumentIdentity, DocumentLocale, DocumentLockGates, DocumentSaveState, DocumentStatus, DocumentViewProps, EDITABLE_VALIDATION_RULES, FieldDefaultOption, FieldDefaultValueInput, FieldDefaultValueInputProps, FieldOption, FieldOptionsEditor, FieldOptionsEditorProps, FieldShell, FieldShellProps, FieldShellRenderProps, FieldTypePicker, FieldTypePickerProps, FieldWidth, FormActions, FormActionsProps, FormSection, FormSectionProps, FrameState, Grid, GridProps, InlineRichTextAttachment, InlineRichTextEditor, InlineRichTextRefusal, InlineRichTextSession, Input, Label, NextlyColumn, NextlyFieldSchema, NextlyFieldType, PILL_LABEL, PillState, PluginRouteInvalidation, PluginRouteMethod, PluginRouteRead, PluginRouteRequest, PluginRouteWrite, PluginRouteWriter, RichTextEditorKit, RowAction, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue, SingleDocument, SkeletonShape, Stack, StackProps, Stat, StatProps, SubmitRefusal, Switch, Textarea, UseDocumentCheckpointOptions, UseDocumentCheckpointResult, ValidationIssue, ValidationNumberField, ValidationNumberFieldProps, ValidationRuleValues, ValidationRulesEditor, ValidationRulesEditorProps, Widget, WidgetBarChartGroup, WidgetBarChartProps, WidgetChartUnit, WidgetFigureProps, WidgetListProps, WidgetListTotal, WidgetRenderSize, WidgetRowAction, WidgetSeries, WidgetSeriesChartProps, WidgetSeriesInterval, WidgetSeriesPoint, WidgetTableColumn, WidgetTableProps, apiErrorMessage, drawsAnyValidationRule, formatWidgetTime, isApiError, loadInlineRichTextEditor, loadRichTextEditorKit, navigateWithinAdmin as navigateTo, operatorTakesValue, operatorsForType, pillStateFromForm, registerBulkAction, registerCellRenderer, registerColumns, registerComponent, registerComponents, registerKnownPlugin, registerRowAction, toastMutationResult, transformColumns, useBeforeDocumentAction, useDocumentActions, useDocumentCheckpoint, useDocumentIdentity, useDocumentLocale, useDocumentStatus, useEntryFieldsPanel, usePluginClientConfig, usePluginFieldTypeEntries, usePluginRoute, usePluginRouteMutation, useRefreshDashboard, useReportUnsavedWork, useSingleDocument, useSuppressAdminChrome, useTrackedWrite, useUpdateSingleDocument, useUploadMedia, useWidgetClock, validationIssues, withOptionIds } from "@nextlyhq/admin";
|
|
3
|
+
export { type ActionGroup, type ActionPlacement, type AdminChromeLayer, type ApiError, type AutosaveStatus, type BeforeDocumentAction, type BulkAction, Button, Card, CardAction, CardContent, CardDescription, type CardEmptyContent, CardFooter, CardHeader, type CardProps, type CardState, CardTitle, type CellContext, type CellRenderer, type CellRendererDefinition, type ChallengeResolveResult, type ChallengeViewProps, Checkbox, type ColumnProvider, type ColumnTransform, type ComponentPath, type ConditionOperatorName, type ConditionRange, ConditionRow, type ConditionRowProps, type ConditionSource, type ConditionSourceOption, type ConditionValue, type CustomEditViewProps, DataTable, type DataTableContext, type DataTableProps, type DataTableSelection, type DataTableTarget, DataTableView, type DataTableViewProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, type DocumentAction, type DocumentActionOutcome, type DocumentActions, type DocumentIdentity, type DocumentLocale, type DocumentLockGates, type DocumentSaveState, type DocumentStatus, type DocumentViewProps, EDITABLE_VALIDATION_RULES, type FieldDefaultOption, FieldDefaultValueInput, type FieldDefaultValueInputProps, type FieldOption, FieldOptionsEditor, type FieldOptionsEditorProps, FieldShell, type FieldShellProps, type FieldShellRenderProps, FieldTypePicker, type FieldTypePickerProps, type FieldWidth, FormActions, type FormActionsProps, FormSection, type FormSectionProps, FrameState, Grid, type GridProps, type InlineRichTextAttachment, type InlineRichTextEditor, type InlineRichTextRefusal, type InlineRichTextSession, Input, type JsonObject, type JsonValue, Label, type NextlyColumn, type NextlyFieldSchema, type NextlyFieldType, PILL_LABEL, type PillState, type PluginAdminContributions, type PluginAdminPage, type PluginCollectionView, type PluginDocumentView, type PluginFieldTypeDocumentView, type PluginMenuItem, type PluginRouteInvalidation, type PluginRouteMethod, type PluginRouteRead, type PluginRouteRequest, type PluginRouteWrite, type PluginRouteWriter, type RichTextEditorKit, type RowAction, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue, type SingleDocument, type SkeletonShape, Stack, type StackProps, Stat, type StatProps, type SubmitRefusal, Switch, Textarea, type UseDocumentCheckpointOptions, type UseDocumentCheckpointResult, type ValidationIssue, ValidationNumberField, type ValidationNumberFieldProps, type ValidationRuleValues, ValidationRulesEditor, type ValidationRulesEditorProps, Widget, type WidgetBarChartGroup, type WidgetBarChartProps, type WidgetChartUnit, type WidgetFigureProps, type WidgetListProps, type WidgetListTotal, type WidgetRenderSize, type WidgetRowAction, type WidgetSeries, type WidgetSeriesChartProps, type WidgetSeriesInterval, type WidgetSeriesPoint, type WidgetTableColumn, type WidgetTableProps, apiErrorMessage, drawsAnyValidationRule, formatWidgetTime, isApiError, loadInlineRichTextEditor, loadRichTextEditorKit, navigateTo, operatorTakesValue, operatorsForType, pillStateFromForm, registerBulkAction, registerCellRenderer, registerColumns, registerComponent, registerComponents, registerKnownPlugin, registerRowAction, toastMutationResult, transformColumns, useBeforeDocumentAction, useDocumentActions, useDocumentCheckpoint, useDocumentIdentity, useDocumentLocale, useDocumentStatus, useEntryFieldsPanel, usePluginClientConfig, usePluginFieldTypeEntries, usePluginRoute, usePluginRouteMutation, useRefreshDashboard, useReportUnsavedWork, useSingleDocument, useSuppressAdminChrome, useTrackedWrite, useUpdateSingleDocument, useUploadMedia, useWidgetClock, validationIssues, withOptionIds };
|
package/dist/admin.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, ConditionRow, DataTable, DataTableView, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, EDITABLE_VALIDATION_RULES, FieldDefaultValueInput, FieldOptionsEditor, FieldShell, FieldTypePicker, FormActions, FormSection, Grid, Input, Label, PILL_LABEL, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue, Stack, Stat, Switch, Textarea, ValidationNumberField, ValidationRulesEditor, apiErrorMessage, drawsAnyValidationRule, isApiError, loadInlineRichTextEditor, loadRichTextEditorKit, navigateWithinAdmin as navigateTo, operatorTakesValue, operatorsForType, pillStateFromForm, registerBulkAction, registerCellRenderer, registerColumns, registerComponent, registerComponents, registerKnownPlugin, registerRowAction, toastMutationResult, transformColumns, useBeforeDocumentAction, useDocumentActions, useDocumentCheckpoint, useDocumentIdentity, useDocumentLocale, useDocumentStatus, useEntryFieldsPanel, usePluginClientConfig, usePluginFieldTypeEntries, usePluginRoute, usePluginRouteMutation, useReportUnsavedWork, useSingleDocument, useSuppressAdminChrome, useTrackedWrite, useUpdateSingleDocument, useUploadMedia, validationIssues, withOptionIds } from "@nextlyhq/admin";
|
|
1
|
+
export { Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, ConditionRow, DataTable, DataTableView, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, EDITABLE_VALIDATION_RULES, FieldDefaultValueInput, FieldOptionsEditor, FieldShell, FieldTypePicker, FormActions, FormSection, FrameState, Grid, Input, Label, PILL_LABEL, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue, Stack, Stat, Switch, Textarea, ValidationNumberField, ValidationRulesEditor, Widget, apiErrorMessage, drawsAnyValidationRule, formatWidgetTime, isApiError, loadInlineRichTextEditor, loadRichTextEditorKit, navigateWithinAdmin as navigateTo, operatorTakesValue, operatorsForType, pillStateFromForm, registerBulkAction, registerCellRenderer, registerColumns, registerComponent, registerComponents, registerKnownPlugin, registerRowAction, toastMutationResult, transformColumns, useBeforeDocumentAction, useDocumentActions, useDocumentCheckpoint, useDocumentIdentity, useDocumentLocale, useDocumentStatus, useEntryFieldsPanel, usePluginClientConfig, usePluginFieldTypeEntries, usePluginRoute, usePluginRouteMutation, useRefreshDashboard, useReportUnsavedWork, useSingleDocument, useSuppressAdminChrome, useTrackedWrite, useUpdateSingleDocument, useUploadMedia, useWidgetClock, validationIssues, withOptionIds } from "@nextlyhq/admin";
|
package/dist/blocks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyBlockDefinition, BlockDefinition as BlockDefinition$1, BlockEditorMeta, BlockExample, BlockIcon, BlockIsland, BlockPart, BlockRenderArgs as BlockRenderArgs$1, BlockSeoContribution, BlockSeoImage, BlockVariation, ComponentPath, InferBlockProps, NodeStyles, PropSchema, SlotLock, SlotSpec, SupportDefinition } from "@nextlyhq/blocks-engine";
|
|
1
|
+
import { AnyBlockDefinition, BlockDefinition as BlockDefinition$1, BlockEditorMeta, BlockExample, BlockIcon, BlockInspectorProps, BlockIsland, BlockPart, BlockRenderArgs as BlockRenderArgs$1, BlockSeoContribution, BlockSeoImage, BlockVariation, ComponentPath, InferBlockProps, NodeStyles, PropSchema, SlotLock, SlotSpec, SupportDefinition } from "@nextlyhq/blocks-engine";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
/**
|
|
4
4
|
* The support keys a block may declare.
|
|
@@ -151,17 +151,14 @@ export interface BlockRenderArgs<P> extends Omit<BlockRenderArgs$1<P, BlockRende
|
|
|
151
151
|
*
|
|
152
152
|
* `ReactNode` rather than the `ReactNode | Promise<ReactNode>` that `render`
|
|
153
153
|
* returns, and the asymmetry is deliberate: this value is one a block places
|
|
154
|
-
* into its own JSX, and that union is not a legal child
|
|
155
|
-
* peer. React 18 admits no promise at all; React 19 admits only
|
|
154
|
+
* into its own JSX, and that union is not a legal child. React admits only
|
|
156
155
|
* `Promise<AwaitedReactNode>`, a promise of a settled node, so a promise that
|
|
157
|
-
* may itself yield a promise is refused
|
|
158
|
-
*
|
|
156
|
+
* may itself yield a promise is refused. Widening here would move the error
|
|
157
|
+
* onto every block that draws a slot.
|
|
159
158
|
*
|
|
160
|
-
* It still
|
|
161
|
-
* `Promise<AwaitedReactNode>` as a `ReactNode`: a renderer
|
|
162
|
-
*
|
|
163
|
-
* costs nothing, since an async block cannot be drawn under React 18's types
|
|
164
|
-
* regardless — `<AsyncBlock />` is refused outright there.
|
|
159
|
+
* It still admits a pending slot, because React counts
|
|
160
|
+
* `Promise<AwaitedReactNode>` as a `ReactNode`: a renderer may hand one back
|
|
161
|
+
* and the block places it unchanged.
|
|
165
162
|
*/
|
|
166
163
|
renderSlot(this: void, name: string, ctx?: BlockRenderContext): ReactNode;
|
|
167
164
|
}
|
|
@@ -180,11 +177,10 @@ export interface BlockDefinition<P extends object = Record<string, unknown>> ext
|
|
|
180
177
|
/**
|
|
181
178
|
* Renders the block.
|
|
182
179
|
*
|
|
183
|
-
* The promise is spelled out rather than left to `ReactNode
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
* the range this package declares.
|
|
180
|
+
* The promise is spelled out rather than left to `ReactNode`, which admits
|
|
181
|
+
* only a promise of a settled node: an async block's `render` returns a
|
|
182
|
+
* promise of anything it could return synchronously, and spelling it out
|
|
183
|
+
* says so.
|
|
188
184
|
*/
|
|
189
185
|
render(args: BlockRenderArgs<P>): BlockRenderResult;
|
|
190
186
|
}
|
|
@@ -243,12 +239,10 @@ export declare function blockSupports<S extends BlockSupports>(supports: ExactSu
|
|
|
243
239
|
* not satisfy `BlockDefinition["render"]`, so handing that helper to
|
|
244
240
|
* `defineBlock` failed to compile.
|
|
245
241
|
*
|
|
246
|
-
* The promise is spelled out for the same reason `render` spells it out
|
|
247
|
-
* 19 added promises to `ReactNode` and React 18 did not, and this package
|
|
248
|
-
* supports both.
|
|
242
|
+
* The promise is spelled out for the same reason `render` spells it out.
|
|
249
243
|
*
|
|
250
244
|
* @experimental Carried by the same freeze as `defineBlock`.
|
|
251
245
|
*/
|
|
252
246
|
export type BlockRenderResult = ReactNode | Promise<ReactNode>;
|
|
253
|
-
export type { AnyBlockDefinition, BlockEditorMeta, BlockExample, BlockIcon, BlockIsland, BlockPart, BlockSeoContribution, BlockSeoImage, BlockVariation, ComponentPath, InferBlockProps, NodeStyles, PropSchema, SlotLock, SlotSpec, SupportDefinition };
|
|
247
|
+
export type { AnyBlockDefinition, BlockEditorMeta, BlockExample, BlockIcon, BlockInspectorProps, BlockIsland, BlockPart, BlockSeoContribution, BlockSeoImage, BlockVariation, ComponentPath, InferBlockProps, NodeStyles, PropSchema, SlotLock, SlotSpec, SupportDefinition };
|
|
254
248
|
//# sourceMappingURL=blocks.d.ts.map
|
package/dist/blocks.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blocks.mjs","names":[],"sources":["../src/blocks.ts"],"sourcesContent":["/**\n * Block authoring — the contracts a plugin contributing blocks to the page\n * builder needs.\n *\n * A subpath rather than the SDK's main entry, so a plugin that has nothing to\n * do with blocks never pulls the block engine into its type graph. The SDK\n * remains the single stable import surface a plugin author is offered; this\n * simply keeps a page-builder-specific vocabulary out of everyone else's way.\n *\n * The engine is a real dependency of this package rather than an optional peer,\n * because the types below are built on top of its own: they have to resolve for\n * an author who installed only the SDK, and under a strict `node_modules`\n * layout the page builder's copy is not reachable from their package. The\n * engine's registry is pinned to `globalThis`, so even a duplicated install\n * still reads and writes the one registry the page builder consumes.\n *\n * What an author writes is declared here rather than re-exported. `defineBlock`\n * and `BlockSupports` are this module's own so that `BlockSupportKeys` can be\n * augmented from a plugin's source, which only works for a module that plugin\n * can name.\n *\n * The registration side is not here. Contributing a block means calling the\n * page builder's own service — it is that plugin's registry, not core's — so\n * `blockRegistry` comes from `@nextlyhq/plugin-page-builder/blocks`, which is\n * also where a contributor already declares its `dependsOn`.\n *\n * @packageDocumentation\n */\n\nimport type {\n BlockDefinition as EngineBlockDefinition,\n BlockRenderArgs as EngineBlockRenderArgs,\n} from \"@nextlyhq/blocks-engine\";\nimport type { ReactNode } from \"react\";\n\n/**\n * The support keys a block may declare.\n *\n * Declared HERE rather than in the engine, and that placement is the whole\n * point. A module augmentation has to name a module that resolves from the file\n * doing the augmenting, and a plugin author installs this package: under a\n * strict `node_modules` layout the engine is a nested transitive dependency\n * their own source cannot name, so an augmentation pointed at it fails to\n * compile and the custom support silently never arrives.\n *\n * A plugin that calls `registerSupport()` adds its key to the vocabulary the\n * compiler checks against:\n *\n * ```ts\n * declare module \"@nextlyhq/plugin-sdk/blocks\" {\n * interface BlockSupportKeys {\n * animation: \"enter\" | \"exit\";\n * parallax: true;\n * }\n * }\n * ```\n *\n * Declaration merging rather than an index signature: an index signature accepts\n * every key, which is what leaves a misspelled `spaceing` to be found at boot,\n * in someone else's app, instead of while it is being written.\n *\n * One rule reads the value: a union of strings names the sub-flags the support\n * recognises, and anything else means the support is all-or-nothing. So a nested\n * typo is caught in the same breath as a top-level one — `{ spacing: { paddding:\n * true } }` enables nothing at all, and finding that out at boot is exactly what\n * this exists to prevent — while a support with no finer granularity can be\n * written the way it reads, as `never` or as `true`.\n *\n * The built-in keys are the style catalog's groups plus the capabilities that\n * have no catalog group of their own. A test holds both the keys and their\n * flags to what the registry actually accepts, so the two cannot drift.\n *\n * @experimental Carried by the same freeze as `defineBlock`.\n */\nexport interface BlockSupportKeys {\n /** Padding and margin. */\n spacing: \"margin\" | \"padding\";\n /** Flow, alignment and gap. */\n layout: never;\n /** Width, height and their limits. */\n dimensions: never;\n /** Font, size, weight, line height and letter spacing. */\n typography: never;\n /** Text and link colours. */\n color: \"text\" | \"link\";\n /** Background colour, image and gradient. */\n background: \"color\" | \"image\" | \"gradient\";\n /** Border lines and corner rounding. */\n border: \"line\" | \"radius\";\n /** Box and text shadows. */\n shadow: never;\n /** Opacity, filters and transforms. */\n effects: never;\n /** Positioning and stacking. */\n position: never;\n /** Container-query behaviour. */\n container: never;\n /** Marker style on a list. */\n list: never;\n /** Author-written CSS on this block. Gates a capability, not a style group. */\n customCss: never;\n}\n\n/**\n * What one support key accepts, given the sub-flags it declares.\n *\n * The two cases are kept apart rather than both handed to `Record`, because\n * `Record` demands a property key and a support that declares no flags has none\n * to give. Feeding it either sentinel is unsound in opposite directions: `true`\n * is not a property key at all, so the mapped type stops instantiating and an\n * augmenting plugin's build fails on the declaration rather than on anything it\n * wrote; `never` produces `Partial<Record<never, boolean>>`, which is `{}`, and\n * `{}` accepts every object — so `{ layout: { typo: true } }` type-checks and is\n * refused only later, by the registry, at boot.\n *\n * `[F] extends [never]` is asked first and in tuple form. Bare `F extends never`\n * distributes and answers for the empty union rather than about it, and\n * `[never] extends [string]` is true, so a `never` reaching the string case\n * would rebuild the same `{}`.\n */\ntype SupportSetting<F> = [F] extends [never]\n ? boolean\n : [F] extends [string]\n ? boolean | Partial<Record<F & string, boolean>>\n : boolean;\n\n/**\n * Style capabilities a block opts into: `true` for a whole group, or an object\n * naming the sub-flags it wants.\n *\n * @experimental Carried by the same freeze as `defineBlock`.\n */\nexport type BlockSupports = {\n [K in keyof BlockSupportKeys]?: SupportSetting<BlockSupportKeys[K]>;\n};\n\n/**\n * Supports as written at a definition, with unknown keys refused.\n *\n * TypeScript checks for excess properties only on a literal written in place,\n * so lifting settings into a shared object skips it: `const shared = { spacing:\n * true, spaceing: true }` assigns to `BlockSupports` without complaint, and the\n * typo survives to be caught at boot in someone else's app — which is the whole\n * failure this vocabulary exists to move earlier.\n *\n * Naming the offending key as `never` refuses it wherever it was written.\n */\ntype ExactSupports<S> = S & {\n [K in Exclude<keyof S, keyof BlockSupportKeys>]: never;\n};\n\n/**\n * Everything a renderer makes available to every block it draws.\n *\n * ONE description per app, rather than each block inventing its own. A block\n * author writes `defineBlock<MyProps>` and `ctx` is already typed as whatever\n * this app's renderer provides, with no type written by hand; a block that\n * needs something unusual has to add it here, which is an app-wide statement\n * anyone can see rather than a quiet assumption inside one file.\n *\n * A renderer declares what it supplies by augmenting this from its own package:\n *\n * ```ts\n * declare module \"@nextlyhq/plugin-sdk/blocks\" {\n * interface BlockRenderContext {\n * data?: DataProvider;\n * }\n * }\n * ```\n *\n * `locale` is here because every renderer of localized content has one, and a\n * block that varies its own output by language should not have to reach past\n * this interface to find out which.\n *\n * @experimental Carried by the same freeze as `defineBlock`.\n */\nexport interface BlockRenderContext {\n /** The locale being rendered, when the renderer is rendering one. */\n locale?: string;\n}\n\n/**\n * What a block's `render` receives.\n *\n * The engine's own version leaves both the context and the output unnamed,\n * because the engine serves any renderer and cannot know either. This one names\n * both: the context is what THIS app's renderer provides, which is what lets a\n * block read `ctx.data` with no type written by hand, and the output is React,\n * which is what lets a block place a slot straight into its JSX instead of\n * asserting a type over it.\n *\n * @experimental Carried by the same freeze as `defineBlock`.\n */\nexport interface BlockRenderArgs<P>\n extends Omit<EngineBlockRenderArgs<P, BlockRenderContext>, \"renderSlot\"> {\n /**\n * Render one of this block's slots, optionally under a different context.\n *\n * `ReactNode` rather than the `ReactNode | Promise<ReactNode>` that `render`\n * returns, and the asymmetry is deliberate: this value is one a block places\n * into its own JSX, and that union is not a legal child under EITHER supported\n * peer. React 18 admits no promise at all; React 19 admits only\n * `Promise<AwaitedReactNode>`, a promise of a settled node, so a promise that\n * may itself yield a promise is refused there too. Widening here would move\n * the error onto every block that draws a slot.\n *\n * It still says what each peer can express, because React 19 counts\n * `Promise<AwaitedReactNode>` as a `ReactNode`: a renderer on 19 may hand back\n * a pending slot and the block places it unchanged. On 18 it may not, which\n * costs nothing, since an async block cannot be drawn under React 18's types\n * regardless — `<AsyncBlock />` is refused outright there.\n */\n renderSlot(this: void, name: string, ctx?: BlockRenderContext): ReactNode;\n}\n\n/**\n * One block type, as an author writes it.\n *\n * The engine's own definition leaves `supports` open, because its registry holds\n * blocks from every source and checks their keys at boot against whatever is\n * registered. Authoring is the moment a typo is cheap to catch, so this narrows\n * that one member and changes nothing else.\n *\n * @experimental Carried by the same freeze as `defineBlock`.\n */\nexport interface BlockDefinition<P extends object = Record<string, unknown>>\n extends Omit<\n EngineBlockDefinition<P, BlockRenderContext>,\n // `conditionalSlots` is withheld ON PURPOSE. It exists because a core block\n // needs it, and what a block author should write is a Block API freeze\n // decision — but an `@internal` tag removes nothing from a published type,\n // and this `Omit` inherits every property it does not name. Reserving it\n // takes naming it here; anything less lets a plugin compile against a\n // provisional shape and be broken when the freeze settles it.\n \"supports\" | \"render\" | \"conditionalSlots\"\n > {\n supports?: BlockSupports;\n /**\n * Renders the block.\n *\n * The promise is spelled out rather than left to `ReactNode`. React 19 added\n * promises to that type and React 18 did not, and this package supports both,\n * so an async block would compile against one peer and be rejected by the\n * other. Naming it here makes the async contract mean the same thing across\n * the range this package declares.\n */\n render(args: BlockRenderArgs<P>): BlockRenderResult;\n}\n\n/**\n * Declare a block.\n *\n * Returns its argument. It exists to infer the prop type from what is written\n * and to check the rest against the definition shape, which is what makes a\n * mistyped prop name or an unknown support key a compile error rather than a\n * boot one.\n *\n * There is deliberately no per-block context parameter. What a renderer\n * provides is one description per app, and a block that needs something unusual\n * declares it on `BlockRenderContext` where the whole app can see it. A block\n * naming its own context would be asserting privately that it will be handed\n * something, which nothing checks and no registry can honour.\n *\n * @experimental The block API is frozen at the end of the engine phase, not\n * now. Until then a contributed block may need changes when the definition\n * shape settles.\n */\nexport function defineBlock<P extends object>(\n definition: BlockDefinition<P>\n): BlockDefinition<P> {\n return definition;\n}\n\n/**\n * Supports settings meant to be shared between blocks.\n *\n * Written straight into a definition, a typo is caught: TypeScript checks a\n * literal for keys the target does not declare. Lifted into a variable first,\n * it is not, because that check applies only where the literal is written. This\n * puts the check back at the declaration, which is where the settings are.\n *\n * ```ts\n * const layoutSupports = blockSupports({ spacing: true, layout: true });\n * defineBlock<MyProps>({ …, supports: layoutSupports });\n * ```\n *\n * `satisfies BlockSupports` does the same thing and needs nothing from this\n * package; the helper exists because it reads as the obvious move and cannot be\n * forgotten halfway through.\n *\n * It cannot live on `defineBlock` itself: catching this needs the supplied\n * object's own keys inferred, and TypeScript infers nothing once any type\n * argument is written by hand, so `defineBlock<MyProps>` — the form nearly\n * every block uses — would stop checking anything at all.\n *\n * @experimental Carried by the same freeze as `defineBlock`.\n */\nexport function blockSupports<S extends BlockSupports>(\n supports: ExactSupports<S>\n): BlockSupports {\n return supports;\n}\n\n/**\n * @experimental Carried by the same freeze as `defineBlock`: these describe the\n * definition shape, so they change with it.\n */\nexport type {\n AnyBlockDefinition,\n InferBlockProps,\n PropSchema,\n SupportDefinition,\n} from \"@nextlyhq/blocks-engine\";\n\n/**\n * What a block's `render` returns.\n *\n * Declared here rather than re-exported. The engine's own is `unknown`, because\n * the engine serves any renderer and cannot name an output type; naming it there\n * would tie a runtime-free package to React. That leaves the re-exported name\n * useless for the thing an author would reach for it to do — a helper typed\n * `(args: BlockRenderArgs<P>) => BlockRenderResult` returns `unknown`, which does\n * not satisfy `BlockDefinition[\"render\"]`, so handing that helper to\n * `defineBlock` failed to compile.\n *\n * The promise is spelled out for the same reason `render` spells it out: React\n * 19 added promises to `ReactNode` and React 18 did not, and this package\n * supports both.\n *\n * @experimental Carried by the same freeze as `defineBlock`.\n */\nexport type BlockRenderResult = ReactNode | Promise<ReactNode>;\n\n/**\n * The rest of the definition's own vocabulary. Every one of these names a field\n * a block author fills in, so leaving them off this surface meant writing a slot\n * template, an example, or an editor entry against a type that could only be\n * reached by importing the engine directly — which is the one thing this subpath\n * exists to make unnecessary.\n *\n * `BlockSupportValue` is deliberately NOT among them. The engine's is\n * `boolean | Record<string, boolean>`, which is what its registry stores from\n * every source; offered here as authoring vocabulary it would undo the check\n * this module exists for, since `const spacing: BlockSupportValue = { paddding:\n * true }` accepts the typo the per-key flag unions refuse. A shared setting for\n * one key is written as `BlockSupports[\"spacing\"]`, which is checked, and a\n * whole object goes through `blockSupports()`.\n *\n * @experimental Carried by the same freeze as `defineBlock`.\n */\nexport type {\n BlockEditorMeta,\n BlockExample,\n BlockIcon,\n BlockIsland,\n BlockPart,\n BlockSeoContribution,\n BlockSeoImage,\n BlockVariation,\n ComponentPath,\n NodeStyles,\n SlotLock,\n SlotSpec,\n} from \"@nextlyhq/blocks-engine\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA2QA,SAAgB,YACd,YACoB;CACpB,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,cACd,UACe;CACf,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"blocks.mjs","names":[],"sources":["../src/blocks.ts"],"sourcesContent":["/**\n * Block authoring — the contracts a plugin contributing blocks to the page\n * builder needs.\n *\n * A subpath rather than the SDK's main entry, so a plugin that has nothing to\n * do with blocks never pulls the block engine into its type graph. The SDK\n * remains the single stable import surface a plugin author is offered; this\n * simply keeps a page-builder-specific vocabulary out of everyone else's way.\n *\n * The engine is a real dependency of this package rather than an optional peer,\n * because the types below are built on top of its own: they have to resolve for\n * an author who installed only the SDK, and under a strict `node_modules`\n * layout the page builder's copy is not reachable from their package. The\n * engine's registry is pinned to `globalThis`, so even a duplicated install\n * still reads and writes the one registry the page builder consumes.\n *\n * What an author writes is declared here rather than re-exported. `defineBlock`\n * and `BlockSupports` are this module's own so that `BlockSupportKeys` can be\n * augmented from a plugin's source, which only works for a module that plugin\n * can name.\n *\n * The registration side is not here. Contributing a block means calling the\n * page builder's own service — it is that plugin's registry, not core's — so\n * `blockRegistry` comes from `@nextlyhq/plugin-page-builder/blocks`, which is\n * also where a contributor already declares its `dependsOn`.\n *\n * @packageDocumentation\n */\n\nimport type {\n BlockDefinition as EngineBlockDefinition,\n BlockRenderArgs as EngineBlockRenderArgs,\n} from \"@nextlyhq/blocks-engine\";\nimport type { ReactNode } from \"react\";\n\n/**\n * The support keys a block may declare.\n *\n * Declared HERE rather than in the engine, and that placement is the whole\n * point. A module augmentation has to name a module that resolves from the file\n * doing the augmenting, and a plugin author installs this package: under a\n * strict `node_modules` layout the engine is a nested transitive dependency\n * their own source cannot name, so an augmentation pointed at it fails to\n * compile and the custom support silently never arrives.\n *\n * A plugin that calls `registerSupport()` adds its key to the vocabulary the\n * compiler checks against:\n *\n * ```ts\n * declare module \"@nextlyhq/plugin-sdk/blocks\" {\n * interface BlockSupportKeys {\n * animation: \"enter\" | \"exit\";\n * parallax: true;\n * }\n * }\n * ```\n *\n * Declaration merging rather than an index signature: an index signature accepts\n * every key, which is what leaves a misspelled `spaceing` to be found at boot,\n * in someone else's app, instead of while it is being written.\n *\n * One rule reads the value: a union of strings names the sub-flags the support\n * recognises, and anything else means the support is all-or-nothing. So a nested\n * typo is caught in the same breath as a top-level one — `{ spacing: { paddding:\n * true } }` enables nothing at all, and finding that out at boot is exactly what\n * this exists to prevent — while a support with no finer granularity can be\n * written the way it reads, as `never` or as `true`.\n *\n * The built-in keys are the style catalog's groups plus the capabilities that\n * have no catalog group of their own. A test holds both the keys and their\n * flags to what the registry actually accepts, so the two cannot drift.\n *\n * @experimental Carried by the same freeze as `defineBlock`.\n */\nexport interface BlockSupportKeys {\n /** Padding and margin. */\n spacing: \"margin\" | \"padding\";\n /** Flow, alignment and gap. */\n layout: never;\n /** Width, height and their limits. */\n dimensions: never;\n /** Font, size, weight, line height and letter spacing. */\n typography: never;\n /** Text and link colours. */\n color: \"text\" | \"link\";\n /** Background colour, image and gradient. */\n background: \"color\" | \"image\" | \"gradient\";\n /** Border lines and corner rounding. */\n border: \"line\" | \"radius\";\n /** Box and text shadows. */\n shadow: never;\n /** Opacity, filters and transforms. */\n effects: never;\n /** Positioning and stacking. */\n position: never;\n /** Container-query behaviour. */\n container: never;\n /** Marker style on a list. */\n list: never;\n /** Author-written CSS on this block. Gates a capability, not a style group. */\n customCss: never;\n}\n\n/**\n * What one support key accepts, given the sub-flags it declares.\n *\n * The two cases are kept apart rather than both handed to `Record`, because\n * `Record` demands a property key and a support that declares no flags has none\n * to give. Feeding it either sentinel is unsound in opposite directions: `true`\n * is not a property key at all, so the mapped type stops instantiating and an\n * augmenting plugin's build fails on the declaration rather than on anything it\n * wrote; `never` produces `Partial<Record<never, boolean>>`, which is `{}`, and\n * `{}` accepts every object — so `{ layout: { typo: true } }` type-checks and is\n * refused only later, by the registry, at boot.\n *\n * `[F] extends [never]` is asked first and in tuple form. Bare `F extends never`\n * distributes and answers for the empty union rather than about it, and\n * `[never] extends [string]` is true, so a `never` reaching the string case\n * would rebuild the same `{}`.\n */\ntype SupportSetting<F> = [F] extends [never]\n ? boolean\n : [F] extends [string]\n ? boolean | Partial<Record<F & string, boolean>>\n : boolean;\n\n/**\n * Style capabilities a block opts into: `true` for a whole group, or an object\n * naming the sub-flags it wants.\n *\n * @experimental Carried by the same freeze as `defineBlock`.\n */\nexport type BlockSupports = {\n [K in keyof BlockSupportKeys]?: SupportSetting<BlockSupportKeys[K]>;\n};\n\n/**\n * Supports as written at a definition, with unknown keys refused.\n *\n * TypeScript checks for excess properties only on a literal written in place,\n * so lifting settings into a shared object skips it: `const shared = { spacing:\n * true, spaceing: true }` assigns to `BlockSupports` without complaint, and the\n * typo survives to be caught at boot in someone else's app — which is the whole\n * failure this vocabulary exists to move earlier.\n *\n * Naming the offending key as `never` refuses it wherever it was written.\n */\ntype ExactSupports<S> = S & {\n [K in Exclude<keyof S, keyof BlockSupportKeys>]: never;\n};\n\n/**\n * Everything a renderer makes available to every block it draws.\n *\n * ONE description per app, rather than each block inventing its own. A block\n * author writes `defineBlock<MyProps>` and `ctx` is already typed as whatever\n * this app's renderer provides, with no type written by hand; a block that\n * needs something unusual has to add it here, which is an app-wide statement\n * anyone can see rather than a quiet assumption inside one file.\n *\n * A renderer declares what it supplies by augmenting this from its own package:\n *\n * ```ts\n * declare module \"@nextlyhq/plugin-sdk/blocks\" {\n * interface BlockRenderContext {\n * data?: DataProvider;\n * }\n * }\n * ```\n *\n * `locale` is here because every renderer of localized content has one, and a\n * block that varies its own output by language should not have to reach past\n * this interface to find out which.\n *\n * @experimental Carried by the same freeze as `defineBlock`.\n */\nexport interface BlockRenderContext {\n /** The locale being rendered, when the renderer is rendering one. */\n locale?: string;\n}\n\n/**\n * What a block's `render` receives.\n *\n * The engine's own version leaves both the context and the output unnamed,\n * because the engine serves any renderer and cannot know either. This one names\n * both: the context is what THIS app's renderer provides, which is what lets a\n * block read `ctx.data` with no type written by hand, and the output is React,\n * which is what lets a block place a slot straight into its JSX instead of\n * asserting a type over it.\n *\n * @experimental Carried by the same freeze as `defineBlock`.\n */\nexport interface BlockRenderArgs<P>\n extends Omit<EngineBlockRenderArgs<P, BlockRenderContext>, \"renderSlot\"> {\n /**\n * Render one of this block's slots, optionally under a different context.\n *\n * `ReactNode` rather than the `ReactNode | Promise<ReactNode>` that `render`\n * returns, and the asymmetry is deliberate: this value is one a block places\n * into its own JSX, and that union is not a legal child. React admits only\n * `Promise<AwaitedReactNode>`, a promise of a settled node, so a promise that\n * may itself yield a promise is refused. Widening here would move the error\n * onto every block that draws a slot.\n *\n * It still admits a pending slot, because React counts\n * `Promise<AwaitedReactNode>` as a `ReactNode`: a renderer may hand one back\n * and the block places it unchanged.\n */\n renderSlot(this: void, name: string, ctx?: BlockRenderContext): ReactNode;\n}\n\n/**\n * One block type, as an author writes it.\n *\n * The engine's own definition leaves `supports` open, because its registry holds\n * blocks from every source and checks their keys at boot against whatever is\n * registered. Authoring is the moment a typo is cheap to catch, so this narrows\n * that one member and changes nothing else.\n *\n * @experimental Carried by the same freeze as `defineBlock`.\n */\nexport interface BlockDefinition<P extends object = Record<string, unknown>>\n extends Omit<\n EngineBlockDefinition<P, BlockRenderContext>,\n // `conditionalSlots` is withheld ON PURPOSE. It exists because a core block\n // needs it, and what a block author should write is a Block API freeze\n // decision — but an `@internal` tag removes nothing from a published type,\n // and this `Omit` inherits every property it does not name. Reserving it\n // takes naming it here; anything less lets a plugin compile against a\n // provisional shape and be broken when the freeze settles it.\n \"supports\" | \"render\" | \"conditionalSlots\"\n > {\n supports?: BlockSupports;\n /**\n * Renders the block.\n *\n * The promise is spelled out rather than left to `ReactNode`, which admits\n * only a promise of a settled node: an async block's `render` returns a\n * promise of anything it could return synchronously, and spelling it out\n * says so.\n */\n render(args: BlockRenderArgs<P>): BlockRenderResult;\n}\n\n/**\n * Declare a block.\n *\n * Returns its argument. It exists to infer the prop type from what is written\n * and to check the rest against the definition shape, which is what makes a\n * mistyped prop name or an unknown support key a compile error rather than a\n * boot one.\n *\n * There is deliberately no per-block context parameter. What a renderer\n * provides is one description per app, and a block that needs something unusual\n * declares it on `BlockRenderContext` where the whole app can see it. A block\n * naming its own context would be asserting privately that it will be handed\n * something, which nothing checks and no registry can honour.\n *\n * @experimental The block API is frozen at the end of the engine phase, not\n * now. Until then a contributed block may need changes when the definition\n * shape settles.\n */\nexport function defineBlock<P extends object>(\n definition: BlockDefinition<P>\n): BlockDefinition<P> {\n return definition;\n}\n\n/**\n * Supports settings meant to be shared between blocks.\n *\n * Written straight into a definition, a typo is caught: TypeScript checks a\n * literal for keys the target does not declare. Lifted into a variable first,\n * it is not, because that check applies only where the literal is written. This\n * puts the check back at the declaration, which is where the settings are.\n *\n * ```ts\n * const layoutSupports = blockSupports({ spacing: true, layout: true });\n * defineBlock<MyProps>({ …, supports: layoutSupports });\n * ```\n *\n * `satisfies BlockSupports` does the same thing and needs nothing from this\n * package; the helper exists because it reads as the obvious move and cannot be\n * forgotten halfway through.\n *\n * It cannot live on `defineBlock` itself: catching this needs the supplied\n * object's own keys inferred, and TypeScript infers nothing once any type\n * argument is written by hand, so `defineBlock<MyProps>` — the form nearly\n * every block uses — would stop checking anything at all.\n *\n * @experimental Carried by the same freeze as `defineBlock`.\n */\nexport function blockSupports<S extends BlockSupports>(\n supports: ExactSupports<S>\n): BlockSupports {\n return supports;\n}\n\n/**\n * @experimental Carried by the same freeze as `defineBlock`: these describe the\n * definition shape, so they change with it.\n */\nexport type {\n AnyBlockDefinition,\n InferBlockProps,\n PropSchema,\n SupportDefinition,\n} from \"@nextlyhq/blocks-engine\";\n\n/**\n * What a block's `render` returns.\n *\n * Declared here rather than re-exported. The engine's own is `unknown`, because\n * the engine serves any renderer and cannot name an output type; naming it there\n * would tie a runtime-free package to React. That leaves the re-exported name\n * useless for the thing an author would reach for it to do — a helper typed\n * `(args: BlockRenderArgs<P>) => BlockRenderResult` returns `unknown`, which does\n * not satisfy `BlockDefinition[\"render\"]`, so handing that helper to\n * `defineBlock` failed to compile.\n *\n * The promise is spelled out for the same reason `render` spells it out.\n *\n * @experimental Carried by the same freeze as `defineBlock`.\n */\nexport type BlockRenderResult = ReactNode | Promise<ReactNode>;\n\n/**\n * What a block's own inspector (`editor.component`) is given: the selected\n * node, its props, `commit(name, value)` through the editor's own write path,\n * and whether the block is read-only. The editor refuses a commit while it is,\n * and one to a non-content prop inside a `contentOnly` area, whatever the\n * component does.\n *\n * @experimental The contract will grow with the editor's controls registry.\n */\nexport type { BlockInspectorProps } from \"@nextlyhq/blocks-engine\";\n\n/**\n * The rest of the definition's own vocabulary. Every one of these names a field\n * a block author fills in, so leaving them off this surface meant writing a slot\n * template, an example, or an editor entry against a type that could only be\n * reached by importing the engine directly — which is the one thing this subpath\n * exists to make unnecessary.\n *\n * `BlockSupportValue` is deliberately NOT among them. The engine's is\n * `boolean | Record<string, boolean>`, which is what its registry stores from\n * every source; offered here as authoring vocabulary it would undo the check\n * this module exists for, since `const spacing: BlockSupportValue = { paddding:\n * true }` accepts the typo the per-key flag unions refuse. A shared setting for\n * one key is written as `BlockSupports[\"spacing\"]`, which is checked, and a\n * whole object goes through `blockSupports()`.\n *\n * @experimental Carried by the same freeze as `defineBlock`.\n */\nexport type {\n BlockEditorMeta,\n BlockExample,\n BlockIcon,\n BlockIsland,\n BlockPart,\n BlockSeoContribution,\n BlockSeoImage,\n BlockVariation,\n ComponentPath,\n NodeStyles,\n SlotLock,\n SlotSpec,\n} from \"@nextlyhq/blocks-engine\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuQA,SAAgB,YACd,YACoB;CACpB,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,cACd,UACe;CACf,OAAO;AACT"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Action, AddressableField, AddressableFieldsOptions, AdmittedReservation, AuthEventName, AuthEvents, AuthHookName, AuthHooks, AuthInput, AuthLimitAnswer, AuthOutcome, AuthStrategy, AuthUser, AuthenticatedScope, AuthorableFieldConfig, AuthoredDraftSplitCollection, BatchOperationResult, BeforeOperationArgs, BeforeOperationContext, BeforeOperationHandler, BreachedPasswordsConfig, BulkUpdateEntry, Challenge, ChallengeDefinition, CompleteLoginOptions, ComponentPath, CoreFilterSeam,
|
|
1
|
+
import { Action, AddressableField, AddressableFieldsOptions, AdmittedReservation, AnyWidget, AttentionCount, AttentionItem, AuthEventName, AuthEvents, AuthHookName, AuthHooks, AuthInput, AuthLimitAnswer, AuthOutcome, AuthStrategy, AuthUser, AuthenticatedScope, AuthorableFieldConfig, AuthoredDraftSplitCollection, BatchOperationResult, BeforeOperationArgs, BeforeOperationContext, BeforeOperationHandler, BreachedPasswordsConfig, BulkUpdateEntry, Challenge, ChallengeDefinition, CompleteLoginOptions, ComponentPath, CoreFilterSeam, CoreView, DEFAULT_ADMIN_PATH, Decision, DocumentEventName, DocumentEvents, DraftSplitDisabledReason, DraftSplitEligibility, EmailAfterSendValue, EmailFilterContext, EmailPayloadFilterValue, EmailProviderCapabilities, EmailProviderConfigField, EmailProviderDefinition, EmailProviderDescriptor, EmailTemplateData, EntryVerdict, EventBus, EventEnvelope, EventHandler, EventName, FieldAdminOptions, FieldConfig, FieldValueDeclaration, FieldValueDeclarationInput, Filter, FilterSeams, FrozenCopy, FrozenValue, GrantedPermission, GridSize, HookContext, HookContextPhase, HookHandler, HookPointContext, HookPointNameOf, HookPointPayload, HookPointPayloads, HookPointValue, HookType, JobContext, JobDefinition, JobDefinitionInput, JobInputFor, JobRetryPolicy, JobSlug, JsonObject, JsonValue, LimitCheck, LimitEntry, LimitOutcome, LimitReservation, LimitRule, LimitTarget, ListQueryFilterContext, ListQueryWhere, MAX_ATTENTION_ITEMS_PER_PLUGIN, MAX_EMAIL_PROVIDER_TYPE_LENGTH, MAX_JOB_SLUG_LENGTH, MediaEventName, MediaEvents, Middleware, NavCollectionItem, NavFilterContext, NextlyError, NextlyPrincipals, OneTimeSecrets, OpaqueSecrets, PLUGIN_CATEGORIES, PaginatedResult, PaginationMeta, PasswordCheck, PasswordHelper, PasswordRules, PasswordTooLongError, PermissionSlug, PluginActionRegistry, PluginAdminContributions, PluginAdminPage, PluginAuditApi, PluginAuditDeclaration, PluginAuthApi, PluginCapabilities, PluginCategory, PluginCollectionService, PluginCollectionTransaction, PluginCollectionView, PluginConfig, PluginContext, PluginContributions, PluginDataFieldConfig, PluginDatabase, PluginDeclaration, PluginDefinition, PluginEmailProvider, PluginEmailService, PluginEmailSettings, PluginEmailTemplate, PluginFieldCodegen, PluginFieldCodegenImport, PluginFieldInput, PluginFieldInstance, PluginFieldIssue, PluginFieldType, PluginFieldValidateArgs, PluginFieldValidationResult, PluginFieldWrite, PluginFilterRegistry, PluginHookPointDeclaration, PluginHookRegistry, PluginInsert, PluginLimiter, PluginMediaService, PluginMenuItem, PluginNavSection, PluginPermission, PluginPinOptions, PluginPinTransaction, PluginPrincipalsApi, PluginRawDatabase, PluginRole, PluginRoute, PluginRouteCaller, PluginRouteContext, PluginRouteHandler, PluginRouteIdentity, PluginRouteLimitKey, PluginRouteMount, PluginRoutePermissionResolver, PluginRoutePermissionScope, PluginRoutePrincipal, PluginRouteRateLimit, PluginSecurityApi, PluginSettingsApi, PluginSingleRecord, PluginSinglesResult, PluginSinglesService, PluginStoredValue, PluginStoredValueTarget, PluginSummary, PluginTransaction, PluginUserService, PluginVersionPin, PluginVersionPinHolder, PluginVersionPins, PluginVersionsService, Principal, PrincipalAnswer, PrincipalAttributeDescriptors, PrincipalAttributeType, PrincipalAttributeTypeOf, PrincipalAttributeValue, PrincipalAttributes, PrincipalAttributesOf, PrincipalKindContribution, PrincipalKindDefinition, PrincipalRecord, PrincipalRef, PrincipalReportOptions, ProviderAvailability, QueryOptions, QueueJobArgs, QueueJobResult, ReadCaller, ReadableContent, ReadableContentCaller, ReadableContentEntity, RegisteredEmailProvider, RequestContext, ResolvedDraftSplitCollection, ResolverOptions, RouteMethod, RunAsPrincipal, ScheduledTask, SecretData, SerializedFieldConfig, ServiceOpts, SettingEditorProps, TIMESERIES_INTERVALS, TimeseriesInterval, TrustedHtml, TxOption, UnvalidatedAddressableField, UserCreatedPayload, UserDeletedPayload, UserEventName, UserEvents, ValidateFieldValuesOptions, ValidationIssue, VersionPinHolderDefinition, VersionRef, WIDGET_CONDITIONS, WIDGET_LIFECYCLES, WIDGET_OPS, WIDGET_SOURCE_FIELD_TYPES, WIDGET_SOURCE_KINDS, WidgetAccess, WidgetAccessGate, WidgetCondition, WidgetData, WidgetFieldChoice, WidgetInterval, WidgetLifecycle, WidgetLoadSize, WidgetOp, WidgetPreviewCase, WidgetProps, WidgetQuery, WidgetRange, WidgetReadServices, WidgetRenderSize, WidgetScope, WidgetSetting, WidgetSizeDeclaration, WidgetSource, WidgetSourceField, WidgetSourceFieldType, WidgetSourceKind, WidgetSourceResolver, WidgetSummary, WidgetSummaryCount, WidgetView, addressableFields, callerReadOptions, checkbox, collectDeclarations, collectionDraftSplit, defineAttentionItem, defineEmailProvider, defineJob, definePlugin, defineWidget, getCachedNextly, group, isLocaleSelector, isPluginCategory, isTimeseriesInterval, markHtml, narrowScope, option, pluginAdminSlug, pluginField, readableContent, resolvedCollectionDraftSplit, resolvedCollectionView, respondAction, respondDoc, respondList, respondMutation, routePathIsLiteral, rowsThatFit, sanitizeAdminPath, setting, text, textarea, trustedClientIp, upload, validateFieldValues } from "nextly";
|
|
2
|
+
import { ChartSlot as WidgetChartSlot, chartColour as widgetChartColour, formatChange as formatWidgetChange, formatCount as formatWidgetNumber } from "@nextlyhq/ui/format";
|
|
2
3
|
/**
|
|
3
4
|
* @experimental A secret value that auto-redacts at every common leak vector —
|
|
4
5
|
* `JSON.stringify` (`toJSON`), `String()`/template interpolation (`toString`),
|
|
@@ -18,5 +19,5 @@ export declare class Secret<T = string> {
|
|
|
18
19
|
export declare function secret<T>(value: T): Secret<T>;
|
|
19
20
|
/** @experimental True if `value` is a {@link Secret}. */
|
|
20
21
|
export declare function isSecret(value: unknown): value is Secret<unknown>;
|
|
21
|
-
export { type Action, type AddressableField, type AddressableFieldsOptions, type AdmittedReservation, type AuthEventName, AuthEvents, type AuthHookName, type AuthHooks, type AuthInput, type AuthLimitAnswer, type AuthOutcome, type AuthStrategy, type AuthUser, type AuthenticatedScope, type AuthorableFieldConfig, type AuthoredDraftSplitCollection, type BatchOperationResult, type BeforeOperationArgs, type BeforeOperationContext, type BeforeOperationHandler, type BreachedPasswordsConfig, type BulkUpdateEntry, type Challenge, type ChallengeDefinition, type CompleteLoginOptions, type ComponentPath, type CoreFilterSeam,
|
|
22
|
+
export { type Action, type AddressableField, type AddressableFieldsOptions, type AdmittedReservation, type AnyWidget, type AttentionCount, type AttentionItem, type AuthEventName, AuthEvents, type AuthHookName, type AuthHooks, type AuthInput, type AuthLimitAnswer, type AuthOutcome, type AuthStrategy, type AuthUser, type AuthenticatedScope, type AuthorableFieldConfig, type AuthoredDraftSplitCollection, type BatchOperationResult, type BeforeOperationArgs, type BeforeOperationContext, type BeforeOperationHandler, type BreachedPasswordsConfig, type BulkUpdateEntry, type Challenge, type ChallengeDefinition, type CompleteLoginOptions, type ComponentPath, type CoreFilterSeam, type CoreView, DEFAULT_ADMIN_PATH, type Decision, type DocumentEventName, DocumentEvents, type DraftSplitDisabledReason, type DraftSplitEligibility, type EmailAfterSendValue, type EmailFilterContext, type EmailPayloadFilterValue, type EmailProviderCapabilities, type EmailProviderConfigField, type EmailProviderDefinition, type EmailProviderDescriptor, type EmailTemplateData, type EntryVerdict, type EventBus, type EventEnvelope, type EventHandler, type EventName, type FieldAdminOptions, type FieldConfig, type FieldValueDeclaration, type FieldValueDeclarationInput, type Filter, FilterSeams, type FrozenCopy, type FrozenValue, type GrantedPermission, type GridSize, type HookContext, type HookContextPhase, type HookHandler, type HookPointContext, type HookPointNameOf, type HookPointPayload, type HookPointPayloads, type HookPointValue, type HookType, type JobContext, type JobDefinition, type JobDefinitionInput, type JobInputFor, type JobRetryPolicy, type JobSlug, type JsonObject, type JsonValue, type LimitCheck, type LimitEntry, type LimitOutcome, type LimitReservation, type LimitRule, type LimitTarget, type ListQueryFilterContext, type ListQueryWhere, MAX_ATTENTION_ITEMS_PER_PLUGIN, MAX_EMAIL_PROVIDER_TYPE_LENGTH, MAX_JOB_SLUG_LENGTH, type MediaEventName, MediaEvents, type Middleware, type NavCollectionItem, type NavFilterContext, NextlyError, type NextlyPrincipals, type OneTimeSecrets, type OpaqueSecrets, PLUGIN_CATEGORIES, type PaginatedResult, type PaginationMeta, type PasswordCheck, type PasswordHelper, type PasswordRules, PasswordTooLongError, type PermissionSlug, type PluginActionRegistry, type PluginAdminContributions, type PluginAdminPage, type PluginAuditApi, type PluginAuditDeclaration, type PluginAuthApi, type PluginCapabilities, type PluginCategory, type PluginCollectionService, type PluginCollectionTransaction, type PluginCollectionView, type PluginConfig, type PluginContext, type PluginContributions, type PluginDataFieldConfig, type PluginDatabase, type PluginDeclaration, type PluginDefinition, type PluginEmailProvider, type PluginEmailService, type PluginEmailSettings, type PluginEmailTemplate, type PluginFieldCodegen, type PluginFieldCodegenImport, type PluginFieldInput, type PluginFieldInstance, type PluginFieldIssue, type PluginFieldType, type PluginFieldValidateArgs, type PluginFieldValidationResult, type PluginFieldWrite, type PluginFilterRegistry, type PluginHookPointDeclaration, type PluginHookRegistry, type PluginInsert, type PluginLimiter, type PluginMediaService, type PluginMenuItem, type PluginNavSection, type PluginPermission, type PluginPinOptions, type PluginPinTransaction, type PluginPrincipalsApi, type PluginRawDatabase, type PluginRole, type PluginRoute, type PluginRouteCaller, type PluginRouteContext, type PluginRouteHandler, type PluginRouteIdentity, type PluginRouteLimitKey, type PluginRouteMount, type PluginRoutePermissionResolver, type PluginRoutePermissionScope, type PluginRoutePrincipal, type PluginRouteRateLimit, type PluginSecurityApi, type PluginSettingsApi, type PluginSingleRecord, type PluginSinglesResult, type PluginSinglesService, type PluginStoredValue, type PluginStoredValueTarget, type PluginSummary, type PluginTransaction, type PluginUserService, type PluginVersionPin, type PluginVersionPinHolder, type PluginVersionPins, type PluginVersionsService, type Principal, type PrincipalAnswer, type PrincipalAttributeDescriptors, type PrincipalAttributeType, type PrincipalAttributeTypeOf, type PrincipalAttributeValue, type PrincipalAttributes, type PrincipalAttributesOf, type PrincipalKindContribution, type PrincipalKindDefinition, type PrincipalRecord, type PrincipalRef, type PrincipalReportOptions, type ProviderAvailability, type QueryOptions, type QueueJobArgs, type QueueJobResult, type ReadCaller, type ReadableContent, type ReadableContentCaller, type ReadableContentEntity, type RegisteredEmailProvider, type RequestContext, type ResolvedDraftSplitCollection, type ResolverOptions, type RouteMethod, type RunAsPrincipal, type ScheduledTask, type SecretData, type SerializedFieldConfig, type ServiceOpts, type SettingEditorProps, TIMESERIES_INTERVALS, type TimeseriesInterval, TrustedHtml, type TxOption, type UnvalidatedAddressableField, type UserCreatedPayload, type UserDeletedPayload, type UserEventName, UserEvents, type ValidateFieldValuesOptions, type ValidationIssue, type VersionPinHolderDefinition, type VersionRef, WIDGET_CONDITIONS, WIDGET_LIFECYCLES, WIDGET_OPS, WIDGET_SOURCE_FIELD_TYPES, WIDGET_SOURCE_KINDS, type WidgetAccess, type WidgetAccessGate, type WidgetChartSlot, type WidgetCondition, type WidgetData, type WidgetFieldChoice, type WidgetInterval, type WidgetLifecycle, type WidgetLoadSize, type WidgetOp, type WidgetPreviewCase, type WidgetProps, type WidgetQuery, type WidgetRange, type WidgetReadServices, type WidgetRenderSize, type WidgetScope, type WidgetSetting, type WidgetSizeDeclaration, type WidgetSource, type WidgetSourceField, type WidgetSourceFieldType, type WidgetSourceKind, type WidgetSourceResolver, type WidgetSummary, type WidgetSummaryCount, type WidgetView, addressableFields, callerReadOptions, checkbox, collectDeclarations, collectionDraftSplit, defineAttentionItem, defineEmailProvider, defineJob, definePlugin, defineWidget, formatWidgetChange, formatWidgetNumber, getCachedNextly, group, isLocaleSelector, isPluginCategory, isTimeseriesInterval, markHtml, narrowScope, option, pluginAdminSlug, pluginField, readableContent, resolvedCollectionDraftSplit, resolvedCollectionView, respondAction, respondDoc, respondList, respondMutation, routePathIsLiteral, rowsThatFit, sanitizeAdminPath, setting, text, textarea, trustedClientIp, upload, validateFieldValues, widgetChartColour };
|
|
22
23
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { AuthEvents, DEFAULT_ADMIN_PATH, DocumentEvents, FilterSeams, MAX_EMAIL_PROVIDER_TYPE_LENGTH, MAX_JOB_SLUG_LENGTH, MediaEvents, NextlyError, PLUGIN_CATEGORIES, PasswordTooLongError, TIMESERIES_INTERVALS, TrustedHtml, UserEvents,
|
|
1
|
+
import { AuthEvents, DEFAULT_ADMIN_PATH, DocumentEvents, FilterSeams, MAX_ATTENTION_ITEMS_PER_PLUGIN, MAX_EMAIL_PROVIDER_TYPE_LENGTH, MAX_JOB_SLUG_LENGTH, MediaEvents, NextlyError, PLUGIN_CATEGORIES, PasswordTooLongError, TIMESERIES_INTERVALS, TrustedHtml, UserEvents, WIDGET_CONDITIONS, WIDGET_LIFECYCLES, WIDGET_OPS, WIDGET_SOURCE_FIELD_TYPES, WIDGET_SOURCE_KINDS, addressableFields, callerReadOptions, checkbox, collectDeclarations, collectionDraftSplit, defineAttentionItem, defineEmailProvider, defineJob, definePlugin, defineWidget, getCachedNextly, group, isLocaleSelector, isPluginCategory, isTimeseriesInterval, markHtml, narrowScope, option, pluginAdminSlug, pluginField, readableContent, resolvedCollectionDraftSplit, resolvedCollectionView, respondAction, respondDoc, respondList, respondMutation, routePathIsLiteral, rowsThatFit, sanitizeAdminPath, setting, text, textarea, trustedClientIp, upload, validateFieldValues } from "nextly";
|
|
2
|
+
import { chartColour as widgetChartColour, formatChange as formatWidgetChange, formatCount as formatWidgetNumber } from "@nextlyhq/ui/format";
|
|
2
3
|
// src/secret.ts
|
|
3
4
|
const REDACTED = "[redacted]";
|
|
4
5
|
/**
|
|
@@ -39,6 +40,6 @@ function secret(value) {
|
|
|
39
40
|
function isSecret(value) {
|
|
40
41
|
return value instanceof Secret;
|
|
41
42
|
}
|
|
42
|
-
export { AuthEvents, DEFAULT_ADMIN_PATH, DocumentEvents, FilterSeams, MAX_EMAIL_PROVIDER_TYPE_LENGTH, MAX_JOB_SLUG_LENGTH, MediaEvents, NextlyError, PLUGIN_CATEGORIES, PasswordTooLongError, Secret, TIMESERIES_INTERVALS, TrustedHtml, UserEvents,
|
|
43
|
+
export { AuthEvents, DEFAULT_ADMIN_PATH, DocumentEvents, FilterSeams, MAX_ATTENTION_ITEMS_PER_PLUGIN, MAX_EMAIL_PROVIDER_TYPE_LENGTH, MAX_JOB_SLUG_LENGTH, MediaEvents, NextlyError, PLUGIN_CATEGORIES, PasswordTooLongError, Secret, TIMESERIES_INTERVALS, TrustedHtml, UserEvents, WIDGET_CONDITIONS, WIDGET_LIFECYCLES, WIDGET_OPS, WIDGET_SOURCE_FIELD_TYPES, WIDGET_SOURCE_KINDS, addressableFields, callerReadOptions, checkbox, collectDeclarations, collectionDraftSplit, defineAttentionItem, defineEmailProvider, defineJob, definePlugin, defineWidget, formatWidgetChange, formatWidgetNumber, getCachedNextly, group, isLocaleSelector, isPluginCategory, isSecret, isTimeseriesInterval, markHtml, narrowScope, option, pluginAdminSlug, pluginField, readableContent, resolvedCollectionDraftSplit, resolvedCollectionView, respondAction, respondDoc, respondList, respondMutation, routePathIsLiteral, rowsThatFit, sanitizeAdminPath, secret, setting, text, textarea, trustedClientIp, upload, validateFieldValues, widgetChartColour };
|
|
43
44
|
|
|
44
45
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/secret.ts"],"sourcesContent":["const REDACTED = \"[redacted]\";\n\n/**\n * @experimental A secret value that auto-redacts at every common leak vector —\n * `JSON.stringify` (`toJSON`), `String()`/template interpolation (`toString`),\n * and `console.log`/`util.inspect` (the node inspect symbol). The real value is\n * available only via the explicit, greppable `.reveal()`. Wrap secret config /\n * env values (D37): `secret(process.env.API_KEY)`.\n */\nexport class Secret<T = string> {\n readonly #value: T;\n constructor(value: T) {\n this.#value = value;\n }\n /** Return the underlying secret value. The only way to read it. */\n reveal(): T {\n return this.#value;\n }\n toJSON(): string {\n return REDACTED;\n }\n toString(): string {\n return REDACTED;\n }\n}\n\n// `util.inspect` and `console.log` read a custom rendering from Node's own\n// registered symbol, which `Symbol.for` returns without importing `node:util`.\n// Defined on the prototype as a class method would be (not enumerable), rather\n// than in the class: a member under a computed key cannot be declared from the\n// source alone, and the published declaration never named it.\nObject.defineProperty(\n Secret.prototype,\n Symbol.for(\"nodejs.util.inspect.custom\"),\n {\n value(): string {\n return REDACTED;\n },\n writable: true,\n configurable: true,\n }\n);\n\n/** @experimental Wrap a value so it redacts unless explicitly `.reveal()`ed (D37). */\nexport function secret<T>(value: T): Secret<T> {\n return new Secret(value);\n}\n\n/** @experimental True if `value` is a {@link Secret}. */\nexport function isSecret(value: unknown): value is Secret<unknown> {\n return value instanceof Secret;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/secret.ts"],"sourcesContent":["const REDACTED = \"[redacted]\";\n\n/**\n * @experimental A secret value that auto-redacts at every common leak vector —\n * `JSON.stringify` (`toJSON`), `String()`/template interpolation (`toString`),\n * and `console.log`/`util.inspect` (the node inspect symbol). The real value is\n * available only via the explicit, greppable `.reveal()`. Wrap secret config /\n * env values (D37): `secret(process.env.API_KEY)`.\n */\nexport class Secret<T = string> {\n readonly #value: T;\n constructor(value: T) {\n this.#value = value;\n }\n /** Return the underlying secret value. The only way to read it. */\n reveal(): T {\n return this.#value;\n }\n toJSON(): string {\n return REDACTED;\n }\n toString(): string {\n return REDACTED;\n }\n}\n\n// `util.inspect` and `console.log` read a custom rendering from Node's own\n// registered symbol, which `Symbol.for` returns without importing `node:util`.\n// Defined on the prototype as a class method would be (not enumerable), rather\n// than in the class: a member under a computed key cannot be declared from the\n// source alone, and the published declaration never named it.\nObject.defineProperty(\n Secret.prototype,\n Symbol.for(\"nodejs.util.inspect.custom\"),\n {\n value(): string {\n return REDACTED;\n },\n writable: true,\n configurable: true,\n }\n);\n\n/** @experimental Wrap a value so it redacts unless explicitly `.reveal()`ed (D37). */\nexport function secret<T>(value: T): Secret<T> {\n return new Secret(value);\n}\n\n/** @experimental True if `value` is a {@link Secret}. */\nexport function isSecret(value: unknown): value is Secret<unknown> {\n return value instanceof Secret;\n}\n"],"mappings":";;;AAAA,MAAM,WAAW;;;;;;;;AASjB,IAAa,SAAb,MAAgC;CAC9B;CACA,YAAY,OAAU;EACpB,KAAK,SAAS;CAChB;;CAEA,SAAY;EACV,OAAO,KAAK;CACd;CACA,SAAiB;EACf,OAAO;CACT;CACA,WAAmB;EACjB,OAAO;CACT;AACF;AAOA,OAAO,eACL,OAAO,WACP,OAAO,IAAI,4BAA4B,GACvC;CACE,QAAgB;EACd,OAAO;CACT;CACA,UAAU;CACV,cAAc;AAChB,CACF;;AAGA,SAAgB,OAAU,OAAqB;CAC7C,OAAO,IAAI,OAAO,KAAK;AACzB;;AAGA,SAAgB,SAAS,OAA0C;CACjE,OAAO,iBAAiB;AAC1B"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { AnyWidget, WidgetData } from "nextly";
|
|
2
|
+
import { WidgetLoadResult } from "nextly/testing/widget-card";
|
|
3
|
+
import { ComponentType, JSX } from "react";
|
|
4
|
+
/** A card's states: each a load can answer, and `loading`, which only a card shows. */
|
|
5
|
+
export type WidgetCardState = WidgetLoadResult<unknown>["state"] | "loading";
|
|
6
|
+
/** The card a hand-made case draws: a state, and what that state carries. */
|
|
7
|
+
type HandMade<W> = {
|
|
8
|
+
state: "loading";
|
|
9
|
+
} | {
|
|
10
|
+
state: "ready" | "empty";
|
|
11
|
+
data: WidgetData<W>;
|
|
12
|
+
} | {
|
|
13
|
+
state: "needs-setting";
|
|
14
|
+
setting: string;
|
|
15
|
+
} | {
|
|
16
|
+
state: "unavailable" | "not-shown";
|
|
17
|
+
} | {
|
|
18
|
+
state: "error";
|
|
19
|
+
error: string;
|
|
20
|
+
};
|
|
21
|
+
export type RenderWidgetCardOptions<W> = ({
|
|
22
|
+
result: WidgetLoadResult<W>;
|
|
23
|
+
} | HandMade<W>) & {
|
|
24
|
+
/** The card's size, and the tier it is drawn at; the widget's starting size when left out. */
|
|
25
|
+
size?: {
|
|
26
|
+
w: number;
|
|
27
|
+
h: number;
|
|
28
|
+
tier?: "small" | "medium" | "large";
|
|
29
|
+
};
|
|
30
|
+
/** The colour scheme the card is drawn in; light when left out. */
|
|
31
|
+
theme?: "light" | "dark";
|
|
32
|
+
/** The component a view of the widget's own draws with. */
|
|
33
|
+
component?: ComponentType<never>;
|
|
34
|
+
};
|
|
35
|
+
/** The card's element, for a test to render with its own renderer. */
|
|
36
|
+
export declare function renderWidgetCard<W extends AnyWidget>(widget: W, options: RenderWidgetCardOptions<W>): JSX.Element;
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=admin.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { widgetCardElement } from "@nextlyhq/admin/testing";
|
|
2
|
+
import { publishedWidgetDefinition, widgetCardSlot } from "nextly/testing/widget-card";
|
|
3
|
+
// src/testing/admin.ts
|
|
4
|
+
/**
|
|
5
|
+
* `@nextlyhq/plugin-sdk/testing/admin`: a widget's card drawn as the dashboard
|
|
6
|
+
* draws it, for a test to render, in any state the card can be in.
|
|
7
|
+
*
|
|
8
|
+
* ```tsx
|
|
9
|
+
* import { render } from "@testing-library/react";
|
|
10
|
+
* import { renderWidgetCard } from "@nextlyhq/plugin-sdk/testing/admin";
|
|
11
|
+
*
|
|
12
|
+
* render(renderWidgetCard(ordersWidget, { state: "ready", data: { total: 3 } }));
|
|
13
|
+
* // or what a load answered, as runWidgetLoad returns it:
|
|
14
|
+
* render(renderWidgetCard(ordersWidget, { result: await runWidgetLoad(t, ordersWidget, { as }) }));
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* The card is described as the registry publishes the widget and drawn by the
|
|
18
|
+
* admin's own renderer inside the real frame; for tests, never production.
|
|
19
|
+
*
|
|
20
|
+
* @experimental Until the widget SDK's test helpers settle.
|
|
21
|
+
*/
|
|
22
|
+
/** The card's element, for a test to render with its own renderer. */
|
|
23
|
+
function renderWidgetCard(widget, options) {
|
|
24
|
+
const shown = "result" in options ? options.result : options;
|
|
25
|
+
return widgetCardElement({
|
|
26
|
+
definition: publishedWidgetDefinition(widget),
|
|
27
|
+
slot: widgetCardSlot(widget, shown),
|
|
28
|
+
...options.size === void 0 ? {} : { size: options.size },
|
|
29
|
+
...options.theme === void 0 ? {} : { theme: options.theme },
|
|
30
|
+
...options.component === void 0 ? {} : { component: options.component }
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export { renderWidgetCard };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=admin.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin.mjs","names":[],"sources":["../../src/testing/admin.ts"],"sourcesContent":["/**\n * `@nextlyhq/plugin-sdk/testing/admin`: a widget's card drawn as the dashboard\n * draws it, for a test to render, in any state the card can be in.\n *\n * ```tsx\n * import { render } from \"@testing-library/react\";\n * import { renderWidgetCard } from \"@nextlyhq/plugin-sdk/testing/admin\";\n *\n * render(renderWidgetCard(ordersWidget, { state: \"ready\", data: { total: 3 } }));\n * // or what a load answered, as runWidgetLoad returns it:\n * render(renderWidgetCard(ordersWidget, { result: await runWidgetLoad(t, ordersWidget, { as }) }));\n * ```\n *\n * The card is described as the registry publishes the widget and drawn by the\n * admin's own renderer inside the real frame; for tests, never production.\n *\n * @experimental Until the widget SDK's test helpers settle.\n */\nimport { widgetCardElement } from \"@nextlyhq/admin/testing\";\nimport type { AnyWidget, WidgetData } from \"nextly\";\n// The card helpers' own entry, not `nextly/testing`: that entry's harness\n// refuses to load where `window` is defined, so a card test under jsdom could\n// not import this module through it.\nimport {\n publishedWidgetDefinition,\n widgetCardSlot,\n type WidgetLoadResult,\n} from \"nextly/testing/widget-card\";\nimport type { ComponentType, JSX } from \"react\";\n\n/** A card's states: each a load can answer, and `loading`, which only a card shows. */\nexport type WidgetCardState = WidgetLoadResult<unknown>[\"state\"] | \"loading\";\n\n/** The card a hand-made case draws: a state, and what that state carries. */\ntype HandMade<W> =\n | { state: \"loading\" }\n | { state: \"ready\" | \"empty\"; data: WidgetData<W> }\n | { state: \"needs-setting\"; setting: string }\n | { state: \"unavailable\" | \"not-shown\" }\n | { state: \"error\"; error: string };\n\nexport type RenderWidgetCardOptions<W> = (\n | { result: WidgetLoadResult<W> }\n | HandMade<W>\n) & {\n /** The card's size, and the tier it is drawn at; the widget's starting size when left out. */\n size?: { w: number; h: number; tier?: \"small\" | \"medium\" | \"large\" };\n /** The colour scheme the card is drawn in; light when left out. */\n theme?: \"light\" | \"dark\";\n /** The component a view of the widget's own draws with. */\n component?: ComponentType<never>;\n};\n\n/** The card's element, for a test to render with its own renderer. */\nexport function renderWidgetCard<W extends AnyWidget>(\n widget: W,\n options: RenderWidgetCardOptions<W>\n): JSX.Element {\n const shown: WidgetLoadResult<W> | { state: \"loading\" } =\n \"result\" in options ? options.result : options;\n return widgetCardElement({\n definition: publishedWidgetDefinition(widget),\n slot: widgetCardSlot(widget, shown),\n ...(options.size === undefined ? {} : { size: options.size }),\n ...(options.theme === undefined ? {} : { theme: options.theme }),\n ...(options.component === undefined\n ? {}\n : { component: options.component }),\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsDA,SAAgB,iBACd,QACA,SACa;CACb,MAAM,QACJ,YAAY,UAAU,QAAQ,SAAS;CACzC,OAAO,kBAAkB;EACvB,YAAY,0BAA0B,MAAM;EAC5C,MAAM,eAAe,QAAQ,KAAK;EAClC,GAAI,QAAQ,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM,QAAQ,KAAK;EAC3D,GAAI,QAAQ,UAAU,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO,QAAQ,MAAM;EAC9D,GAAI,QAAQ,cAAc,KAAA,IACtB,CAAC,IACD,EAAE,WAAW,QAAQ,UAAU;CACrC,CAAC;AACH"}
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { CreateTestNextlyOptions, TestDialect, TestNextly, createTestNextly, describeAbortedTransactions, getConfiguredTestDialects, takeAbortedTransactionSightings } from "nextly/testing";
|
|
2
|
-
export { type CreateTestNextlyOptions, type TestDialect, type TestNextly, createTestNextly, describeAbortedTransactions, getConfiguredTestDialects, takeAbortedTransactionSightings };
|
|
1
|
+
import { CreateTestNextlyOptions, RunWidgetLoadOptions, TestDialect, TestNextly, WidgetLoadResult, createTestNextly, describeAbortedTransactions, getConfiguredTestDialects, runWidgetLoad, takeAbortedTransactionSightings } from "nextly/testing";
|
|
2
|
+
export { type CreateTestNextlyOptions, type RunWidgetLoadOptions, type TestDialect, type TestNextly, type WidgetLoadResult, createTestNextly, describeAbortedTransactions, getConfiguredTestDialects, runWidgetLoad, takeAbortedTransactionSightings };
|
package/dist/testing.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createTestNextly, describeAbortedTransactions, getConfiguredTestDialects, takeAbortedTransactionSightings } from "nextly/testing";
|
|
1
|
+
export { createTestNextly, describeAbortedTransactions, getConfiguredTestDialects, runWidgetLoad, takeAbortedTransactionSightings } from "nextly/testing";
|
package/dist/widgets.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { WidgetData, WidgetProps } from "nextly";
|
|
2
|
+
import { WidgetRenderSize, WidgetResult, WidgetResultField } from "nextly/widget-result";
|
|
3
|
+
export type { WidgetData, WidgetProps, WidgetRenderSize, WidgetResult, WidgetResultField };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextlyhq/plugin-sdk",
|
|
3
|
-
"version": "0.0.2-alpha.
|
|
3
|
+
"version": "0.0.2-alpha.73",
|
|
4
4
|
"description": "Nextly Plugin SDK — the author-facing surface for building Nextly plugins; the plugin API stability boundary (see STABILITY.md).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -32,6 +32,11 @@
|
|
|
32
32
|
"import": "./dist/testing.mjs",
|
|
33
33
|
"default": "./dist/testing.mjs"
|
|
34
34
|
},
|
|
35
|
+
"./testing/admin": {
|
|
36
|
+
"types": "./dist/testing/admin.d.ts",
|
|
37
|
+
"import": "./dist/testing/admin.mjs",
|
|
38
|
+
"default": "./dist/testing/admin.mjs"
|
|
39
|
+
},
|
|
35
40
|
"./client": {
|
|
36
41
|
"types": "./dist/client.d.ts",
|
|
37
42
|
"import": "./dist/client.mjs",
|
|
@@ -70,13 +75,14 @@
|
|
|
70
75
|
"node": "^22.12.0 || >=24.0.0"
|
|
71
76
|
},
|
|
72
77
|
"dependencies": {
|
|
73
|
-
"@nextlyhq/blocks-engine": "0.0.2-alpha.
|
|
78
|
+
"@nextlyhq/blocks-engine": "0.0.2-alpha.73",
|
|
79
|
+
"@nextlyhq/ui": "0.0.2-alpha.73"
|
|
74
80
|
},
|
|
75
81
|
"peerDependencies": {
|
|
76
|
-
"@nextlyhq/admin": "0.0.2-alpha.
|
|
77
|
-
"nextly": "0.0.2-alpha.
|
|
78
|
-
"react": "^
|
|
79
|
-
"react-dom": "^
|
|
82
|
+
"@nextlyhq/admin": "0.0.2-alpha.73",
|
|
83
|
+
"nextly": "0.0.2-alpha.73",
|
|
84
|
+
"react": "^19.3.0",
|
|
85
|
+
"react-dom": "^19.3.0"
|
|
80
86
|
},
|
|
81
87
|
"peerDependenciesMeta": {
|
|
82
88
|
"@nextlyhq/admin": {
|
|
@@ -90,11 +96,12 @@
|
|
|
90
96
|
}
|
|
91
97
|
},
|
|
92
98
|
"devDependencies": {
|
|
93
|
-
"@nextlyhq/admin": "0.0.2-alpha.
|
|
94
|
-
"@nextlyhq/tsconfig": "0.0.2-alpha.
|
|
99
|
+
"@nextlyhq/admin": "0.0.2-alpha.73",
|
|
100
|
+
"@nextlyhq/tsconfig": "0.0.2-alpha.73",
|
|
95
101
|
"@types/node": "^22.20.5",
|
|
96
102
|
"@types/react": "19.3.0",
|
|
97
|
-
"
|
|
103
|
+
"jsdom": "^27.1.0",
|
|
104
|
+
"nextly": "0.0.2-alpha.73",
|
|
98
105
|
"react": "19.3.1",
|
|
99
106
|
"react-dom": "19.3.1",
|
|
100
107
|
"tsdown": "^0.23.1",
|