@cogenta/blocks 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/action.d.ts +35 -0
- package/dist/action.d.ts.map +1 -0
- package/dist/action.js +24 -0
- package/dist/action.js.map +1 -0
- package/dist/define-block.d.ts +12 -0
- package/dist/define-block.d.ts.map +1 -0
- package/dist/define-block.js +59 -0
- package/dist/define-block.js.map +1 -0
- package/dist/errors.d.ts +14 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +52 -0
- package/dist/errors.js.map +1 -0
- package/dist/field.d.ts +165 -0
- package/dist/field.d.ts.map +1 -0
- package/dist/field.js +156 -0
- package/dist/field.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/migrate.d.ts +64 -0
- package/dist/migrate.d.ts.map +1 -0
- package/dist/migrate.js +113 -0
- package/dist/migrate.js.map +1 -0
- package/dist/plain-text.d.ts +13 -0
- package/dist/plain-text.d.ts.map +1 -0
- package/dist/plain-text.js +23 -0
- package/dist/plain-text.js.map +1 -0
- package/dist/registry.d.ts +33 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +73 -0
- package/dist/registry.js.map +1 -0
- package/dist/rich-text.d.ts +67 -0
- package/dist/rich-text.d.ts.map +1 -0
- package/dist/rich-text.js +60 -0
- package/dist/rich-text.js.map +1 -0
- package/dist/types.d.ts +75 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -0
- package/dist/validate.d.ts +40 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +108 -0
- package/dist/validate.js.map +1 -0
- package/dist/version.d.ts +11 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +23 -0
- package/dist/version.js.map +1 -0
- package/dist/vocabulary.d.ts +472 -0
- package/dist/vocabulary.d.ts.map +1 -0
- package/dist/vocabulary.js +309 -0
- package/dist/vocabulary.js.map +1 -0
- package/package.json +44 -0
package/dist/action.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Contract B, "Actions". The shape is fixed and shared by `hero` and `cta`.
|
|
4
|
+
*
|
|
5
|
+
* A target is either an external URL or an entity reference. Referencing the
|
|
6
|
+
* entity rather than its URL is what makes a slug change harmless.
|
|
7
|
+
*/
|
|
8
|
+
export declare const linkTargetSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
9
|
+
href: z.ZodString;
|
|
10
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
11
|
+
collection: z.ZodString;
|
|
12
|
+
id: z.ZodString;
|
|
13
|
+
}, z.core.$strict>]>;
|
|
14
|
+
export type LinkTarget = z.infer<typeof linkTargetSchema>;
|
|
15
|
+
/**
|
|
16
|
+
* `emphasis` is a semantic intent — which action matters most — that the theme
|
|
17
|
+
* translates as it sees fit. It is not a CSS class in disguise: `'btn-lg'`
|
|
18
|
+
* would be a presentation value, forbidden by rule R3. The distinction is thin
|
|
19
|
+
* on paper and decisive in use.
|
|
20
|
+
*/
|
|
21
|
+
export declare const actionSchema: z.ZodObject<{
|
|
22
|
+
label: z.ZodString;
|
|
23
|
+
target: z.ZodUnion<readonly [z.ZodObject<{
|
|
24
|
+
href: z.ZodString;
|
|
25
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
26
|
+
collection: z.ZodString;
|
|
27
|
+
id: z.ZodString;
|
|
28
|
+
}, z.core.$strict>]>;
|
|
29
|
+
emphasis: z.ZodOptional<z.ZodEnum<{
|
|
30
|
+
primary: "primary";
|
|
31
|
+
secondary: "secondary";
|
|
32
|
+
}>>;
|
|
33
|
+
}, z.core.$strict>;
|
|
34
|
+
export type Action = z.infer<typeof actionSchema>;
|
|
35
|
+
//# sourceMappingURL=action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../src/action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;;;;;oBAG3B,CAAA;AAEF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAEzD;;;;;GAKG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;kBAIvB,CAAA;AAEF,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA"}
|
package/dist/action.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { plainTextSchema } from './plain-text.js';
|
|
3
|
+
/**
|
|
4
|
+
* Contract B, "Actions". The shape is fixed and shared by `hero` and `cta`.
|
|
5
|
+
*
|
|
6
|
+
* A target is either an external URL or an entity reference. Referencing the
|
|
7
|
+
* entity rather than its URL is what makes a slug change harmless.
|
|
8
|
+
*/
|
|
9
|
+
export const linkTargetSchema = z.union([
|
|
10
|
+
z.strictObject({ href: z.string().min(1) }),
|
|
11
|
+
z.strictObject({ collection: z.string().min(1), id: z.string().min(1) }),
|
|
12
|
+
]);
|
|
13
|
+
/**
|
|
14
|
+
* `emphasis` is a semantic intent — which action matters most — that the theme
|
|
15
|
+
* translates as it sees fit. It is not a CSS class in disguise: `'btn-lg'`
|
|
16
|
+
* would be a presentation value, forbidden by rule R3. The distinction is thin
|
|
17
|
+
* on paper and decisive in use.
|
|
18
|
+
*/
|
|
19
|
+
export const actionSchema = z.strictObject({
|
|
20
|
+
label: plainTextSchema.min(1),
|
|
21
|
+
target: linkTargetSchema,
|
|
22
|
+
emphasis: z.enum(['primary', 'secondary']).optional(),
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.js","sourceRoot":"","sources":["../src/action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC;IACtC,CAAC,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3C,CAAC,CAAC,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;CACzE,CAAC,CAAA;AAIF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,YAAY,CAAC;IACzC,KAAK,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7B,MAAM,EAAE,gBAAgB;IACxB,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,QAAQ,EAAE;CACtD,CAAC,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type BlockSchema } from './field.js';
|
|
2
|
+
import { type BlockDefinition, type BlockManifest } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Declares a block: its identity, its data, and what a renderer needs to know
|
|
5
|
+
* about it before rendering anything.
|
|
6
|
+
*
|
|
7
|
+
* The manifest is checked here rather than at first use, because a malformed
|
|
8
|
+
* block definition is a programming error that must surface at import time —
|
|
9
|
+
* not on the one page in a thousand that happens to use the block.
|
|
10
|
+
*/
|
|
11
|
+
export declare function defineBlock<const N extends string, const S extends BlockSchema>(manifest: BlockManifest<N, S>): BlockDefinition<N, S>;
|
|
12
|
+
//# sourceMappingURL=define-block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-block.d.ts","sourceRoot":"","sources":["../src/define-block.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,YAAY,CAAA;AAChE,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,aAAa,EAGnB,MAAM,YAAY,CAAA;AASnB;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,CAAC,CAAC,SAAS,WAAW,EAC7E,QAAQ,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,GAC5B,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAmDvB"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { invalidBlockDefinition } from './errors.js';
|
|
3
|
+
import { BLOCK_FIELD_KINDS } from './field.js';
|
|
4
|
+
import { BLOCK_RUNTIMES, HEADING_LEVELS, } from './types.js';
|
|
5
|
+
import { isBlockVersion } from './version.js';
|
|
6
|
+
/** Reserved by the envelope. A field may not shadow one. */
|
|
7
|
+
const RESERVED_FIELDS = new Set(['_key', '_type', '_version']);
|
|
8
|
+
/** Matches the vocabulary's own names: `hero`, `mediaFigure`, `collectionList`. */
|
|
9
|
+
const BLOCK_NAME = /^[a-z][a-zA-Z0-9]*$/;
|
|
10
|
+
/**
|
|
11
|
+
* Declares a block: its identity, its data, and what a renderer needs to know
|
|
12
|
+
* about it before rendering anything.
|
|
13
|
+
*
|
|
14
|
+
* The manifest is checked here rather than at first use, because a malformed
|
|
15
|
+
* block definition is a programming error that must surface at import time —
|
|
16
|
+
* not on the one page in a thousand that happens to use the block.
|
|
17
|
+
*/
|
|
18
|
+
export function defineBlock(manifest) {
|
|
19
|
+
const { name, version, schema, runtime, fallback, a11y } = manifest;
|
|
20
|
+
if (!BLOCK_NAME.test(name)) {
|
|
21
|
+
throw invalidBlockDefinition(name, 'the name must be camelCase, starting with a letter');
|
|
22
|
+
}
|
|
23
|
+
if (!isBlockVersion(version)) {
|
|
24
|
+
throw invalidBlockDefinition(name, `"${version}" is not a major.minor.patch version`);
|
|
25
|
+
}
|
|
26
|
+
if (!BLOCK_RUNTIMES.includes(runtime)) {
|
|
27
|
+
throw invalidBlockDefinition(name, `runtime must be one of ${BLOCK_RUNTIMES.join(', ')}`);
|
|
28
|
+
}
|
|
29
|
+
if (!HEADING_LEVELS.includes(a11y.headingLevel)) {
|
|
30
|
+
throw invalidBlockDefinition(name, `a11y.headingLevel must be one of ${HEADING_LEVELS.join(', ')}`);
|
|
31
|
+
}
|
|
32
|
+
if (fallback !== null && (fallback === name || !BLOCK_NAME.test(fallback))) {
|
|
33
|
+
throw invalidBlockDefinition(name, 'fallback must be null or the name of another block');
|
|
34
|
+
}
|
|
35
|
+
const shape = {
|
|
36
|
+
_key: z.string().min(1),
|
|
37
|
+
_type: z.literal(name),
|
|
38
|
+
_version: z.string().refine(isBlockVersion, { error: 'must be a major.minor.patch version' }),
|
|
39
|
+
};
|
|
40
|
+
for (const [field, definition] of Object.entries(schema)) {
|
|
41
|
+
if (RESERVED_FIELDS.has(field)) {
|
|
42
|
+
throw invalidBlockDefinition(name, `"${field}" is reserved by the block envelope`);
|
|
43
|
+
}
|
|
44
|
+
if (!BLOCK_FIELD_KINDS.includes(definition.kind)) {
|
|
45
|
+
throw invalidBlockDefinition(name, `field "${field}" uses "${definition.kind}", which contract B does not allow inside a block`);
|
|
46
|
+
}
|
|
47
|
+
shape[field] = definition.required ? definition.zod : definition.zod.optional();
|
|
48
|
+
}
|
|
49
|
+
// Strict on purpose, and this is where rule R3 is enforced structurally: a
|
|
50
|
+
// `className`, a `style` or an `html` key is not ignored, it is refused. An
|
|
51
|
+
// ignored key would be silently dropped on the next write instead.
|
|
52
|
+
//
|
|
53
|
+
// The cast bridges the shape assembled at runtime and the type derived from
|
|
54
|
+
// the schema at compile time; both describe the same object, and only the
|
|
55
|
+
// compiler cannot see it.
|
|
56
|
+
const validator = z.strictObject(shape);
|
|
57
|
+
return { name, version, schema, runtime, fallback, a11y, validator };
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=define-block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-block.js","sourceRoot":"","sources":["../src/define-block.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,iBAAiB,EAAoB,MAAM,YAAY,CAAA;AAChE,OAAO,EACL,cAAc,EAGd,cAAc,GAEf,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C,4DAA4D;AAC5D,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAA;AAE9D,mFAAmF;AACnF,MAAM,UAAU,GAAG,qBAAqB,CAAA;AAExC;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CACzB,QAA6B;IAE7B,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAA;IAEnE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,MAAM,sBAAsB,CAAC,IAAI,EAAE,oDAAoD,CAAC,CAAA;IAC1F,CAAC;IACD,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7B,MAAM,sBAAsB,CAAC,IAAI,EAAE,IAAI,OAAO,sCAAsC,CAAC,CAAA;IACvF,CAAC;IACD,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACtC,MAAM,sBAAsB,CAAC,IAAI,E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AAQ,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAA;IACjF,CAAC;IAED,2EAA2E;IAC3E,4EAA4E;IAC5E,mEAAmE;IACnE,EAAE;IACF,4EAA4E;IAC5E,0EAA0E;IAC1E,0BAA0B;IAC1B,MAAM,SAAS,GAAG,CAAC,CAAC,YAAY,CAAC,KAAK,CAA4C,CAAA;IAElF,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;AACtE,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CogentaError } from '@cogenta/core';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* Every error this package throws names the block, and — when the failure is a
|
|
5
|
+
* validation failure — the field. "Invalid block" alone is useless to an editor
|
|
6
|
+
* looking at twenty blocks on a page.
|
|
7
|
+
*/
|
|
8
|
+
/** Renders Zod issues as `field: reason`, one per line, so nothing is hidden. */
|
|
9
|
+
export declare function formatBlockIssues(error: z.ZodError): string;
|
|
10
|
+
export declare function invalidBlockDefinition(name: string, reason: string): CogentaError;
|
|
11
|
+
export declare function invalidBlock(name: string, key: string | undefined, error: z.ZodError): CogentaError;
|
|
12
|
+
export declare function unknownBlock(name: string, known: readonly string[]): CogentaError;
|
|
13
|
+
export declare function blockMigrationFailed(name: string, from: string, to: string, reason: string): CogentaError;
|
|
14
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B;;;;GAIG;AAEH,iFAAiF;AACjF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,GAAG,MAAM,CAO3D;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,YAAY,CAOjF;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,KAAK,EAAE,CAAC,CAAC,QAAQ,GAChB,YAAY,CAad;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,YAAY,CAOjF;AAED,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,MAAM,GACb,YAAY,CAOd"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { CogentaError } from '@cogenta/core';
|
|
2
|
+
/**
|
|
3
|
+
* Every error this package throws names the block, and — when the failure is a
|
|
4
|
+
* validation failure — the field. "Invalid block" alone is useless to an editor
|
|
5
|
+
* looking at twenty blocks on a page.
|
|
6
|
+
*/
|
|
7
|
+
/** Renders Zod issues as `field: reason`, one per line, so nothing is hidden. */
|
|
8
|
+
export function formatBlockIssues(error) {
|
|
9
|
+
return error.issues
|
|
10
|
+
.map((issue) => {
|
|
11
|
+
const path = issue.path.map(String).join('.');
|
|
12
|
+
return ` ${path === '' ? '(block)' : path}: ${issue.message}`;
|
|
13
|
+
})
|
|
14
|
+
.join('\n');
|
|
15
|
+
}
|
|
16
|
+
export function invalidBlockDefinition(name, reason) {
|
|
17
|
+
return new CogentaError({
|
|
18
|
+
code: 'BLOCK_DEFINITION_INVALID',
|
|
19
|
+
message: `Block "${name}" cannot be defined: ${reason}`,
|
|
20
|
+
hint: 'A block manifest follows contract B: name, version, schema, runtime, fallback, a11y.',
|
|
21
|
+
details: { block: name },
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export function invalidBlock(name, key, error) {
|
|
25
|
+
// An unrecognised key carries an empty path — the offending name is in
|
|
26
|
+
// `keys`. Reporting it is the whole point here: the field a theme tried to
|
|
27
|
+
// smuggle in is exactly what the author needs to see.
|
|
28
|
+
const fields = error.issues.flatMap((issue) => issue.code === 'unrecognized_keys' ? issue.keys : [issue.path.map(String).join('.')]);
|
|
29
|
+
return new CogentaError({
|
|
30
|
+
code: 'BLOCK_INVALID',
|
|
31
|
+
message: `Block "${name}"${key === undefined ? '' : ` (${key})`} is invalid:\n${formatBlockIssues(error)}`,
|
|
32
|
+
hint: 'A block stores semantic data only: no HTML, no CSS class, no style value (rule R3).',
|
|
33
|
+
details: { block: name, key, fields },
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
export function unknownBlock(name, known) {
|
|
37
|
+
return new CogentaError({
|
|
38
|
+
code: 'BLOCK_UNKNOWN',
|
|
39
|
+
message: `Block "${name}" is not registered.`,
|
|
40
|
+
hint: `Known blocks: ${known.join(', ')}. A theme-specific block must be registered before use, with a fallback.`,
|
|
41
|
+
details: { block: name, known },
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export function blockMigrationFailed(name, from, to, reason) {
|
|
45
|
+
return new CogentaError({
|
|
46
|
+
code: 'BLOCK_MIGRATION_FAILED',
|
|
47
|
+
message: `Block "${name}" cannot be migrated from ${from} to ${to}: ${reason}`,
|
|
48
|
+
hint: 'Register a migration for every version step, so stored content is never left in an ambiguous state.',
|
|
49
|
+
details: { block: name, from, to },
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAG5C;;;;GAIG;AAEH,iFAAiF;AACjF,M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CAAC,KAAK,CAAC,EAAE;QAC1G,IAAI,EAAE,qFAAqF;QAC3F,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE;KACtC,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,KAAwB;IACjE,OAAO,IAAI,YAAY,CAAC;QACtB,IAAI,EAAE,eAAe;QACrB,OAAO,EAAE,UAAU,IAAI,sBAAsB;QAC7C,IAAI,EAAE,iBAAiB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,0EAA0E;QACjH,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE;KAChC,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,IAAY,EACZ,IAAY,EACZ,EAAU,EACV,MAAc;IAEd,OAAO,IAAI,YAAY,CAAC;QACtB,IAAI,EAAE,wBAAwB;QAC9B,OAAO,EAAE,UAAU,IAAI,6BAA6B,IAAI,OAAO,EAAE,KAAK,MAAM,EAAE;QAC9E,IAAI,EAAE,qGAAqG;QAC3G,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE;KACnC,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/field.d.ts
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type RichTextDocument } from './rich-text.js';
|
|
3
|
+
/**
|
|
4
|
+
* The field builders a block schema is written with.
|
|
5
|
+
*
|
|
6
|
+
* TEMPORARY. Contract B is explicit: a block describes its fields with **the
|
|
7
|
+
* same `f.*` types as contract A** — one type system for content and for
|
|
8
|
+
* blocks, one validator, one admin renderer, one target for generation. This
|
|
9
|
+
* module is a local stand-in while `@cogenta/schema` is written in parallel; it
|
|
10
|
+
* mirrors `FieldDefinition` from `@cogenta/schema/types` so the two are
|
|
11
|
+
* structurally compatible, and must be replaced by `@cogenta/schema`'s `f` at
|
|
12
|
+
* merge time.
|
|
13
|
+
*
|
|
14
|
+
* Only the nine kinds contract B allows in a block are exposed. `slug`, `date`,
|
|
15
|
+
* `datetime`, `geo` and — above all — `blocks` are deliberately absent: nesting
|
|
16
|
+
* is the gateway to a layout builder, which Cogenta is not (ADR-0009).
|
|
17
|
+
*/
|
|
18
|
+
/** Contract B, "Schéma d'un bloc". A strict subset of contract A's kinds. */
|
|
19
|
+
export declare const BLOCK_FIELD_KINDS: readonly ['text', 'richText', 'number', 'boolean', 'media', 'relation', 'select', 'color', 'json'];
|
|
20
|
+
export type BlockFieldKind = (typeof BLOCK_FIELD_KINDS)[number];
|
|
21
|
+
/** Mirrors `FieldAdminOptions` in `@cogenta/schema/types`. */
|
|
22
|
+
export interface FieldAdminOptions {
|
|
23
|
+
readonly label?: string;
|
|
24
|
+
readonly help?: string;
|
|
25
|
+
readonly group?: string;
|
|
26
|
+
readonly showWhen?: {
|
|
27
|
+
readonly field: string;
|
|
28
|
+
readonly equals: unknown;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A field definition carrying its own validator.
|
|
33
|
+
*
|
|
34
|
+
* The validator lives on the field rather than being recompiled from `kind` and
|
|
35
|
+
* `options` by every consumer: one description, one behaviour, and no drift
|
|
36
|
+
* between what the admin renders and what the writer accepts.
|
|
37
|
+
*/
|
|
38
|
+
export interface BlockField<K extends BlockFieldKind, V, R extends boolean> {
|
|
39
|
+
readonly kind: K;
|
|
40
|
+
/** Kind-specific settings, in the shape `@cogenta/schema` expects. */
|
|
41
|
+
readonly options: Readonly<Record<string, unknown>>;
|
|
42
|
+
readonly required: R;
|
|
43
|
+
readonly localized: boolean;
|
|
44
|
+
readonly admin: FieldAdminOptions | undefined;
|
|
45
|
+
/** Validator for the field's value, optionality aside. */
|
|
46
|
+
readonly zod: z.ZodType<V>;
|
|
47
|
+
}
|
|
48
|
+
export type AnyBlockField = BlockField<BlockFieldKind, unknown, boolean>;
|
|
49
|
+
/** A block's fields, by name. */
|
|
50
|
+
export type BlockSchema = Readonly<Record<string, AnyBlockField>>;
|
|
51
|
+
export interface CommonFieldOptions<R extends boolean = false> {
|
|
52
|
+
readonly required?: R;
|
|
53
|
+
readonly localized?: boolean;
|
|
54
|
+
readonly admin?: FieldAdminOptions;
|
|
55
|
+
}
|
|
56
|
+
type NotRequired = {
|
|
57
|
+
readonly required?: false;
|
|
58
|
+
};
|
|
59
|
+
/** `required: true` written literally at the call site becomes a literal type. */
|
|
60
|
+
type IsRequired<O> = O extends {
|
|
61
|
+
readonly required: true;
|
|
62
|
+
} ? true : false;
|
|
63
|
+
export interface TextFieldOptions<R extends boolean = false> extends CommonFieldOptions<R> {
|
|
64
|
+
readonly min?: number;
|
|
65
|
+
readonly max?: number;
|
|
66
|
+
/**
|
|
67
|
+
* A shape the value must take beyond being text. Only `url` exists so far,
|
|
68
|
+
* because only `embed.url` needs it; the list grows from real needs, not from
|
|
69
|
+
* anticipation.
|
|
70
|
+
*/
|
|
71
|
+
readonly format?: 'url';
|
|
72
|
+
}
|
|
73
|
+
declare function text<const O extends TextFieldOptions<boolean> = NotRequired>(o?: O): BlockField<'text', string, IsRequired<O>>;
|
|
74
|
+
declare function richText<const O extends CommonFieldOptions<boolean> = NotRequired>(o?: O): BlockField<'richText', RichTextDocument, IsRequired<O>>;
|
|
75
|
+
export interface NumberFieldOptions<R extends boolean = false> extends CommonFieldOptions<R> {
|
|
76
|
+
readonly min?: number;
|
|
77
|
+
readonly max?: number;
|
|
78
|
+
readonly integer?: boolean;
|
|
79
|
+
}
|
|
80
|
+
declare function number<const O extends NumberFieldOptions<boolean> = NotRequired>(o?: O): BlockField<'number', number, IsRequired<O>>;
|
|
81
|
+
declare function boolean<const O extends CommonFieldOptions<boolean> = NotRequired>(o?: O): BlockField<'boolean', boolean, IsRequired<O>>;
|
|
82
|
+
export type MediaKind = 'image' | 'video' | 'audio' | 'file';
|
|
83
|
+
export interface MediaFieldOptions<R extends boolean = false> extends CommonFieldOptions<R> {
|
|
84
|
+
readonly accept?: readonly MediaKind[];
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* A media field stores the media library's identifier, never an URL and never a
|
|
88
|
+
* rendition. Alt text, dimensions and variants belong to the media entry, so
|
|
89
|
+
* they are corrected in one place and every block pointing at it follows.
|
|
90
|
+
*/
|
|
91
|
+
declare function media<const O extends MediaFieldOptions<boolean> = NotRequired>(o?: O): BlockField<'media', string, IsRequired<O>>;
|
|
92
|
+
export interface RelationFieldOptions<R extends boolean = false> extends CommonFieldOptions<R> {
|
|
93
|
+
readonly to: string;
|
|
94
|
+
readonly many?: boolean;
|
|
95
|
+
}
|
|
96
|
+
type RelationValue<O> = O extends {
|
|
97
|
+
readonly many: true;
|
|
98
|
+
} ? string[] : string;
|
|
99
|
+
declare function relation<const O extends RelationFieldOptions<boolean>>(o: O): BlockField<'relation', RelationValue<O>, IsRequired<O>>;
|
|
100
|
+
export interface SelectFieldOptions<R extends boolean = false> extends CommonFieldOptions<R> {
|
|
101
|
+
readonly options: readonly [string, ...string[]];
|
|
102
|
+
}
|
|
103
|
+
declare function select<const O extends SelectFieldOptions<boolean>>(o: O): BlockField<'select', O['options'][number], IsRequired<O>>;
|
|
104
|
+
export interface ColorFieldOptions<R extends boolean = false> extends CommonFieldOptions<R> {
|
|
105
|
+
/** Restrict the field to named skin tokens rather than free hex values. */
|
|
106
|
+
readonly tokens?: readonly [string, ...string[]];
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Available because contract B lists it, and used by none of the twelve blocks
|
|
110
|
+
* on purpose: a colour picked per block is a presentation value, and rule R3
|
|
111
|
+
* keeps those in the theme's skin tokens. A block-level colour only earns its
|
|
112
|
+
* place when it carries meaning the theme cannot know — the brand colour of an
|
|
113
|
+
* imported partner logo, say — and `tokens` is then the safer form.
|
|
114
|
+
*/
|
|
115
|
+
declare function color<const O extends ColorFieldOptions<boolean> = NotRequired>(o?: O): BlockField<'color', string, IsRequired<O>>;
|
|
116
|
+
export type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
117
|
+
[key: string]: JsonValue;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* The shape a `json` or `list` field holds is passed positionally, not inside
|
|
121
|
+
* the options object. Inside it, the contextual type of a block schema widens
|
|
122
|
+
* `required: true` back to `boolean`, and every list would end up optional.
|
|
123
|
+
*/
|
|
124
|
+
declare function json<V = JsonValue, const O extends CommonFieldOptions<boolean> = NotRequired>(of?: z.ZodType<V>, o?: O): BlockField<'json', V, IsRequired<O>>;
|
|
125
|
+
export interface ListFieldOptions<R extends boolean = false> extends CommonFieldOptions<R> {
|
|
126
|
+
readonly min?: number;
|
|
127
|
+
readonly max?: number;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* A repeated, structured field — the `items[]` of the vocabulary.
|
|
131
|
+
*
|
|
132
|
+
* Contract A has no `array` kind, so a list is stored as a `json` field with an
|
|
133
|
+
* explicit item schema. That keeps a block schema inside the nine allowed kinds
|
|
134
|
+
* while still refusing an item with a missing or unknown key, which a bare
|
|
135
|
+
* `json` field would wave through.
|
|
136
|
+
*/
|
|
137
|
+
declare function list<T, const O extends ListFieldOptions<boolean> = NotRequired>(of: z.ZodType<T>, o?: O): BlockField<'json', T[], IsRequired<O>>;
|
|
138
|
+
export declare const f: {
|
|
139
|
+
readonly text: typeof text;
|
|
140
|
+
readonly richText: typeof richText;
|
|
141
|
+
readonly number: typeof number;
|
|
142
|
+
readonly boolean: typeof boolean;
|
|
143
|
+
readonly media: typeof media;
|
|
144
|
+
readonly relation: typeof relation;
|
|
145
|
+
readonly select: typeof select;
|
|
146
|
+
readonly color: typeof color;
|
|
147
|
+
readonly json: typeof json;
|
|
148
|
+
readonly list: typeof list;
|
|
149
|
+
};
|
|
150
|
+
/** The value a field holds once parsed. */
|
|
151
|
+
export type FieldValue<F> = F extends BlockField<BlockFieldKind, infer V, boolean> ? V : never;
|
|
152
|
+
type RequiredFieldNames<S extends BlockSchema> = {
|
|
153
|
+
[K in keyof S]: S[K]['required'] extends true ? K : never;
|
|
154
|
+
}[keyof S];
|
|
155
|
+
type Simplify<T> = {
|
|
156
|
+
[K in keyof T]: T[K];
|
|
157
|
+
} & {};
|
|
158
|
+
/** The data a block of schema `S` holds, required and optional keys apart. */
|
|
159
|
+
export type BlockData<S extends BlockSchema> = Simplify<{
|
|
160
|
+
[K in RequiredFieldNames<S>]: FieldValue<S[K]>;
|
|
161
|
+
} & {
|
|
162
|
+
[K in Exclude<keyof S, RequiredFieldNames<S>>]?: FieldValue<S[K]>;
|
|
163
|
+
}>;
|
|
164
|
+
export {};
|
|
165
|
+
//# sourceMappingURL=field.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../src/field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,KAAK,gBAAgB,EAA0B,MAAM,gBAAgB,CAAA;AAE9E;;;;;;;;;;;;;;GAcG;AAEH,6EAA6E;AAC7E,eAAO,MAAM,iBAAiB,YAC5B,MAAM,EACN,UAAU,EACV,QAAQ,EACR,SAAS,EACT,OAAO,EACP,UAAU,EACV,QAAQ,EACR,OAAO,EACP,MAAM,CACE,CAAA;AAEV,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAA;AAE/D,8DAA8D;AAC9D,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;KAAE,CAAA;CACz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z } from 'zod';
|
|
2
|
+
import { plainTextSchema } from './plain-text.js';
|
|
3
|
+
import { richTextDocumentSchema } from './rich-text.js';
|
|
4
|
+
/**
|
|
5
|
+
* The field builders a block schema is written with.
|
|
6
|
+
*
|
|
7
|
+
* TEMPORARY. Contract B is explicit: a block describes its fields with **the
|
|
8
|
+
* same `f.*` types as contract A** — one type system for content and for
|
|
9
|
+
* blocks, one validator, one admin renderer, one target for generation. This
|
|
10
|
+
* module is a local stand-in while `@cogenta/schema` is written in parallel; it
|
|
11
|
+
* mirrors `FieldDefinition` from `@cogenta/schema/types` so the two are
|
|
12
|
+
* structurally compatible, and must be replaced by `@cogenta/schema`'s `f` at
|
|
13
|
+
* merge time.
|
|
14
|
+
*
|
|
15
|
+
* Only the nine kinds contract B allows in a block are exposed. `slug`, `date`,
|
|
16
|
+
* `datetime`, `geo` and — above all — `blocks` are deliberately absent: nesting
|
|
17
|
+
* is the gateway to a layout builder, which Cogenta is not (ADR-0009).
|
|
18
|
+
*/
|
|
19
|
+
/** Contract B, "Schéma d'un bloc". A strict subset of contract A's kinds. */
|
|
20
|
+
export const BLOCK_FIELD_KINDS = [
|
|
21
|
+
'text',
|
|
22
|
+
'richText',
|
|
23
|
+
'number',
|
|
24
|
+
'boolean',
|
|
25
|
+
'media',
|
|
26
|
+
'relation',
|
|
27
|
+
'select',
|
|
28
|
+
'color',
|
|
29
|
+
'json',
|
|
30
|
+
];
|
|
31
|
+
/**
|
|
32
|
+
* The one place a runtime boolean is bridged to the literal type derived from
|
|
33
|
+
* the call site. Doing it once here keeps every builder below cast-free.
|
|
34
|
+
*/
|
|
35
|
+
function makeField(kind, zod, options, o) {
|
|
36
|
+
return {
|
|
37
|
+
kind,
|
|
38
|
+
options,
|
|
39
|
+
required: (o.required ?? false),
|
|
40
|
+
localized: o.localized ?? false,
|
|
41
|
+
admin: o.admin,
|
|
42
|
+
zod,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function text(o) {
|
|
46
|
+
const opts = o ?? {};
|
|
47
|
+
let schema = plainTextSchema;
|
|
48
|
+
if (opts.min !== undefined)
|
|
49
|
+
schema = schema.min(opts.min);
|
|
50
|
+
if (opts.max !== undefined)
|
|
51
|
+
schema = schema.max(opts.max);
|
|
52
|
+
if (opts.format === 'url') {
|
|
53
|
+
schema = schema.refine((value) => URL.canParse(value), {
|
|
54
|
+
error: 'must be an absolute URL',
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return makeField('text', schema, { min: opts.min, max: opts.max, format: opts.format }, opts);
|
|
58
|
+
}
|
|
59
|
+
function richText(o) {
|
|
60
|
+
return makeField('richText', richTextDocumentSchema, {}, o ?? {});
|
|
61
|
+
}
|
|
62
|
+
function number(o) {
|
|
63
|
+
const opts = o ?? {};
|
|
64
|
+
let schema = z.number();
|
|
65
|
+
if (opts.integer === true)
|
|
66
|
+
schema = schema.int();
|
|
67
|
+
if (opts.min !== undefined)
|
|
68
|
+
schema = schema.min(opts.min);
|
|
69
|
+
if (opts.max !== undefined)
|
|
70
|
+
schema = schema.max(opts.max);
|
|
71
|
+
return makeField('number', schema, { min: opts.min, max: opts.max, integer: opts.integer ?? false }, opts);
|
|
72
|
+
}
|
|
73
|
+
function boolean(o) {
|
|
74
|
+
return makeField('boolean', z.boolean(), {}, o ?? {});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A media field stores the media library's identifier, never an URL and never a
|
|
78
|
+
* rendition. Alt text, dimensions and variants belong to the media entry, so
|
|
79
|
+
* they are corrected in one place and every block pointing at it follows.
|
|
80
|
+
*/
|
|
81
|
+
function media(o) {
|
|
82
|
+
const opts = o ?? {};
|
|
83
|
+
return makeField('media', z.string().min(1), { accept: opts.accept }, opts);
|
|
84
|
+
}
|
|
85
|
+
function relation(o) {
|
|
86
|
+
const id = z.string().min(1);
|
|
87
|
+
const schema = (o.many === true ? z.array(id) : id);
|
|
88
|
+
return makeField('relation', schema, { to: o.to, many: o.many ?? false }, o);
|
|
89
|
+
}
|
|
90
|
+
function select(o) {
|
|
91
|
+
const schema = z.enum([...o.options]);
|
|
92
|
+
return makeField('select', schema, { options: o.options }, o);
|
|
93
|
+
}
|
|
94
|
+
const HEX_COLOR = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
|
|
95
|
+
/**
|
|
96
|
+
* Available because contract B lists it, and used by none of the twelve blocks
|
|
97
|
+
* on purpose: a colour picked per block is a presentation value, and rule R3
|
|
98
|
+
* keeps those in the theme's skin tokens. A block-level colour only earns its
|
|
99
|
+
* place when it carries meaning the theme cannot know — the brand colour of an
|
|
100
|
+
* imported partner logo, say — and `tokens` is then the safer form.
|
|
101
|
+
*/
|
|
102
|
+
function color(o) {
|
|
103
|
+
const opts = o ?? {};
|
|
104
|
+
const tokens = opts.tokens;
|
|
105
|
+
const schema = tokens === undefined
|
|
106
|
+
? z.string().regex(HEX_COLOR, { error: 'must be a hex colour such as #1a2b3c' })
|
|
107
|
+
: z.enum([...tokens]);
|
|
108
|
+
return makeField('color', schema, { tokens }, opts);
|
|
109
|
+
}
|
|
110
|
+
const jsonValueSchema = z.lazy(() => z.union([
|
|
111
|
+
z.string(),
|
|
112
|
+
z.number(),
|
|
113
|
+
z.boolean(),
|
|
114
|
+
z.null(),
|
|
115
|
+
z.array(jsonValueSchema),
|
|
116
|
+
z.record(z.string(), jsonValueSchema),
|
|
117
|
+
]));
|
|
118
|
+
/**
|
|
119
|
+
* The shape a `json` or `list` field holds is passed positionally, not inside
|
|
120
|
+
* the options object. Inside it, the contextual type of a block schema widens
|
|
121
|
+
* `required: true` back to `boolean`, and every list would end up optional.
|
|
122
|
+
*/
|
|
123
|
+
function json(of, o) {
|
|
124
|
+
const schema = (of ?? jsonValueSchema);
|
|
125
|
+
return makeField('json', schema, {}, o ?? {});
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* A repeated, structured field — the `items[]` of the vocabulary.
|
|
129
|
+
*
|
|
130
|
+
* Contract A has no `array` kind, so a list is stored as a `json` field with an
|
|
131
|
+
* explicit item schema. That keeps a block schema inside the nine allowed kinds
|
|
132
|
+
* while still refusing an item with a missing or unknown key, which a bare
|
|
133
|
+
* `json` field would wave through.
|
|
134
|
+
*/
|
|
135
|
+
function list(of, o) {
|
|
136
|
+
const opts = o ?? {};
|
|
137
|
+
let schema = z.array(of);
|
|
138
|
+
if (opts.min !== undefined)
|
|
139
|
+
schema = schema.min(opts.min);
|
|
140
|
+
if (opts.max !== undefined)
|
|
141
|
+
schema = schema.max(opts.max);
|
|
142
|
+
return makeField('json', schema, { list: true, min: opts.min, max: opts.max }, opts);
|
|
143
|
+
}
|
|
144
|
+
export const f = {
|
|
145
|
+
text,
|
|
146
|
+
richText,
|
|
147
|
+
number,
|
|
148
|
+
boolean,
|
|
149
|
+
media,
|
|
150
|
+
relation,
|
|
151
|
+
select,
|
|
152
|
+
color,
|
|
153
|
+
json,
|
|
154
|
+
list,
|
|
155
|
+
};
|
|
156
|
+
//# sourceMappingURL=field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field.js","sourceRoot":"","sources":["../src/field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAyB,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAE9E;;;;;;;;;;;;;;GAcG;AAEH,6EAA6E;AAC7E,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,MAAM;IACN,UAAU;IACV,QAAQ;IACR,SAAS;IACT,OAAO;IACP,UAAU;IACV,QAAQ;IACR,OAAO;IACP,MAAM;CACE,CAAA;AA8CV;;;GAGG;AACH,SAAS,SAAS,CAChB,IAAO,EACP,GAAiB,EACjB,OAA0C,EAC1C,CAA8B;IAE9B,OAAO;QACL,IAAI;QACJ,OAAO;QACP,QAAQ,EAAE,CAAC,CAAC,CAAC,QAAQ,IAAI,KAAK,CAA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EAAiB,EACjB,CAAK;IAEL,MAAM,MAAM,GAAG,CAAC,EAAE,IAAI,eAAe,CAAiB,CAAA;IACtD,OAAO,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,CAAA;AAC/C,CAAC;AAOD;;;;;;;GAOG;AACH,SAAS,IAAI,CACX,EAAgB,EAChB,CAAK;IAEL,MAAM,IAAI,GAA8B,CAAC,IAAI,EAAE,CAAA;IAC/C,IAAI,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IACxB,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS;QAAE,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACzD,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS;QAAE,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACzD,OAAO,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAA;AACtF,CAAC;AAED,MAAM,CAAC,MAAM,CAAC,GAAG;IACf,IAAI;IACJ,QAAQ;IACR,MAAM;IACN,OAAO;IACP,KAAK;IACL,QAAQ;IACR,MAAM;IACN,KAAK;IACL,IAAI;IACJ,IAAI;CACI,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './action.js';
|
|
2
|
+
export * from './define-block.js';
|
|
3
|
+
export * from './errors.js';
|
|
4
|
+
export * from './field.js';
|
|
5
|
+
export * from './migrate.js';
|
|
6
|
+
export * from './plain-text.js';
|
|
7
|
+
export * from './registry.js';
|
|
8
|
+
export * from './rich-text.js';
|
|
9
|
+
export * from './types.js';
|
|
10
|
+
export * from './validate.js';
|
|
11
|
+
export * from './version.js';
|
|
12
|
+
export * from './vocabulary.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './action.js';
|
|
2
|
+
export * from './define-block.js';
|
|
3
|
+
export * from './errors.js';
|
|
4
|
+
export * from './field.js';
|
|
5
|
+
export * from './migrate.js';
|
|
6
|
+
export * from './plain-text.js';
|
|
7
|
+
export * from './registry.js';
|
|
8
|
+
export * from './rich-text.js';
|
|
9
|
+
export * from './types.js';
|
|
10
|
+
export * from './validate.js';
|
|
11
|
+
export * from './version.js';
|
|
12
|
+
export * from './vocabulary.js';
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA"}
|