@storyblok/schema 0.1.0-alpha.0 → 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/generated/capi/types.gen.d.cts +1 -126
- package/dist/generated/capi/types.gen.d.mts +1 -126
- package/dist/generated/mapi/_internal.gen.d.cts +1 -171
- package/dist/generated/mapi/_internal.gen.d.mts +1 -171
- package/dist/generated/overlay/zod.gen.cjs +409 -0
- package/dist/generated/overlay/zod.gen.cjs.map +1 -0
- package/dist/generated/overlay/zod.gen.mjs +403 -0
- package/dist/generated/overlay/zod.gen.mjs.map +1 -0
- package/dist/generated/types/block.d.cts +27 -14
- package/dist/generated/types/block.d.mts +27 -14
- package/dist/generated/types/field.d.cts +28 -13
- package/dist/generated/types/field.d.mts +28 -13
- package/dist/generated/types/mapi-story.d.cts +5 -9
- package/dist/generated/types/mapi-story.d.mts +5 -9
- package/dist/helpers/define-block.cjs +10 -28
- package/dist/helpers/define-block.cjs.map +1 -1
- package/dist/helpers/define-block.d.cts +14 -31
- package/dist/helpers/define-block.d.mts +14 -31
- package/dist/helpers/define-block.mjs +11 -27
- package/dist/helpers/define-block.mjs.map +1 -1
- package/dist/helpers/define-datasource.cjs +0 -16
- package/dist/helpers/define-datasource.cjs.map +1 -1
- package/dist/helpers/define-datasource.d.cts +14 -23
- package/dist/helpers/define-datasource.d.mts +14 -23
- package/dist/helpers/define-datasource.mjs +1 -15
- package/dist/helpers/define-datasource.mjs.map +1 -1
- package/dist/helpers/define-field.cjs +11 -11
- package/dist/helpers/define-field.cjs.map +1 -1
- package/dist/helpers/define-field.d.cts +46 -85
- package/dist/helpers/define-field.d.mts +46 -85
- package/dist/helpers/define-field.mjs +12 -11
- package/dist/helpers/define-field.mjs.map +1 -1
- package/dist/helpers/schema-type.d.cts +5 -9
- package/dist/helpers/schema-type.d.mts +5 -9
- package/dist/index.cjs +6 -47
- package/dist/index.d.cts +11 -20
- package/dist/index.d.mts +11 -20
- package/dist/index.mjs +6 -15
- package/dist/utils/is-record.cjs +10 -0
- package/dist/utils/is-record.cjs.map +1 -0
- package/dist/utils/is-record.mjs +9 -0
- package/dist/utils/is-record.mjs.map +1 -0
- package/dist/validators/create-story-validator.cjs +37 -0
- package/dist/validators/create-story-validator.cjs.map +1 -0
- package/dist/validators/create-story-validator.d.cts +18 -0
- package/dist/validators/create-story-validator.d.mts +18 -0
- package/dist/validators/create-story-validator.mjs +37 -0
- package/dist/validators/create-story-validator.mjs.map +1 -0
- package/dist/validators/internal-schemas.cjs +1 -0
- package/dist/validators/internal-schemas.mjs +3 -0
- package/dist/validators/shapes.cjs +12 -0
- package/dist/validators/shapes.cjs.map +1 -0
- package/dist/validators/shapes.d.cts +62 -0
- package/dist/validators/shapes.d.mts +62 -0
- package/dist/validators/shapes.mjs +12 -0
- package/dist/validators/shapes.mjs.map +1 -0
- package/dist/validators/types.d.cts +25 -0
- package/dist/validators/types.d.mts +25 -0
- package/dist/validators/validate-schema.cjs +125 -0
- package/dist/validators/validate-schema.cjs.map +1 -0
- package/dist/validators/validate-schema.d.cts +18 -0
- package/dist/validators/validate-schema.d.mts +18 -0
- package/dist/validators/validate-schema.mjs +125 -0
- package/dist/validators/validate-schema.mjs.map +1 -0
- package/dist/validators/validate-story.cjs +257 -0
- package/dist/validators/validate-story.cjs.map +1 -0
- package/dist/validators/validate-story.d.cts +17 -0
- package/dist/validators/validate-story.d.mts +17 -0
- package/dist/validators/validate-story.mjs +257 -0
- package/dist/validators/validate-story.mjs.map +1 -0
- package/package.json +5 -1
- package/dist/generated/mapi/types.gen.d.cts +0 -1272
- package/dist/generated/mapi/types.gen.d.mts +0 -1272
- package/dist/helpers/create-story-helpers.cjs +0 -42
- package/dist/helpers/create-story-helpers.cjs.map +0 -1
- package/dist/helpers/create-story-helpers.d.cts +0 -50
- package/dist/helpers/create-story-helpers.d.mts +0 -50
- package/dist/helpers/create-story-helpers.mjs +0 -42
- package/dist/helpers/create-story-helpers.mjs.map +0 -1
- package/dist/helpers/define-asset-folder.cjs +0 -46
- package/dist/helpers/define-asset-folder.cjs.map +0 -1
- package/dist/helpers/define-asset-folder.d.cts +0 -33
- package/dist/helpers/define-asset-folder.d.mts +0 -33
- package/dist/helpers/define-asset-folder.mjs +0 -43
- package/dist/helpers/define-asset-folder.mjs.map +0 -1
- package/dist/helpers/define-asset.cjs +0 -60
- package/dist/helpers/define-asset.cjs.map +0 -1
- package/dist/helpers/define-asset.d.cts +0 -32
- package/dist/helpers/define-asset.d.mts +0 -32
- package/dist/helpers/define-asset.mjs +0 -57
- package/dist/helpers/define-asset.mjs.map +0 -1
- package/dist/helpers/define-block-folder.cjs +0 -44
- package/dist/helpers/define-block-folder.cjs.map +0 -1
- package/dist/helpers/define-block-folder.d.cts +0 -34
- package/dist/helpers/define-block-folder.d.mts +0 -34
- package/dist/helpers/define-block-folder.mjs +0 -41
- package/dist/helpers/define-block-folder.mjs.map +0 -1
- package/dist/helpers/define-datasource-entry.cjs +0 -47
- package/dist/helpers/define-datasource-entry.cjs.map +0 -1
- package/dist/helpers/define-datasource-entry.d.cts +0 -49
- package/dist/helpers/define-datasource-entry.d.mts +0 -49
- package/dist/helpers/define-datasource-entry.mjs +0 -43
- package/dist/helpers/define-datasource-entry.mjs.map +0 -1
- package/dist/helpers/define-internal-tag.cjs +0 -41
- package/dist/helpers/define-internal-tag.cjs.map +0 -1
- package/dist/helpers/define-internal-tag.d.cts +0 -34
- package/dist/helpers/define-internal-tag.d.mts +0 -34
- package/dist/helpers/define-internal-tag.mjs +0 -38
- package/dist/helpers/define-internal-tag.mjs.map +0 -1
- package/dist/helpers/define-link.cjs +0 -23
- package/dist/helpers/define-link.cjs.map +0 -1
- package/dist/helpers/define-link.d.cts +0 -32
- package/dist/helpers/define-link.d.mts +0 -32
- package/dist/helpers/define-link.mjs +0 -22
- package/dist/helpers/define-link.mjs.map +0 -1
- package/dist/helpers/define-preset.cjs +0 -44
- package/dist/helpers/define-preset.cjs.map +0 -1
- package/dist/helpers/define-preset.d.cts +0 -35
- package/dist/helpers/define-preset.d.mts +0 -35
- package/dist/helpers/define-preset.mjs +0 -41
- package/dist/helpers/define-preset.mjs.map +0 -1
- package/dist/helpers/define-space.cjs +0 -47
- package/dist/helpers/define-space.cjs.map +0 -1
- package/dist/helpers/define-space.d.cts +0 -31
- package/dist/helpers/define-space.d.mts +0 -31
- package/dist/helpers/define-space.mjs +0 -44
- package/dist/helpers/define-space.mjs.map +0 -1
- package/dist/helpers/define-story.cjs +0 -122
- package/dist/helpers/define-story.cjs.map +0 -1
- package/dist/helpers/define-story.d.cts +0 -135
- package/dist/helpers/define-story.d.mts +0 -135
- package/dist/helpers/define-story.mjs +0 -118
- package/dist/helpers/define-story.mjs.map +0 -1
- package/dist/helpers/define-tag.cjs +0 -13
- package/dist/helpers/define-tag.cjs.map +0 -1
- package/dist/helpers/define-tag.d.cts +0 -23
- package/dist/helpers/define-tag.d.mts +0 -23
- package/dist/helpers/define-tag.mjs +0 -12
- package/dist/helpers/define-tag.mjs.map +0 -1
- package/dist/helpers/define-user.cjs +0 -50
- package/dist/helpers/define-user.cjs.map +0 -1
- package/dist/helpers/define-user.d.cts +0 -26
- package/dist/helpers/define-user.d.mts +0 -26
- package/dist/helpers/define-user.mjs +0 -48
- package/dist/helpers/define-user.mjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,55 +1,14 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_define_story = require('./helpers/define-story.cjs');
|
|
3
|
-
const require_create_story_helpers = require('./helpers/create-story-helpers.cjs');
|
|
4
|
-
const require_define_asset = require('./helpers/define-asset.cjs');
|
|
5
|
-
const require_define_asset_folder = require('./helpers/define-asset-folder.cjs');
|
|
6
2
|
const require_define_block = require('./helpers/define-block.cjs');
|
|
7
|
-
const require_define_block_folder = require('./helpers/define-block-folder.cjs');
|
|
8
3
|
const require_define_datasource = require('./helpers/define-datasource.cjs');
|
|
9
|
-
const require_define_datasource_entry = require('./helpers/define-datasource-entry.cjs');
|
|
10
4
|
const require_define_field = require('./helpers/define-field.cjs');
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const require_define_space = require('./helpers/define-space.cjs');
|
|
15
|
-
const require_define_tag = require('./helpers/define-tag.cjs');
|
|
16
|
-
const require_define_user = require('./helpers/define-user.cjs');
|
|
5
|
+
const require_validate_story = require('./validators/validate-story.cjs');
|
|
6
|
+
const require_create_story_validator = require('./validators/create-story-validator.cjs');
|
|
7
|
+
const require_validate_schema = require('./validators/validate-schema.cjs');
|
|
17
8
|
|
|
18
|
-
exports.
|
|
19
|
-
exports.defineAssetCreate = require_define_asset.defineAssetCreate;
|
|
20
|
-
exports.defineAssetFolder = require_define_asset_folder.defineAssetFolder;
|
|
21
|
-
exports.defineAssetFolderCreate = require_define_asset_folder.defineAssetFolderCreate;
|
|
22
|
-
exports.defineAssetFolderUpdate = require_define_asset_folder.defineAssetFolderUpdate;
|
|
23
|
-
exports.defineAssetUpdate = require_define_asset.defineAssetUpdate;
|
|
9
|
+
exports.createStoryValidator = require_create_story_validator.createStoryValidator;
|
|
24
10
|
exports.defineBlock = require_define_block.defineBlock;
|
|
25
|
-
exports.defineBlockCreate = require_define_block.defineBlockCreate;
|
|
26
|
-
exports.defineBlockFolder = require_define_block_folder.defineBlockFolder;
|
|
27
|
-
exports.defineBlockFolderCreate = require_define_block_folder.defineBlockFolderCreate;
|
|
28
|
-
exports.defineBlockFolderUpdate = require_define_block_folder.defineBlockFolderUpdate;
|
|
29
|
-
exports.defineBlockUpdate = require_define_block.defineBlockUpdate;
|
|
30
11
|
exports.defineDatasource = require_define_datasource.defineDatasource;
|
|
31
|
-
exports.defineDatasourceCreate = require_define_datasource.defineDatasourceCreate;
|
|
32
|
-
exports.defineDatasourceEntry = require_define_datasource_entry.defineDatasourceEntry;
|
|
33
|
-
exports.defineDatasourceEntryCreate = require_define_datasource_entry.defineDatasourceEntryCreate;
|
|
34
|
-
exports.defineDatasourceEntryUpdate = require_define_datasource_entry.defineDatasourceEntryUpdate;
|
|
35
|
-
exports.defineDatasourceUpdate = require_define_datasource.defineDatasourceUpdate;
|
|
36
12
|
exports.defineField = require_define_field.defineField;
|
|
37
|
-
exports.
|
|
38
|
-
exports.
|
|
39
|
-
exports.defineInternalTagUpdate = require_define_internal_tag.defineInternalTagUpdate;
|
|
40
|
-
exports.defineLink = require_define_link.defineLink;
|
|
41
|
-
exports.defineMapiAsset = require_define_asset.defineMapiAsset;
|
|
42
|
-
exports.defineMapiDatasourceEntry = require_define_datasource_entry.defineMapiDatasourceEntry;
|
|
43
|
-
exports.defineMapiStory = require_define_story.defineMapiStory;
|
|
44
|
-
exports.definePreset = require_define_preset.definePreset;
|
|
45
|
-
exports.definePresetCreate = require_define_preset.definePresetCreate;
|
|
46
|
-
exports.definePresetUpdate = require_define_preset.definePresetUpdate;
|
|
47
|
-
exports.defineSpace = require_define_space.defineSpace;
|
|
48
|
-
exports.defineSpaceCreate = require_define_space.defineSpaceCreate;
|
|
49
|
-
exports.defineSpaceUpdate = require_define_space.defineSpaceUpdate;
|
|
50
|
-
exports.defineStory = require_define_story.defineStory;
|
|
51
|
-
exports.defineStoryCreate = require_define_story.defineStoryCreate;
|
|
52
|
-
exports.defineStoryUpdate = require_define_story.defineStoryUpdate;
|
|
53
|
-
exports.defineTag = require_define_tag.defineTag;
|
|
54
|
-
exports.defineUser = require_define_user.defineUser;
|
|
55
|
-
exports.defineUserUpdate = require_define_user.defineUserUpdate;
|
|
13
|
+
exports.validateSchema = require_validate_schema.validateSchema;
|
|
14
|
+
exports.validateStory = require_validate_story.validateStory;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
import { AssetFieldValue, Field, MultilinkFieldValue, PluginFieldValue, RichtextFieldValue, TableFieldValue } from "./generated/overlay/_internal.gen.cjs";
|
|
2
|
-
import { Block,
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { AssetCreate, AssetFolder, AssetFolderCreate, AssetFolderUpdate, AssetUpdate, ComponentFolder, ComponentFolderCreate, ComponentFolderUpdate, DatasourceCreate, DatasourceEntryCreate, DatasourceEntryUpdate, DatasourceUpdate, InternalTag, InternalTagCreate, InternalTagUpdate, Preset, PresetCreate, PresetUpdate, Space, SpaceCreate, SpaceUpdate, StoryLocalizedPath, StoryTranslatedSlug, User, UserUpdate } from "./generated/mapi/types.gen.cjs";
|
|
6
|
-
import { MapiStory, StoryCreate, StoryUpdate } from "./generated/types/mapi-story.cjs";
|
|
2
|
+
import { Block, BlockFields, NestableBlock, RootBlock } from "./generated/types/block.cjs";
|
|
3
|
+
import { BlockContent, BlockContentInput, BlocksFieldValue, FieldType, FieldValue, FieldValueInput } from "./generated/types/field.cjs";
|
|
4
|
+
import { MapiStory } from "./generated/types/mapi-story.cjs";
|
|
7
5
|
import { Story } from "./generated/types/story.cjs";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { MapiAsset, defineAssetCreate, defineAssetUpdate, defineMapiAsset } from "./helpers/define-asset.cjs";
|
|
12
|
-
import { defineAssetFolder, defineAssetFolderCreate, defineAssetFolderUpdate } from "./helpers/define-asset-folder.cjs";
|
|
13
|
-
import { defineBlockFolder, defineBlockFolderCreate, defineBlockFolderUpdate } from "./helpers/define-block-folder.cjs";
|
|
14
|
-
import { defineDatasource, defineDatasourceCreate, defineDatasourceUpdate } from "./helpers/define-datasource.cjs";
|
|
15
|
-
import { DatasourceEntry, MapiDatasourceEntry, defineDatasourceEntry, defineDatasourceEntryCreate, defineDatasourceEntryUpdate, defineMapiDatasourceEntry } from "./helpers/define-datasource-entry.cjs";
|
|
16
|
-
import { defineInternalTag, defineInternalTagCreate, defineInternalTagUpdate } from "./helpers/define-internal-tag.cjs";
|
|
17
|
-
import { defineLink } from "./helpers/define-link.cjs";
|
|
18
|
-
import { definePreset, definePresetCreate, definePresetUpdate } from "./helpers/define-preset.cjs";
|
|
19
|
-
import { defineSpace, defineSpaceCreate, defineSpaceUpdate } from "./helpers/define-space.cjs";
|
|
20
|
-
import { defineTag } from "./helpers/define-tag.cjs";
|
|
21
|
-
import { defineUser, defineUserUpdate } from "./helpers/define-user.cjs";
|
|
6
|
+
import { defineBlock } from "./helpers/define-block.cjs";
|
|
7
|
+
import { Datasource, defineDatasource } from "./helpers/define-datasource.cjs";
|
|
8
|
+
import { DefinedField, FieldInput, defineField } from "./helpers/define-field.cjs";
|
|
22
9
|
import { Schema } from "./helpers/schema-type.cjs";
|
|
23
|
-
|
|
10
|
+
import { createStoryValidator } from "./validators/create-story-validator.cjs";
|
|
11
|
+
import { ValidationIssue, ValidationResult, ValidationSeverity } from "./validators/types.cjs";
|
|
12
|
+
import { validateSchema } from "./validators/validate-schema.cjs";
|
|
13
|
+
import { validateStory } from "./validators/validate-story.cjs";
|
|
14
|
+
export { type AssetFieldValue, type Block, type BlockContent, type BlockContentInput, type BlockFields, type BlocksFieldValue, type Datasource, type DefinedField, type Field, type FieldInput, type FieldType, type FieldValue, type FieldValueInput, type MapiStory, type MultilinkFieldValue, type NestableBlock, type PluginFieldValue, type RichtextFieldValue, type RootBlock, type Schema, type Story, type TableFieldValue, type ValidationIssue, type ValidationResult, type ValidationSeverity, createStoryValidator, defineBlock, defineDatasource, defineField, validateSchema, validateStory };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
import { AssetFieldValue, Field, MultilinkFieldValue, PluginFieldValue, RichtextFieldValue, TableFieldValue } from "./generated/overlay/_internal.gen.mjs";
|
|
2
|
-
import { Block,
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { AssetCreate, AssetFolder, AssetFolderCreate, AssetFolderUpdate, AssetUpdate, ComponentFolder, ComponentFolderCreate, ComponentFolderUpdate, DatasourceCreate, DatasourceEntryCreate, DatasourceEntryUpdate, DatasourceUpdate, InternalTag, InternalTagCreate, InternalTagUpdate, Preset, PresetCreate, PresetUpdate, Space, SpaceCreate, SpaceUpdate, StoryLocalizedPath, StoryTranslatedSlug, User, UserUpdate } from "./generated/mapi/types.gen.mjs";
|
|
6
|
-
import { MapiStory, StoryCreate, StoryUpdate } from "./generated/types/mapi-story.mjs";
|
|
2
|
+
import { Block, BlockFields, NestableBlock, RootBlock } from "./generated/types/block.mjs";
|
|
3
|
+
import { BlockContent, BlockContentInput, BlocksFieldValue, FieldType, FieldValue, FieldValueInput } from "./generated/types/field.mjs";
|
|
4
|
+
import { MapiStory } from "./generated/types/mapi-story.mjs";
|
|
7
5
|
import { Story } from "./generated/types/story.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { MapiAsset, defineAssetCreate, defineAssetUpdate, defineMapiAsset } from "./helpers/define-asset.mjs";
|
|
12
|
-
import { defineAssetFolder, defineAssetFolderCreate, defineAssetFolderUpdate } from "./helpers/define-asset-folder.mjs";
|
|
13
|
-
import { defineBlockFolder, defineBlockFolderCreate, defineBlockFolderUpdate } from "./helpers/define-block-folder.mjs";
|
|
14
|
-
import { defineDatasource, defineDatasourceCreate, defineDatasourceUpdate } from "./helpers/define-datasource.mjs";
|
|
15
|
-
import { DatasourceEntry, MapiDatasourceEntry, defineDatasourceEntry, defineDatasourceEntryCreate, defineDatasourceEntryUpdate, defineMapiDatasourceEntry } from "./helpers/define-datasource-entry.mjs";
|
|
16
|
-
import { defineInternalTag, defineInternalTagCreate, defineInternalTagUpdate } from "./helpers/define-internal-tag.mjs";
|
|
17
|
-
import { defineLink } from "./helpers/define-link.mjs";
|
|
18
|
-
import { definePreset, definePresetCreate, definePresetUpdate } from "./helpers/define-preset.mjs";
|
|
19
|
-
import { defineSpace, defineSpaceCreate, defineSpaceUpdate } from "./helpers/define-space.mjs";
|
|
20
|
-
import { defineTag } from "./helpers/define-tag.mjs";
|
|
21
|
-
import { defineUser, defineUserUpdate } from "./helpers/define-user.mjs";
|
|
6
|
+
import { defineBlock } from "./helpers/define-block.mjs";
|
|
7
|
+
import { Datasource, defineDatasource } from "./helpers/define-datasource.mjs";
|
|
8
|
+
import { DefinedField, FieldInput, defineField } from "./helpers/define-field.mjs";
|
|
22
9
|
import { Schema } from "./helpers/schema-type.mjs";
|
|
23
|
-
|
|
10
|
+
import { createStoryValidator } from "./validators/create-story-validator.mjs";
|
|
11
|
+
import { ValidationIssue, ValidationResult, ValidationSeverity } from "./validators/types.mjs";
|
|
12
|
+
import { validateSchema } from "./validators/validate-schema.mjs";
|
|
13
|
+
import { validateStory } from "./validators/validate-story.mjs";
|
|
14
|
+
export { type AssetFieldValue, type Block, type BlockContent, type BlockContentInput, type BlockFields, type BlocksFieldValue, type Datasource, type DefinedField, type Field, type FieldInput, type FieldType, type FieldValue, type FieldValueInput, type MapiStory, type MultilinkFieldValue, type NestableBlock, type PluginFieldValue, type RichtextFieldValue, type RootBlock, type Schema, type Story, type TableFieldValue, type ValidationIssue, type ValidationResult, type ValidationSeverity, createStoryValidator, defineBlock, defineDatasource, defineField, validateSchema, validateStory };
|
package/dist/index.mjs
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { defineAssetCreate, defineAssetUpdate, defineMapiAsset } from "./helpers/define-asset.mjs";
|
|
4
|
-
import { defineAssetFolder, defineAssetFolderCreate, defineAssetFolderUpdate } from "./helpers/define-asset-folder.mjs";
|
|
5
|
-
import { defineBlock, defineBlockCreate, defineBlockUpdate } from "./helpers/define-block.mjs";
|
|
6
|
-
import { defineBlockFolder, defineBlockFolderCreate, defineBlockFolderUpdate } from "./helpers/define-block-folder.mjs";
|
|
7
|
-
import { defineDatasource, defineDatasourceCreate, defineDatasourceUpdate } from "./helpers/define-datasource.mjs";
|
|
8
|
-
import { defineDatasourceEntry, defineDatasourceEntryCreate, defineDatasourceEntryUpdate, defineMapiDatasourceEntry } from "./helpers/define-datasource-entry.mjs";
|
|
1
|
+
import { defineBlock } from "./helpers/define-block.mjs";
|
|
2
|
+
import { defineDatasource } from "./helpers/define-datasource.mjs";
|
|
9
3
|
import { defineField } from "./helpers/define-field.mjs";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { defineSpace, defineSpaceCreate, defineSpaceUpdate } from "./helpers/define-space.mjs";
|
|
14
|
-
import { defineTag } from "./helpers/define-tag.mjs";
|
|
15
|
-
import { defineUser, defineUserUpdate } from "./helpers/define-user.mjs";
|
|
4
|
+
import { validateStory } from "./validators/validate-story.mjs";
|
|
5
|
+
import { createStoryValidator } from "./validators/create-story-validator.mjs";
|
|
6
|
+
import { validateSchema } from "./validators/validate-schema.mjs";
|
|
16
7
|
|
|
17
|
-
export {
|
|
8
|
+
export { createStoryValidator, defineBlock, defineDatasource, defineField, validateSchema, validateStory };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/utils/is-record.ts
|
|
3
|
+
/** Type guard for a plain object (record). */
|
|
4
|
+
function isRecord(value) {
|
|
5
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
exports.isRecord = isRecord;
|
|
10
|
+
//# sourceMappingURL=is-record.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-record.cjs","names":[],"sources":["../../src/utils/is-record.ts"],"sourcesContent":["/** Type guard for a plain object (record). */\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n"],"mappings":";;;AACA,SAAgB,SAAS,OAAkD;AACzE,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,MAAM"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/utils/is-record.ts
|
|
2
|
+
/** Type guard for a plain object (record). */
|
|
3
|
+
function isRecord(value) {
|
|
4
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { isRecord };
|
|
9
|
+
//# sourceMappingURL=is-record.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-record.mjs","names":[],"sources":["../../src/utils/is-record.ts"],"sourcesContent":["/** Type guard for a plain object (record). */\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n"],"mappings":";;AACA,SAAgB,SAAS,OAAkD;AACzE,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,MAAM"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const require_is_record = require('../utils/is-record.cjs');
|
|
2
|
+
const require_validate_story = require('./validate-story.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/validators/create-story-validator.ts
|
|
5
|
+
/**
|
|
6
|
+
* Wraps {@link validateStory} as a [Standard Schema](https://standardschema.dev)
|
|
7
|
+
* validator, so a story for `rootBlock` composes with any Standard Schema
|
|
8
|
+
* tooling (e.g. as a tRPC input or a form resolver). The root content
|
|
9
|
+
* `component` is asserted to match `rootBlock.name`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const validator = createStoryValidator(page, schema);
|
|
13
|
+
* const result = validator['~standard'].validate(story);
|
|
14
|
+
*/
|
|
15
|
+
function createStoryValidator(rootBlock, schema) {
|
|
16
|
+
return { "~standard": {
|
|
17
|
+
version: 1,
|
|
18
|
+
vendor: "storyblok-schema",
|
|
19
|
+
validate(value) {
|
|
20
|
+
const issues = require_validate_story.validateStory(value, schema).issues.filter((issue) => issue.severity === "error").map((issue) => ({
|
|
21
|
+
message: issue.message,
|
|
22
|
+
path: issue.path
|
|
23
|
+
}));
|
|
24
|
+
const content = require_is_record.isRecord(value) ? value.content : void 0;
|
|
25
|
+
const component = require_is_record.isRecord(content) ? content.component : void 0;
|
|
26
|
+
if (component !== void 0 && component !== rootBlock.name) issues.push({
|
|
27
|
+
message: `Expected root component "${rootBlock.name}", received "${String(component)}".`,
|
|
28
|
+
path: ["content", "component"]
|
|
29
|
+
});
|
|
30
|
+
return issues.length > 0 ? { issues } : { value };
|
|
31
|
+
}
|
|
32
|
+
} };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
exports.createStoryValidator = createStoryValidator;
|
|
37
|
+
//# sourceMappingURL=create-story-validator.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-story-validator.cjs","names":["validateStory","isRecord"],"sources":["../../src/validators/create-story-validator.ts"],"sourcesContent":["import type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { SchemaBlockLike, SchemaLike } from './shapes';\nimport { isRecord } from './shapes';\nimport { validateStory } from './validate-story';\n\n/**\n * Wraps {@link validateStory} as a [Standard Schema](https://standardschema.dev)\n * validator, so a story for `rootBlock` composes with any Standard Schema\n * tooling (e.g. as a tRPC input or a form resolver). The root content\n * `component` is asserted to match `rootBlock.name`.\n *\n * @example\n * const validator = createStoryValidator(page, schema);\n * const result = validator['~standard'].validate(story);\n */\nexport function createStoryValidator(\n rootBlock: SchemaBlockLike,\n schema: SchemaLike,\n): StandardSchemaV1<unknown, unknown> {\n return {\n '~standard': {\n version: 1,\n vendor: 'storyblok-schema',\n validate(value) {\n const result = validateStory(value, schema);\n const issues = result.issues\n .filter(issue => issue.severity === 'error')\n .map(issue => ({ message: issue.message, path: issue.path }));\n\n const content = isRecord(value) ? value.content : undefined;\n const component = isRecord(content) ? content.component : undefined;\n if (component !== undefined && component !== rootBlock.name) {\n issues.push({\n message: `Expected root component \"${rootBlock.name}\", received \"${String(component)}\".`,\n path: ['content', 'component'],\n });\n }\n\n return issues.length > 0 ? { issues } : { value };\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,qBACd,WACA,QACoC;AACpC,QAAO,EACL,aAAa;EACX,SAAS;EACT,QAAQ;EACR,SAAS,OAAO;GAEd,MAAM,SADSA,qCAAc,OAAO,OAAO,CACrB,OACnB,QAAO,UAAS,MAAM,aAAa,QAAQ,CAC3C,KAAI,WAAU;IAAE,SAAS,MAAM;IAAS,MAAM,MAAM;IAAM,EAAE;GAE/D,MAAM,UAAUC,2BAAS,MAAM,GAAG,MAAM,UAAU;GAClD,MAAM,YAAYA,2BAAS,QAAQ,GAAG,QAAQ,YAAY;AAC1D,OAAI,cAAc,UAAa,cAAc,UAAU,KACrD,QAAO,KAAK;IACV,SAAS,4BAA4B,UAAU,KAAK,eAAe,OAAO,UAAU,CAAC;IACrF,MAAM,CAAC,WAAW,YAAY;IAC/B,CAAC;AAGJ,UAAO,OAAO,SAAS,IAAI,EAAE,QAAQ,GAAG,EAAE,OAAO;;EAEpD,EACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SchemaBlockLike, SchemaLike } from "./shapes.cjs";
|
|
2
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
3
|
+
|
|
4
|
+
//#region src/validators/create-story-validator.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Wraps {@link validateStory} as a [Standard Schema](https://standardschema.dev)
|
|
7
|
+
* validator, so a story for `rootBlock` composes with any Standard Schema
|
|
8
|
+
* tooling (e.g. as a tRPC input or a form resolver). The root content
|
|
9
|
+
* `component` is asserted to match `rootBlock.name`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const validator = createStoryValidator(page, schema);
|
|
13
|
+
* const result = validator['~standard'].validate(story);
|
|
14
|
+
*/
|
|
15
|
+
declare function createStoryValidator(rootBlock: SchemaBlockLike, schema: SchemaLike): StandardSchemaV1<unknown, unknown>;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { createStoryValidator };
|
|
18
|
+
//# sourceMappingURL=create-story-validator.d.cts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SchemaBlockLike, SchemaLike } from "./shapes.mjs";
|
|
2
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
3
|
+
|
|
4
|
+
//#region src/validators/create-story-validator.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Wraps {@link validateStory} as a [Standard Schema](https://standardschema.dev)
|
|
7
|
+
* validator, so a story for `rootBlock` composes with any Standard Schema
|
|
8
|
+
* tooling (e.g. as a tRPC input or a form resolver). The root content
|
|
9
|
+
* `component` is asserted to match `rootBlock.name`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const validator = createStoryValidator(page, schema);
|
|
13
|
+
* const result = validator['~standard'].validate(story);
|
|
14
|
+
*/
|
|
15
|
+
declare function createStoryValidator(rootBlock: SchemaBlockLike, schema: SchemaLike): StandardSchemaV1<unknown, unknown>;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { createStoryValidator };
|
|
18
|
+
//# sourceMappingURL=create-story-validator.d.mts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { isRecord } from "../utils/is-record.mjs";
|
|
2
|
+
import { validateStory } from "./validate-story.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/validators/create-story-validator.ts
|
|
5
|
+
/**
|
|
6
|
+
* Wraps {@link validateStory} as a [Standard Schema](https://standardschema.dev)
|
|
7
|
+
* validator, so a story for `rootBlock` composes with any Standard Schema
|
|
8
|
+
* tooling (e.g. as a tRPC input or a form resolver). The root content
|
|
9
|
+
* `component` is asserted to match `rootBlock.name`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const validator = createStoryValidator(page, schema);
|
|
13
|
+
* const result = validator['~standard'].validate(story);
|
|
14
|
+
*/
|
|
15
|
+
function createStoryValidator(rootBlock, schema) {
|
|
16
|
+
return { "~standard": {
|
|
17
|
+
version: 1,
|
|
18
|
+
vendor: "storyblok-schema",
|
|
19
|
+
validate(value) {
|
|
20
|
+
const issues = validateStory(value, schema).issues.filter((issue) => issue.severity === "error").map((issue) => ({
|
|
21
|
+
message: issue.message,
|
|
22
|
+
path: issue.path
|
|
23
|
+
}));
|
|
24
|
+
const content = isRecord(value) ? value.content : void 0;
|
|
25
|
+
const component = isRecord(content) ? content.component : void 0;
|
|
26
|
+
if (component !== void 0 && component !== rootBlock.name) issues.push({
|
|
27
|
+
message: `Expected root component "${rootBlock.name}", received "${String(component)}".`,
|
|
28
|
+
path: ["content", "component"]
|
|
29
|
+
});
|
|
30
|
+
return issues.length > 0 ? { issues } : { value };
|
|
31
|
+
}
|
|
32
|
+
} };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { createStoryValidator };
|
|
37
|
+
//# sourceMappingURL=create-story-validator.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-story-validator.mjs","names":[],"sources":["../../src/validators/create-story-validator.ts"],"sourcesContent":["import type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { SchemaBlockLike, SchemaLike } from './shapes';\nimport { isRecord } from './shapes';\nimport { validateStory } from './validate-story';\n\n/**\n * Wraps {@link validateStory} as a [Standard Schema](https://standardschema.dev)\n * validator, so a story for `rootBlock` composes with any Standard Schema\n * tooling (e.g. as a tRPC input or a form resolver). The root content\n * `component` is asserted to match `rootBlock.name`.\n *\n * @example\n * const validator = createStoryValidator(page, schema);\n * const result = validator['~standard'].validate(story);\n */\nexport function createStoryValidator(\n rootBlock: SchemaBlockLike,\n schema: SchemaLike,\n): StandardSchemaV1<unknown, unknown> {\n return {\n '~standard': {\n version: 1,\n vendor: 'storyblok-schema',\n validate(value) {\n const result = validateStory(value, schema);\n const issues = result.issues\n .filter(issue => issue.severity === 'error')\n .map(issue => ({ message: issue.message, path: issue.path }));\n\n const content = isRecord(value) ? value.content : undefined;\n const component = isRecord(content) ? content.component : undefined;\n if (component !== undefined && component !== rootBlock.name) {\n issues.push({\n message: `Expected root component \"${rootBlock.name}\", received \"${String(component)}\".`,\n path: ['content', 'component'],\n });\n }\n\n return issues.length > 0 ? { issues } : { value };\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,qBACd,WACA,QACoC;AACpC,QAAO,EACL,aAAa;EACX,SAAS;EACT,QAAQ;EACR,SAAS,OAAO;GAEd,MAAM,SADS,cAAc,OAAO,OAAO,CACrB,OACnB,QAAO,UAAS,MAAM,aAAa,QAAQ,CAC3C,KAAI,WAAU;IAAE,SAAS,MAAM;IAAS,MAAM,MAAM;IAAM,EAAE;GAE/D,MAAM,UAAU,SAAS,MAAM,GAAG,MAAM,UAAU;GAClD,MAAM,YAAY,SAAS,QAAQ,GAAG,QAAQ,YAAY;AAC1D,OAAI,cAAc,UAAa,cAAc,UAAU,KACrD,QAAO,KAAK;IACV,SAAS,4BAA4B,UAAU,KAAK,eAAe,OAAO,UAAU,CAAC;IACrF,MAAM,CAAC,WAAW,YAAY;IAC/B,CAAC;AAGJ,UAAO,OAAO,SAAS,IAAI,EAAE,QAAQ,GAAG,EAAE,OAAO;;EAEpD,EACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const require_zod_gen = require('../generated/overlay/zod.gen.cjs');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const require_is_record = require('../utils/is-record.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/validators/shapes.ts
|
|
4
|
+
/** Normalizes a record-or-array of entities to an array of values. */
|
|
5
|
+
function toValues(input) {
|
|
6
|
+
if (!input) return [];
|
|
7
|
+
return Array.isArray(input) ? [...input] : Object.values(input);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
exports.toValues = toValues;
|
|
12
|
+
//# sourceMappingURL=shapes.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shapes.cjs","names":[],"sources":["../../src/validators/shapes.ts"],"sourcesContent":["import type { FieldType } from '../generated/types/field';\n\nexport { isRecord } from '../utils/is-record';\n\n/**\n * Loose structural views of the content-shape definitions, used internally by\n * the validators. A real `Block` / `Datasource` (from the `define*` helpers) is\n * structurally assignable to these, but they also tolerate the plain objects a\n * validator may receive at runtime.\n */\n\n/** A single field within a block's `fields` array. */\nexport interface SchemaFieldLike {\n name: string;\n type: FieldType;\n required?: boolean;\n /** Normalized block-name references for `bloks` fields. */\n allow?: readonly string[];\n /** Normalized datasource slug for option/options fields. */\n datasource?: string;\n // Value constraints enforced by `validateStory` (all optional).\n /** `text`/`textarea`/`markdown`: maximum string length. */\n max_length?: number;\n /** `text`/`textarea`: legacy alias for `max_length`. */\n maxlength?: number;\n /** `text`/`textarea`: minimum string length. */\n minlength?: number;\n /** `number`: inclusive lower bound. */\n min_value?: number;\n /** `number`: inclusive upper bound. */\n max_value?: number;\n /** `number`: maximum number of fractional digits. */\n decimals?: number;\n /** `number`: the value must be a multiple of this step (offset from `min_value`, else 0). */\n steps?: number;\n /** `bloks`: minimum number of nested blocks. */\n minimum?: number;\n /** `bloks`: maximum number of nested blocks. */\n maximum?: number;\n /** `multiasset`: minimum number of assets. */\n minimum_entries?: number;\n /** `multiasset`: maximum number of assets. */\n maximum_entries?: number;\n /** `options`: minimum number of selected options (stored as a string). */\n min_options?: string;\n /** `options`: maximum number of selected options (stored as a string). */\n max_options?: string;\n}\n\n/** A block definition (`defineBlock` result). */\nexport interface SchemaBlockLike {\n name: string;\n fields?: readonly SchemaFieldLike[];\n}\n\n/** A datasource definition (`defineDatasource` result). */\nexport interface SchemaDatasourceLike {\n slug?: string;\n}\n\n/** The schema object accepted by the validators: blocks (required) and datasources (optional). */\nexport interface SchemaLike {\n blocks: Record<string, SchemaBlockLike> | readonly SchemaBlockLike[];\n datasources?: Record<string, SchemaDatasourceLike> | readonly SchemaDatasourceLike[];\n}\n\n/** Normalizes a record-or-array of entities to an array of values. */\nexport function toValues<T>(input: Record<string, T> | readonly T[] | undefined): T[] {\n if (!input) {\n return [];\n }\n return Array.isArray(input) ? [...input] : Object.values(input as Record<string, T>);\n}\n"],"mappings":";;;;AAmEA,SAAgB,SAAY,OAA0D;AACpF,KAAI,CAAC,MACH,QAAO,EAAE;AAEX,QAAO,MAAM,QAAQ,MAAM,GAAG,CAAC,GAAG,MAAM,GAAG,OAAO,OAAO,MAA2B"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { FieldType } from "../generated/types/field.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/validators/shapes.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Loose structural views of the content-shape definitions, used internally by
|
|
6
|
+
* the validators. A real `Block` / `Datasource` (from the `define*` helpers) is
|
|
7
|
+
* structurally assignable to these, but they also tolerate the plain objects a
|
|
8
|
+
* validator may receive at runtime.
|
|
9
|
+
*/
|
|
10
|
+
/** A single field within a block's `fields` array. */
|
|
11
|
+
interface SchemaFieldLike {
|
|
12
|
+
name: string;
|
|
13
|
+
type: FieldType;
|
|
14
|
+
required?: boolean;
|
|
15
|
+
/** Normalized block-name references for `bloks` fields. */
|
|
16
|
+
allow?: readonly string[];
|
|
17
|
+
/** Normalized datasource slug for option/options fields. */
|
|
18
|
+
datasource?: string;
|
|
19
|
+
/** `text`/`textarea`/`markdown`: maximum string length. */
|
|
20
|
+
max_length?: number;
|
|
21
|
+
/** `text`/`textarea`: legacy alias for `max_length`. */
|
|
22
|
+
maxlength?: number;
|
|
23
|
+
/** `text`/`textarea`: minimum string length. */
|
|
24
|
+
minlength?: number;
|
|
25
|
+
/** `number`: inclusive lower bound. */
|
|
26
|
+
min_value?: number;
|
|
27
|
+
/** `number`: inclusive upper bound. */
|
|
28
|
+
max_value?: number;
|
|
29
|
+
/** `number`: maximum number of fractional digits. */
|
|
30
|
+
decimals?: number;
|
|
31
|
+
/** `number`: the value must be a multiple of this step (offset from `min_value`, else 0). */
|
|
32
|
+
steps?: number;
|
|
33
|
+
/** `bloks`: minimum number of nested blocks. */
|
|
34
|
+
minimum?: number;
|
|
35
|
+
/** `bloks`: maximum number of nested blocks. */
|
|
36
|
+
maximum?: number;
|
|
37
|
+
/** `multiasset`: minimum number of assets. */
|
|
38
|
+
minimum_entries?: number;
|
|
39
|
+
/** `multiasset`: maximum number of assets. */
|
|
40
|
+
maximum_entries?: number;
|
|
41
|
+
/** `options`: minimum number of selected options (stored as a string). */
|
|
42
|
+
min_options?: string;
|
|
43
|
+
/** `options`: maximum number of selected options (stored as a string). */
|
|
44
|
+
max_options?: string;
|
|
45
|
+
}
|
|
46
|
+
/** A block definition (`defineBlock` result). */
|
|
47
|
+
interface SchemaBlockLike {
|
|
48
|
+
name: string;
|
|
49
|
+
fields?: readonly SchemaFieldLike[];
|
|
50
|
+
}
|
|
51
|
+
/** A datasource definition (`defineDatasource` result). */
|
|
52
|
+
interface SchemaDatasourceLike {
|
|
53
|
+
slug?: string;
|
|
54
|
+
}
|
|
55
|
+
/** The schema object accepted by the validators: blocks (required) and datasources (optional). */
|
|
56
|
+
interface SchemaLike {
|
|
57
|
+
blocks: Record<string, SchemaBlockLike> | readonly SchemaBlockLike[];
|
|
58
|
+
datasources?: Record<string, SchemaDatasourceLike> | readonly SchemaDatasourceLike[];
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { SchemaBlockLike, SchemaLike };
|
|
62
|
+
//# sourceMappingURL=shapes.d.cts.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { FieldType } from "../generated/types/field.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/validators/shapes.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Loose structural views of the content-shape definitions, used internally by
|
|
6
|
+
* the validators. A real `Block` / `Datasource` (from the `define*` helpers) is
|
|
7
|
+
* structurally assignable to these, but they also tolerate the plain objects a
|
|
8
|
+
* validator may receive at runtime.
|
|
9
|
+
*/
|
|
10
|
+
/** A single field within a block's `fields` array. */
|
|
11
|
+
interface SchemaFieldLike {
|
|
12
|
+
name: string;
|
|
13
|
+
type: FieldType;
|
|
14
|
+
required?: boolean;
|
|
15
|
+
/** Normalized block-name references for `bloks` fields. */
|
|
16
|
+
allow?: readonly string[];
|
|
17
|
+
/** Normalized datasource slug for option/options fields. */
|
|
18
|
+
datasource?: string;
|
|
19
|
+
/** `text`/`textarea`/`markdown`: maximum string length. */
|
|
20
|
+
max_length?: number;
|
|
21
|
+
/** `text`/`textarea`: legacy alias for `max_length`. */
|
|
22
|
+
maxlength?: number;
|
|
23
|
+
/** `text`/`textarea`: minimum string length. */
|
|
24
|
+
minlength?: number;
|
|
25
|
+
/** `number`: inclusive lower bound. */
|
|
26
|
+
min_value?: number;
|
|
27
|
+
/** `number`: inclusive upper bound. */
|
|
28
|
+
max_value?: number;
|
|
29
|
+
/** `number`: maximum number of fractional digits. */
|
|
30
|
+
decimals?: number;
|
|
31
|
+
/** `number`: the value must be a multiple of this step (offset from `min_value`, else 0). */
|
|
32
|
+
steps?: number;
|
|
33
|
+
/** `bloks`: minimum number of nested blocks. */
|
|
34
|
+
minimum?: number;
|
|
35
|
+
/** `bloks`: maximum number of nested blocks. */
|
|
36
|
+
maximum?: number;
|
|
37
|
+
/** `multiasset`: minimum number of assets. */
|
|
38
|
+
minimum_entries?: number;
|
|
39
|
+
/** `multiasset`: maximum number of assets. */
|
|
40
|
+
maximum_entries?: number;
|
|
41
|
+
/** `options`: minimum number of selected options (stored as a string). */
|
|
42
|
+
min_options?: string;
|
|
43
|
+
/** `options`: maximum number of selected options (stored as a string). */
|
|
44
|
+
max_options?: string;
|
|
45
|
+
}
|
|
46
|
+
/** A block definition (`defineBlock` result). */
|
|
47
|
+
interface SchemaBlockLike {
|
|
48
|
+
name: string;
|
|
49
|
+
fields?: readonly SchemaFieldLike[];
|
|
50
|
+
}
|
|
51
|
+
/** A datasource definition (`defineDatasource` result). */
|
|
52
|
+
interface SchemaDatasourceLike {
|
|
53
|
+
slug?: string;
|
|
54
|
+
}
|
|
55
|
+
/** The schema object accepted by the validators: blocks (required) and datasources (optional). */
|
|
56
|
+
interface SchemaLike {
|
|
57
|
+
blocks: Record<string, SchemaBlockLike> | readonly SchemaBlockLike[];
|
|
58
|
+
datasources?: Record<string, SchemaDatasourceLike> | readonly SchemaDatasourceLike[];
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { SchemaBlockLike, SchemaLike };
|
|
62
|
+
//# sourceMappingURL=shapes.d.mts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { isRecord } from "../utils/is-record.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/validators/shapes.ts
|
|
4
|
+
/** Normalizes a record-or-array of entities to an array of values. */
|
|
5
|
+
function toValues(input) {
|
|
6
|
+
if (!input) return [];
|
|
7
|
+
return Array.isArray(input) ? [...input] : Object.values(input);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { toValues };
|
|
12
|
+
//# sourceMappingURL=shapes.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shapes.mjs","names":[],"sources":["../../src/validators/shapes.ts"],"sourcesContent":["import type { FieldType } from '../generated/types/field';\n\nexport { isRecord } from '../utils/is-record';\n\n/**\n * Loose structural views of the content-shape definitions, used internally by\n * the validators. A real `Block` / `Datasource` (from the `define*` helpers) is\n * structurally assignable to these, but they also tolerate the plain objects a\n * validator may receive at runtime.\n */\n\n/** A single field within a block's `fields` array. */\nexport interface SchemaFieldLike {\n name: string;\n type: FieldType;\n required?: boolean;\n /** Normalized block-name references for `bloks` fields. */\n allow?: readonly string[];\n /** Normalized datasource slug for option/options fields. */\n datasource?: string;\n // Value constraints enforced by `validateStory` (all optional).\n /** `text`/`textarea`/`markdown`: maximum string length. */\n max_length?: number;\n /** `text`/`textarea`: legacy alias for `max_length`. */\n maxlength?: number;\n /** `text`/`textarea`: minimum string length. */\n minlength?: number;\n /** `number`: inclusive lower bound. */\n min_value?: number;\n /** `number`: inclusive upper bound. */\n max_value?: number;\n /** `number`: maximum number of fractional digits. */\n decimals?: number;\n /** `number`: the value must be a multiple of this step (offset from `min_value`, else 0). */\n steps?: number;\n /** `bloks`: minimum number of nested blocks. */\n minimum?: number;\n /** `bloks`: maximum number of nested blocks. */\n maximum?: number;\n /** `multiasset`: minimum number of assets. */\n minimum_entries?: number;\n /** `multiasset`: maximum number of assets. */\n maximum_entries?: number;\n /** `options`: minimum number of selected options (stored as a string). */\n min_options?: string;\n /** `options`: maximum number of selected options (stored as a string). */\n max_options?: string;\n}\n\n/** A block definition (`defineBlock` result). */\nexport interface SchemaBlockLike {\n name: string;\n fields?: readonly SchemaFieldLike[];\n}\n\n/** A datasource definition (`defineDatasource` result). */\nexport interface SchemaDatasourceLike {\n slug?: string;\n}\n\n/** The schema object accepted by the validators: blocks (required) and datasources (optional). */\nexport interface SchemaLike {\n blocks: Record<string, SchemaBlockLike> | readonly SchemaBlockLike[];\n datasources?: Record<string, SchemaDatasourceLike> | readonly SchemaDatasourceLike[];\n}\n\n/** Normalizes a record-or-array of entities to an array of values. */\nexport function toValues<T>(input: Record<string, T> | readonly T[] | undefined): T[] {\n if (!input) {\n return [];\n }\n return Array.isArray(input) ? [...input] : Object.values(input as Record<string, T>);\n}\n"],"mappings":";;;;AAmEA,SAAgB,SAAY,OAA0D;AACpF,KAAI,CAAC,MACH,QAAO,EAAE;AAEX,QAAO,MAAM,QAAQ,MAAM,GAAG,CAAC,GAAG,MAAM,GAAG,OAAO,OAAO,MAA2B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/validators/types.d.ts
|
|
2
|
+
/** Severity of a {@link ValidationIssue}. `error` fails validation; `warning` does not. */
|
|
3
|
+
type ValidationSeverity = 'error' | 'warning';
|
|
4
|
+
/** A single problem found by a validator. */
|
|
5
|
+
interface ValidationIssue {
|
|
6
|
+
/** `error` fails validation; `warning` is advisory. */
|
|
7
|
+
severity: ValidationSeverity;
|
|
8
|
+
/** Stable machine-readable identifier, e.g. `unknown_component`, `invalid_value`. */
|
|
9
|
+
code: string;
|
|
10
|
+
/** Location of the problem as a path of keys/indices into the validated input. */
|
|
11
|
+
path: (string | number)[];
|
|
12
|
+
/** The entity the issue concerns, e.g. `schema`, `story`, `block:hero`, `datasource:colors`. */
|
|
13
|
+
entity: string;
|
|
14
|
+
/** Human-readable description. */
|
|
15
|
+
message: string;
|
|
16
|
+
}
|
|
17
|
+
/** The non-throwing result returned by {@link validateSchema} and {@link validateStory}. */
|
|
18
|
+
interface ValidationResult {
|
|
19
|
+
/** `true` when there are no `error`-severity issues (warnings are allowed). */
|
|
20
|
+
ok: boolean;
|
|
21
|
+
issues: ValidationIssue[];
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { ValidationIssue, ValidationResult, ValidationSeverity };
|
|
25
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/validators/types.d.ts
|
|
2
|
+
/** Severity of a {@link ValidationIssue}. `error` fails validation; `warning` does not. */
|
|
3
|
+
type ValidationSeverity = 'error' | 'warning';
|
|
4
|
+
/** A single problem found by a validator. */
|
|
5
|
+
interface ValidationIssue {
|
|
6
|
+
/** `error` fails validation; `warning` is advisory. */
|
|
7
|
+
severity: ValidationSeverity;
|
|
8
|
+
/** Stable machine-readable identifier, e.g. `unknown_component`, `invalid_value`. */
|
|
9
|
+
code: string;
|
|
10
|
+
/** Location of the problem as a path of keys/indices into the validated input. */
|
|
11
|
+
path: (string | number)[];
|
|
12
|
+
/** The entity the issue concerns, e.g. `schema`, `story`, `block:hero`, `datasource:colors`. */
|
|
13
|
+
entity: string;
|
|
14
|
+
/** Human-readable description. */
|
|
15
|
+
message: string;
|
|
16
|
+
}
|
|
17
|
+
/** The non-throwing result returned by {@link validateSchema} and {@link validateStory}. */
|
|
18
|
+
interface ValidationResult {
|
|
19
|
+
/** `true` when there are no `error`-severity issues (warnings are allowed). */
|
|
20
|
+
ok: boolean;
|
|
21
|
+
issues: ValidationIssue[];
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { ValidationIssue, ValidationResult, ValidationSeverity };
|
|
25
|
+
//# sourceMappingURL=types.d.mts.map
|