@unito/integration-api 8.0.1 → 8.0.2
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/schemas/definitions.json +35 -0
- package/dist/schemas/fieldSchema.json +6 -0
- package/dist/src/index.cjs +55 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/richText.d.ts +59 -0
- package/dist/src/richText.js +52 -0
- package/dist/src/types.d.ts +28 -2
- package/package.json +1 -1
|
@@ -24,6 +24,41 @@
|
|
|
24
24
|
"url"
|
|
25
25
|
]
|
|
26
26
|
},
|
|
27
|
+
"richTextNodeType": {
|
|
28
|
+
"$id": "RichTextNodeType",
|
|
29
|
+
"type": "string",
|
|
30
|
+
"enum": [
|
|
31
|
+
"blockquote",
|
|
32
|
+
"break",
|
|
33
|
+
"code",
|
|
34
|
+
"delete",
|
|
35
|
+
"emphasis",
|
|
36
|
+
"heading1",
|
|
37
|
+
"heading2",
|
|
38
|
+
"heading3",
|
|
39
|
+
"heading4",
|
|
40
|
+
"heading5",
|
|
41
|
+
"heading6",
|
|
42
|
+
"highlight",
|
|
43
|
+
"image",
|
|
44
|
+
"inlineCode",
|
|
45
|
+
"link",
|
|
46
|
+
"listItem",
|
|
47
|
+
"listOrdered",
|
|
48
|
+
"listUnordered",
|
|
49
|
+
"paragraph",
|
|
50
|
+
"reference",
|
|
51
|
+
"strong",
|
|
52
|
+
"subscript",
|
|
53
|
+
"superscript",
|
|
54
|
+
"table",
|
|
55
|
+
"tableCell",
|
|
56
|
+
"tableRow",
|
|
57
|
+
"text",
|
|
58
|
+
"thematicBreak",
|
|
59
|
+
"underline"
|
|
60
|
+
]
|
|
61
|
+
},
|
|
27
62
|
"semantic": {
|
|
28
63
|
"$id": "Semantic",
|
|
29
64
|
"type": ["string", "null"],
|
package/dist/src/index.cjs
CHANGED
|
@@ -873,11 +873,65 @@ function matchesFilter(item, filter) {
|
|
|
873
873
|
return item[filter.property] === filter.value;
|
|
874
874
|
}
|
|
875
875
|
|
|
876
|
+
/**
|
|
877
|
+
* Published rich text node vocabulary, following the unist structural convention.
|
|
878
|
+
* Every node has `{ type, children?, value?, data? }`.
|
|
879
|
+
*
|
|
880
|
+
* Per-variant types are used where providers have real capability variance
|
|
881
|
+
* (e.g., heading depth support differs across providers; ordered and unordered
|
|
882
|
+
* lists are independent capabilities). Semantically-equivalent HTML synonyms
|
|
883
|
+
* collapse to the canonical type at parse time — `<b>`/`<strong>` yield
|
|
884
|
+
* `strong`, `<i>`/`<em>` yield `emphasis`, `<s>`/`<strike>`/`<del>` yield
|
|
885
|
+
* `delete`.
|
|
886
|
+
*
|
|
887
|
+
* Nodes whose `type` is not in this list are treated as custom-typed nodes by
|
|
888
|
+
* the Syncer and sentinel-encoded when the target doesn't declare support.
|
|
889
|
+
*
|
|
890
|
+
* Ref: https://github.com/unitoio/sync-services/issues/3239
|
|
891
|
+
*/
|
|
892
|
+
const RichTextNodeTypes = {
|
|
893
|
+
// Block
|
|
894
|
+
PARAGRAPH: 'paragraph',
|
|
895
|
+
HEADING_1: 'heading1',
|
|
896
|
+
HEADING_2: 'heading2',
|
|
897
|
+
HEADING_3: 'heading3',
|
|
898
|
+
HEADING_4: 'heading4',
|
|
899
|
+
HEADING_5: 'heading5',
|
|
900
|
+
HEADING_6: 'heading6',
|
|
901
|
+
BLOCKQUOTE: 'blockquote',
|
|
902
|
+
CODE: 'code',
|
|
903
|
+
LIST_ORDERED: 'listOrdered',
|
|
904
|
+
LIST_UNORDERED: 'listUnordered',
|
|
905
|
+
LIST_ITEM: 'listItem',
|
|
906
|
+
TABLE: 'table',
|
|
907
|
+
TABLE_ROW: 'tableRow',
|
|
908
|
+
TABLE_CELL: 'tableCell',
|
|
909
|
+
THEMATIC_BREAK: 'thematicBreak',
|
|
910
|
+
IMAGE: 'image',
|
|
911
|
+
BREAK: 'break',
|
|
912
|
+
// Inline
|
|
913
|
+
TEXT: 'text',
|
|
914
|
+
STRONG: 'strong',
|
|
915
|
+
EMPHASIS: 'emphasis',
|
|
916
|
+
UNDERLINE: 'underline',
|
|
917
|
+
INLINE_CODE: 'inlineCode',
|
|
918
|
+
DELETE: 'delete',
|
|
919
|
+
LINK: 'link',
|
|
920
|
+
SUPERSCRIPT: 'superscript',
|
|
921
|
+
SUBSCRIPT: 'subscript',
|
|
922
|
+
HIGHLIGHT: 'highlight',
|
|
923
|
+
REFERENCE: 'reference',
|
|
924
|
+
};
|
|
925
|
+
function isRichTextNodeType(value) {
|
|
926
|
+
return typeof value === 'string' && Object.values(RichTextNodeTypes).includes(value);
|
|
927
|
+
}
|
|
928
|
+
|
|
876
929
|
exports.FieldSchemaDefaultValues = FieldSchemaDefaultValues;
|
|
877
930
|
exports.FieldValueTypes = FieldValueTypes;
|
|
878
931
|
exports.OperatorTypes = OperatorTypes;
|
|
879
932
|
exports.RelationSchemaDefaultValues = RelationSchemaDefaultValues;
|
|
880
933
|
exports.RelationSemantics = RelationSemantics;
|
|
934
|
+
exports.RichTextNodeTypes = RichTextNodeTypes;
|
|
881
935
|
exports.Semantics = Semantics;
|
|
882
936
|
exports.StatusCodes = StatusCodes;
|
|
883
937
|
exports.fieldTypeCompatibilityMatrix = fieldTypeCompatibilityMatrix;
|
|
@@ -893,6 +947,7 @@ exports.isRelationPointer = isRelationPointer;
|
|
|
893
947
|
exports.isRelationSchema = isRelationSchema;
|
|
894
948
|
exports.isRelationSchemaOrSelf = isRelationSchemaOrSelf;
|
|
895
949
|
exports.isRelationSummary = isRelationSummary;
|
|
950
|
+
exports.isRichTextNodeType = isRichTextNodeType;
|
|
896
951
|
exports.isSemantic = isSemantic;
|
|
897
952
|
exports.isString = isString;
|
|
898
953
|
exports.isUndefined = isUndefined;
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.js
CHANGED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Published rich text node vocabulary, following the unist structural convention.
|
|
3
|
+
* Every node has `{ type, children?, value?, data? }`.
|
|
4
|
+
*
|
|
5
|
+
* Per-variant types are used where providers have real capability variance
|
|
6
|
+
* (e.g., heading depth support differs across providers; ordered and unordered
|
|
7
|
+
* lists are independent capabilities). Semantically-equivalent HTML synonyms
|
|
8
|
+
* collapse to the canonical type at parse time — `<b>`/`<strong>` yield
|
|
9
|
+
* `strong`, `<i>`/`<em>` yield `emphasis`, `<s>`/`<strike>`/`<del>` yield
|
|
10
|
+
* `delete`.
|
|
11
|
+
*
|
|
12
|
+
* Nodes whose `type` is not in this list are treated as custom-typed nodes by
|
|
13
|
+
* the Syncer and sentinel-encoded when the target doesn't declare support.
|
|
14
|
+
*
|
|
15
|
+
* Ref: https://github.com/unitoio/sync-services/issues/3239
|
|
16
|
+
*/
|
|
17
|
+
export declare const RichTextNodeTypes: {
|
|
18
|
+
readonly PARAGRAPH: "paragraph";
|
|
19
|
+
readonly HEADING_1: "heading1";
|
|
20
|
+
readonly HEADING_2: "heading2";
|
|
21
|
+
readonly HEADING_3: "heading3";
|
|
22
|
+
readonly HEADING_4: "heading4";
|
|
23
|
+
readonly HEADING_5: "heading5";
|
|
24
|
+
readonly HEADING_6: "heading6";
|
|
25
|
+
readonly BLOCKQUOTE: "blockquote";
|
|
26
|
+
readonly CODE: "code";
|
|
27
|
+
readonly LIST_ORDERED: "listOrdered";
|
|
28
|
+
readonly LIST_UNORDERED: "listUnordered";
|
|
29
|
+
readonly LIST_ITEM: "listItem";
|
|
30
|
+
readonly TABLE: "table";
|
|
31
|
+
readonly TABLE_ROW: "tableRow";
|
|
32
|
+
readonly TABLE_CELL: "tableCell";
|
|
33
|
+
readonly THEMATIC_BREAK: "thematicBreak";
|
|
34
|
+
readonly IMAGE: "image";
|
|
35
|
+
readonly BREAK: "break";
|
|
36
|
+
readonly TEXT: "text";
|
|
37
|
+
readonly STRONG: "strong";
|
|
38
|
+
readonly EMPHASIS: "emphasis";
|
|
39
|
+
readonly UNDERLINE: "underline";
|
|
40
|
+
readonly INLINE_CODE: "inlineCode";
|
|
41
|
+
readonly DELETE: "delete";
|
|
42
|
+
readonly LINK: "link";
|
|
43
|
+
readonly SUPERSCRIPT: "superscript";
|
|
44
|
+
readonly SUBSCRIPT: "subscript";
|
|
45
|
+
readonly HIGHLIGHT: "highlight";
|
|
46
|
+
readonly REFERENCE: "reference";
|
|
47
|
+
};
|
|
48
|
+
export type RichTextNodeType = (typeof RichTextNodeTypes)[keyof typeof RichTextNodeTypes];
|
|
49
|
+
export interface RichTextNode {
|
|
50
|
+
type: string;
|
|
51
|
+
children?: RichTextNode[];
|
|
52
|
+
value?: string;
|
|
53
|
+
data?: Record<string, unknown>;
|
|
54
|
+
}
|
|
55
|
+
export interface RichTextRoot {
|
|
56
|
+
type: 'root';
|
|
57
|
+
children: RichTextNode[];
|
|
58
|
+
}
|
|
59
|
+
export declare function isRichTextNodeType(value: unknown): value is RichTextNodeType;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Published rich text node vocabulary, following the unist structural convention.
|
|
3
|
+
* Every node has `{ type, children?, value?, data? }`.
|
|
4
|
+
*
|
|
5
|
+
* Per-variant types are used where providers have real capability variance
|
|
6
|
+
* (e.g., heading depth support differs across providers; ordered and unordered
|
|
7
|
+
* lists are independent capabilities). Semantically-equivalent HTML synonyms
|
|
8
|
+
* collapse to the canonical type at parse time — `<b>`/`<strong>` yield
|
|
9
|
+
* `strong`, `<i>`/`<em>` yield `emphasis`, `<s>`/`<strike>`/`<del>` yield
|
|
10
|
+
* `delete`.
|
|
11
|
+
*
|
|
12
|
+
* Nodes whose `type` is not in this list are treated as custom-typed nodes by
|
|
13
|
+
* the Syncer and sentinel-encoded when the target doesn't declare support.
|
|
14
|
+
*
|
|
15
|
+
* Ref: https://github.com/unitoio/sync-services/issues/3239
|
|
16
|
+
*/
|
|
17
|
+
export const RichTextNodeTypes = {
|
|
18
|
+
// Block
|
|
19
|
+
PARAGRAPH: 'paragraph',
|
|
20
|
+
HEADING_1: 'heading1',
|
|
21
|
+
HEADING_2: 'heading2',
|
|
22
|
+
HEADING_3: 'heading3',
|
|
23
|
+
HEADING_4: 'heading4',
|
|
24
|
+
HEADING_5: 'heading5',
|
|
25
|
+
HEADING_6: 'heading6',
|
|
26
|
+
BLOCKQUOTE: 'blockquote',
|
|
27
|
+
CODE: 'code',
|
|
28
|
+
LIST_ORDERED: 'listOrdered',
|
|
29
|
+
LIST_UNORDERED: 'listUnordered',
|
|
30
|
+
LIST_ITEM: 'listItem',
|
|
31
|
+
TABLE: 'table',
|
|
32
|
+
TABLE_ROW: 'tableRow',
|
|
33
|
+
TABLE_CELL: 'tableCell',
|
|
34
|
+
THEMATIC_BREAK: 'thematicBreak',
|
|
35
|
+
IMAGE: 'image',
|
|
36
|
+
BREAK: 'break',
|
|
37
|
+
// Inline
|
|
38
|
+
TEXT: 'text',
|
|
39
|
+
STRONG: 'strong',
|
|
40
|
+
EMPHASIS: 'emphasis',
|
|
41
|
+
UNDERLINE: 'underline',
|
|
42
|
+
INLINE_CODE: 'inlineCode',
|
|
43
|
+
DELETE: 'delete',
|
|
44
|
+
LINK: 'link',
|
|
45
|
+
SUPERSCRIPT: 'superscript',
|
|
46
|
+
SUBSCRIPT: 'subscript',
|
|
47
|
+
HIGHLIGHT: 'highlight',
|
|
48
|
+
REFERENCE: 'reference',
|
|
49
|
+
};
|
|
50
|
+
export function isRichTextNodeType(value) {
|
|
51
|
+
return typeof value === 'string' && Object.values(RichTextNodeTypes).includes(value);
|
|
52
|
+
}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Readable } from 'node:stream';
|
|
2
|
+
import type { RichTextNodeType } from './richText.js';
|
|
2
3
|
/**
|
|
3
4
|
* A Collection represents a paginated list of ItemSummary available through a Relation.
|
|
4
5
|
*/
|
|
@@ -98,7 +99,7 @@ interface AbstractFieldSchema {
|
|
|
98
99
|
*/
|
|
99
100
|
nullable?: boolean;
|
|
100
101
|
}
|
|
101
|
-
type BasicFieldValueType = Exclude<FieldValueType, typeof FieldValueTypes.BLOB | typeof FieldValueTypes.REFERENCE | typeof FieldValueTypes.OBJECT | typeof FieldValueTypes.DATETIME_RANGE | typeof FieldValueTypes.DATE_RANGE>;
|
|
102
|
+
type BasicFieldValueType = Exclude<FieldValueType, typeof FieldValueTypes.BLOB | typeof FieldValueTypes.REFERENCE | typeof FieldValueTypes.OBJECT | typeof FieldValueTypes.DATETIME_RANGE | typeof FieldValueTypes.DATE_RANGE | typeof FieldValueTypes.RICH_TEXT>;
|
|
102
103
|
/**
|
|
103
104
|
* Semantic-constrained BasicFieldSchema variants.
|
|
104
105
|
* Each semantic restricts which field types are valid, matching the runtime
|
|
@@ -244,10 +245,35 @@ export interface ObjectFieldSchema extends AbstractFieldSchema {
|
|
|
244
245
|
*/
|
|
245
246
|
fields: FieldSchema[];
|
|
246
247
|
}
|
|
248
|
+
/**
|
|
249
|
+
* Semantic-constrained RichTextFieldSchema variants.
|
|
250
|
+
* DESCRIPTION is the only semantic that naturally applies to rich text; other
|
|
251
|
+
* semantics (USER, CREATED_AT, etc.) are tied to different field value types.
|
|
252
|
+
*/
|
|
253
|
+
interface DescriptionRichTextFieldSchema extends AbstractFieldSchema {
|
|
254
|
+
semantic: typeof Semantics.DESCRIPTION;
|
|
255
|
+
type: typeof FieldValueTypes.RICH_TEXT;
|
|
256
|
+
/**
|
|
257
|
+
* The published rich text node types this field can round-trip.
|
|
258
|
+
* `text` is mandatory. When omitted, a curated baseline applies (defined
|
|
259
|
+
* elsewhere in this package).
|
|
260
|
+
*
|
|
261
|
+
* Syncer keys off the target field's declaration to decide whether to
|
|
262
|
+
* pass nodes through or sentinel-encode them. Source-side declarations
|
|
263
|
+
* are descriptive and not enforced at runtime.
|
|
264
|
+
*/
|
|
265
|
+
supportedRichTextNodes?: readonly ['text', ...RichTextNodeType[]];
|
|
266
|
+
}
|
|
267
|
+
interface UnconstrainedRichTextFieldSchema extends AbstractFieldSchema {
|
|
268
|
+
semantic?: never;
|
|
269
|
+
type: typeof FieldValueTypes.RICH_TEXT;
|
|
270
|
+
supportedRichTextNodes?: readonly ['text', ...RichTextNodeType[]];
|
|
271
|
+
}
|
|
272
|
+
export type RichTextFieldSchema = DescriptionRichTextFieldSchema | UnconstrainedRichTextFieldSchema;
|
|
247
273
|
/**
|
|
248
274
|
* A FieldSchema describes the shape of a field.
|
|
249
275
|
*/
|
|
250
|
-
export type FieldSchema = BasicFieldSchema | BlobFieldSchema | ReferenceFieldSchema | ObjectFieldSchema | DateRangeFieldSchema | DatetimeRangeFieldSchema;
|
|
276
|
+
export type FieldSchema = BasicFieldSchema | BlobFieldSchema | ReferenceFieldSchema | ObjectFieldSchema | DateRangeFieldSchema | DatetimeRangeFieldSchema | RichTextFieldSchema;
|
|
251
277
|
/**
|
|
252
278
|
* A FieldValueType determines the type of an item's value.
|
|
253
279
|
* The type represents a unique scalar value such as a string or an integer.
|