alinea 0.8.3 → 0.9.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.
Files changed (122) hide show
  1. package/dist/alinea.d.ts +5 -1
  2. package/dist/backend/Database.d.ts +1 -1
  3. package/dist/backend/Database.js +56 -25
  4. package/dist/backend/test/Example.d.ts +23 -29
  5. package/dist/backend/test/Example.js +157 -146
  6. package/dist/chunks/{chunk-PGE747U6.js → chunk-ZOF2XAUZ.js} +3 -3
  7. package/dist/cli/Serve.js +1 -1
  8. package/dist/cli/Upgrade.d.ts +1 -0
  9. package/dist/cli/Upgrade.js +8 -0
  10. package/dist/cli/bin.js +2 -2
  11. package/dist/cli/generate/FillCache.d.ts +1 -1
  12. package/dist/cli/generate/FillCache.js +2 -2
  13. package/dist/cli/generate/GenerateDashboard.js +1 -1
  14. package/dist/cloud/server/CloudAuthServer.js +1 -1
  15. package/dist/core/Config.d.ts +1 -0
  16. package/dist/core/Config.js +22 -2
  17. package/dist/core/Document.js +2 -2
  18. package/dist/core/Edit.d.ts +2 -3
  19. package/dist/core/EntryRecord.d.ts +39 -22
  20. package/dist/core/EntryRecord.js +46 -33
  21. package/dist/core/Field.d.ts +17 -17
  22. package/dist/core/Infer.d.ts +19 -8
  23. package/dist/core/Picker.d.ts +3 -3
  24. package/dist/core/Reference.d.ts +6 -3
  25. package/dist/core/Reference.js +11 -0
  26. package/dist/core/Root.d.ts +2 -0
  27. package/dist/core/Root.js +12 -0
  28. package/dist/core/Schema.d.ts +1 -0
  29. package/dist/core/Schema.js +24 -0
  30. package/dist/core/Section.d.ts +1 -1
  31. package/dist/core/Shape.d.ts +1 -0
  32. package/dist/core/TextDoc.d.ts +49 -20
  33. package/dist/core/TextDoc.js +39 -6
  34. package/dist/core/Tracker.d.ts +2 -2
  35. package/dist/core/Transaction.d.ts +2 -1
  36. package/dist/core/Type.d.ts +7 -2
  37. package/dist/core/Type.js +21 -0
  38. package/dist/core/Workspace.d.ts +6 -5
  39. package/dist/core/Workspace.js +13 -0
  40. package/dist/core/field/ListField.d.ts +10 -10
  41. package/dist/core/field/ListField.js +5 -5
  42. package/dist/core/field/RecordField.d.ts +2 -2
  43. package/dist/core/field/RichTextField.d.ts +2 -2
  44. package/dist/core/field/RichTextField.js +13 -13
  45. package/dist/core/field/ScalarField.d.ts +2 -2
  46. package/dist/core/field/UnionField.d.ts +2 -2
  47. package/dist/core/media/MediaTypes.browser.js +1 -1
  48. package/dist/core/media/MediaTypes.js +1 -1
  49. package/dist/core/pages/Cursor.d.ts +2 -0
  50. package/dist/core/pages/Cursor.js +14 -0
  51. package/dist/core/shape/ListShape.d.ts +30 -24
  52. package/dist/core/shape/ListShape.js +69 -44
  53. package/dist/core/shape/RecordShape.d.ts +4 -3
  54. package/dist/core/shape/RecordShape.js +28 -16
  55. package/dist/core/shape/RichTextShape.d.ts +8 -6
  56. package/dist/core/shape/RichTextShape.js +195 -103
  57. package/dist/core/shape/ScalarShape.d.ts +1 -0
  58. package/dist/core/shape/ScalarShape.js +3 -0
  59. package/dist/core/shape/UnionShape.d.ts +7 -2
  60. package/dist/core/shape/UnionShape.js +39 -14
  61. package/dist/core/util/Identifiers.d.ts +1 -0
  62. package/dist/core/util/Identifiers.js +10 -0
  63. package/dist/core/util/Types.d.ts +1 -0
  64. package/dist/dashboard/atoms/EntryAtoms.js +1 -1
  65. package/dist/dashboard/atoms/FormAtoms.d.ts +5 -5
  66. package/dist/dashboard/editor/UseField.d.ts +7 -7
  67. package/dist/dashboard/util/PersistentStore.js +1 -1
  68. package/dist/dashboard/view/EntryEdit.js +1 -1
  69. package/dist/dashboard/view/diff/DiffUtils.js +1 -1
  70. package/dist/dashboard/view/diff/ListDiff.js +3 -2
  71. package/dist/dashboard/view/diff/RichTextDiff.d.ts +1 -1
  72. package/dist/dashboard/view/diff/RichTextDiff.js +16 -22
  73. package/dist/dashboard/view/entry/EntryTitle.js +2 -11
  74. package/dist/dashboard/view/entry/NewEntry.js +26 -19
  75. package/dist/dashboard/view/explorer/ExplorerItem.js +1 -1
  76. package/dist/field/link/EntryLink.d.ts +39 -0
  77. package/dist/field/link/EntryLink.js +62 -0
  78. package/dist/field/link/FileLink.d.ts +32 -0
  79. package/dist/field/link/FileLink.js +57 -0
  80. package/dist/field/link/ImageLink.d.ts +52 -0
  81. package/dist/field/link/ImageLink.js +61 -0
  82. package/dist/field/link/Link.d.ts +27 -0
  83. package/dist/field/link/Link.js +62 -0
  84. package/dist/field/link/LinkField.browser.js +34 -34
  85. package/dist/field/link/LinkField.d.ts +5 -6
  86. package/dist/field/link/LinkField.js +4 -2
  87. package/dist/field/link/UrlLink.d.ts +27 -0
  88. package/dist/field/link/UrlLink.js +26 -0
  89. package/dist/field/link.d.ts +5 -1
  90. package/dist/field/link.js +5 -1
  91. package/dist/field/list/ListField.browser.d.ts +2 -2
  92. package/dist/field/list/ListField.browser.js +13 -12
  93. package/dist/field/list/ListField.d.ts +4 -8
  94. package/dist/field/metadata/MetadataField.d.ts +2 -3
  95. package/dist/field/metadata/MetadataField.js +11 -9
  96. package/dist/field/richtext/PickTextLink.js +3 -2
  97. package/dist/field/richtext/ReferenceLink.d.ts +1 -1
  98. package/dist/field/richtext/ReferenceLink.js +26 -23
  99. package/dist/field/richtext/RichTextField.browser.js +40 -15
  100. package/dist/field/richtext/RichTextToolbar.js +2 -2
  101. package/dist/field/richtext/extensions/Link.d.ts +1 -1
  102. package/dist/field/richtext/extensions/Link.js +1 -1
  103. package/dist/field/select/SelectField.js +2 -1
  104. package/dist/field/tabs/Tabs.browser.js +2 -2
  105. package/dist/field.d.ts +5 -6
  106. package/dist/field.js +5 -6
  107. package/dist/picker/entry/EntryPicker.browser.js +5 -4
  108. package/dist/picker/entry/EntryPicker.d.ts +2 -30
  109. package/dist/picker/entry/EntryPicker.js +20 -37
  110. package/dist/picker/entry/EntryPickerRow.js +2 -1
  111. package/dist/picker/entry/EntryReference.d.ts +4 -37
  112. package/dist/picker/entry/EntryReference.js +3 -18
  113. package/dist/picker/url/UrlPicker.browser.js +8 -8
  114. package/dist/picker/url/UrlPicker.d.ts +8 -5
  115. package/dist/picker/url/UrlPicker.js +30 -9
  116. package/dist/picker/url/UrlPickerRow.js +2 -2
  117. package/dist/types.d.ts +6 -1
  118. package/dist/ui/RichText.js +48 -36
  119. package/package.json +3 -3
  120. package/dist/field/link/LinkConstructors.d.ts +0 -77
  121. package/dist/field/link/LinkConstructors.js +0 -204
  122. /package/dist/field/link/{LinkInput.stories.d.ts → LinkField.stories.d.ts} +0 -0
package/dist/alinea.d.ts CHANGED
@@ -14,7 +14,11 @@ export type { Schema } from 'alinea/core/Schema';
14
14
  export type { TextDoc } from 'alinea/core/TextDoc';
15
15
  export type { Type } from 'alinea/core/Type';
16
16
  export { Workspace } from 'alinea/core/Workspace';
17
- export type { EntryReference, FileReference, ImageReference } from 'alinea/picker/entry/EntryReference';
17
+ export type { EntryLink } from 'alinea/field/link/EntryLink';
18
+ export type { FileLink } from 'alinea/field/link/FileLink';
19
+ export type { ImageLink } from 'alinea/field/link/ImageLink';
20
+ export type { UrlLink } from 'alinea/field/link/UrlLink';
21
+ export type { EntryReference } from 'alinea/picker/entry/EntryReference';
18
22
  export type { UrlReference } from 'alinea/picker/url';
19
23
  export { document } from 'alinea/core/Document';
20
24
  export type { Infer as infer } from 'alinea/core/Infer';
@@ -47,6 +47,6 @@ export declare class Database implements Syncable {
47
47
  filePath: string;
48
48
  }, seed?: Seed): Omit<EntryRow, 'rowHash' | 'fileHash'>;
49
49
  seedData(): Map<string, Seed>;
50
- fill(source: Source, commitHash: string, target?: Target): Promise<void>;
50
+ fill(source: Source, commitHash: string, target?: Target, fix?: boolean): Promise<void>;
51
51
  }
52
52
  export {};
@@ -12,7 +12,7 @@ import {
12
12
  import "../chunks/chunk-U5RRZUYZ.js";
13
13
 
14
14
  // src/backend/Database.ts
15
- import { EntryRecord, META_KEY, createRecord } from "alinea/core/EntryRecord";
15
+ import { createRecord, parseRecord } from "alinea/core/EntryRecord";
16
16
  import { createId } from "alinea/core/Id";
17
17
  import { MutationType } from "alinea/core/Mutation";
18
18
  import { PageSeed } from "alinea/core/Page";
@@ -409,8 +409,8 @@ ${JSON.stringify(mutation)}`
409
409
  }
410
410
  }
411
411
  computeEntry(record, meta, seed) {
412
- const { [META_KEY]: alineaMeta, ...data } = record;
413
- const typeName = alineaMeta.type;
412
+ const { meta: recordMeta, data } = parseRecord(record);
413
+ const typeName = recordMeta.type;
414
414
  const parentDir = paths.dirname(meta.filePath);
415
415
  const extension = paths.extname(meta.filePath);
416
416
  const fileName = paths.basename(meta.filePath, extension);
@@ -431,7 +431,7 @@ ${JSON.stringify(mutation)}`
431
431
  `Type mismatch between seed and file: "${seed.type}" !== "${typeName}"`
432
432
  );
433
433
  const childrenDir = paths.join(parentDir, entryPath);
434
- if (!record[META_KEY].entryId)
434
+ if (!recordMeta.entryId)
435
435
  throw new Error(`missing id`);
436
436
  const urlMeta = {
437
437
  locale,
@@ -442,12 +442,12 @@ ${JSON.stringify(mutation)}`
442
442
  const pathData = entryPath === "index" ? "" : entryPath;
443
443
  const seedData = seed ? PageSeed.data(seed.page).partial : {};
444
444
  const title = record.title ?? seedData?.title ?? "";
445
- const entryData = {
445
+ const entryData = Type.toV1(type, {
446
446
  ...seedData,
447
447
  ...data,
448
448
  title,
449
449
  path: pathData
450
- };
450
+ });
451
451
  const searchableText = Type.searchableText(type, entryData);
452
452
  return {
453
453
  workspace: meta.workspace,
@@ -458,16 +458,16 @@ ${JSON.stringify(mutation)}`
458
458
  // file.modifiedAt,
459
459
  active: false,
460
460
  main: false,
461
- entryId: alineaMeta.entryId,
461
+ entryId: recordMeta.entryId,
462
462
  phase: entryPhase,
463
- type: alineaMeta.type,
463
+ type: recordMeta.type,
464
464
  parentDir,
465
465
  childrenDir,
466
466
  parent: null,
467
467
  level: parentDir === "/" ? 0 : segments.length,
468
- index: alineaMeta.index,
468
+ index: recordMeta.index,
469
469
  locale,
470
- i18nId: alineaMeta.i18nId ?? alineaMeta.entryId,
470
+ i18nId: recordMeta.i18nId ?? recordMeta.entryId,
471
471
  path: entryPath,
472
472
  title,
473
473
  url: entryUrl(type, urlMeta),
@@ -513,7 +513,9 @@ ${JSON.stringify(mutation)}`
513
513
  }
514
514
  return res;
515
515
  }
516
- async fill(source, commitHash, target) {
516
+ async fill(source, commitHash, target, fix = false) {
517
+ if (fix && !target)
518
+ throw new TypeError(`Target expected if fix is true`);
517
519
  await this.init();
518
520
  const typeNames = Schema.typeNames(this.config.schema);
519
521
  const publishSeed = [];
@@ -521,6 +523,7 @@ ${JSON.stringify(mutation)}`
521
523
  const seenVersions = [];
522
524
  const seenSeeds = /* @__PURE__ */ new Set();
523
525
  const inserted = [];
526
+ const changes = [];
524
527
  for await (const file of source.entries()) {
525
528
  const fileHash = await createFileHash(file.contents);
526
529
  const exists2 = await query(
@@ -534,7 +537,7 @@ ${JSON.stringify(mutation)}`
534
537
  seeded: EntryRow.seeded
535
538
  }).maybeFirst()
536
539
  );
537
- if (exists2) {
540
+ if (!fix && exists2) {
538
541
  seenVersions.push(exists2.versionId);
539
542
  const key = seedKey(
540
543
  file.workspace,
@@ -546,20 +549,42 @@ ${JSON.stringify(mutation)}`
546
549
  }
547
550
  try {
548
551
  const raw = JsonLoader.parse(this.config.schema, file.contents);
549
- const record = EntryRecord(raw);
550
- const seeded = record[META_KEY]?.seeded;
552
+ const { meta, data } = parseRecord(raw);
553
+ const seeded = meta.seeded;
551
554
  const key = seedKey(
552
555
  file.workspace,
553
556
  file.root,
554
557
  typeof seeded === "string" ? seeded : file.filePath
555
558
  );
556
559
  const seed = this.seed.get(key);
560
+ const record = createRecord({ ...meta, data });
557
561
  const entry = this.computeEntry(record, file, seed);
558
- seenSeeds.add(key);
562
+ const withHash = { ...entry, fileHash, rowHash: "" };
563
+ if (fix) {
564
+ const fileContents = JsonLoader.format(this.config.schema, record);
565
+ const newHash = await createFileHash(fileContents);
566
+ if (fileHash !== newHash) {
567
+ const workspace = this.config.workspaces[entry.workspace];
568
+ const file2 = paths.join(
569
+ Workspace.data(workspace).source,
570
+ entry.root,
571
+ entry.filePath
572
+ );
573
+ const record2 = createRecord(entry);
574
+ const contents = new TextDecoder().decode(
575
+ JsonLoader.format(this.config.schema, record2)
576
+ );
577
+ changes.push({
578
+ type: ChangeType.Write,
579
+ file: file2,
580
+ contents
581
+ });
582
+ }
583
+ }
559
584
  await query(
560
585
  EntryRow({ entryId: entry.entryId, phase: entry.phase }).delete()
561
586
  );
562
- const withHash = { ...entry, fileHash, rowHash: "" };
587
+ seenSeeds.add(key);
563
588
  seenVersions.push(
564
589
  await query(
565
590
  EntryRow().insert(withHash).returning(EntryRow.versionId)
@@ -568,8 +593,15 @@ ${JSON.stringify(mutation)}`
568
593
  inserted.push(`${entry.entryId}.${entry.phase}`);
569
594
  } catch (e2) {
570
595
  console.log(`> skipped ${file.filePath} \u2014 ${e2.message}`);
596
+ console.error(e2);
597
+ process.exit(1);
571
598
  }
572
599
  }
600
+ if (fix && changes.length > 0)
601
+ await target.mutate(
602
+ { commitHash: "", mutations: [{ changes, meta: void 0 }] },
603
+ { logger: new Logger("seed") }
604
+ );
573
605
  const stableI18nIds = /* @__PURE__ */ new Map();
574
606
  for (const seed of this.seed.values()) {
575
607
  const key = seedKey(seed.workspace, seed.root, seed.filePath);
@@ -589,16 +621,15 @@ ${JSON.stringify(mutation)}`
589
621
  stableI18nIds.set(path, i18nId);
590
622
  }
591
623
  const entry = this.computeEntry(
592
- {
624
+ createRecord({
625
+ entryId: createId(),
626
+ i18nId,
627
+ type: typeName,
628
+ index: "a0",
629
+ seeded: seed.filePath,
593
630
  title: partial.title ?? "",
594
- [META_KEY]: {
595
- entryId: createId(),
596
- i18nId,
597
- type: typeName,
598
- index: "a0",
599
- seeded: seed.filePath
600
- }
601
- },
631
+ data: partial
632
+ }),
602
633
  seed,
603
634
  seed
604
635
  );
@@ -13,48 +13,42 @@ export declare function createExample(): {
13
13
  check: import("../../field/check").CheckField;
14
14
  date: import("../../field/date").DateField;
15
15
  code: import("../../field/code").CodeField;
16
- externalLink: import("../../field/link/LinkField").LinkField<import("../..").UrlReference & {}>;
17
- entry: import("../../field/link/LinkField").LinkField<import("../..").EntryReference & {}>;
18
- entryWithCondition: import("../../field/link/LinkField").LinkField<import("../..").EntryReference & {}>;
19
- linkMultiple: import("../../field/link/LinkField").LinksField<(import("../..").EntryReference & {} & import("../../core/shape/ListShape").ListRow) | (import("../..").UrlReference & {} & import("../../core/shape/ListShape").ListRow)>;
20
- image: import("../../field/link/LinkField").LinkField<import("../..").ImageReference & {}>;
21
- images: import("../../field/link/LinkField").LinksField<import("../..").ImageReference & {} & import("../../core/shape/ListShape").ListRow>;
22
- file: import("../../field/link/LinkField").LinkField<import("../..").EntryReference & {}>;
23
- withFields: import("../../field/link/LinkField").LinkField<(import("../..").EntryReference & {
16
+ externalLink: import("../../field/link/LinkField").LinkField<import("../..").UrlReference, import("../..").UrlLink<{}>>;
17
+ entry: import("../../field/link/LinkField").LinkField<import("../..").EntryReference, import("../..").EntryLink<undefined>>;
18
+ entryWithCondition: import("../../field/link/LinkField").LinkField<import("../..").EntryReference, import("../..").EntryLink<undefined>>;
19
+ linkMultiple: import("../../field/link/LinkField").LinksField<import("../../core/shape/ListShape").ListRow, import("../..").AnyLink<{}>>;
20
+ image: import("../../field/link").ImageField<undefined>;
21
+ images: import("../../field/link").ImagesField<undefined>;
22
+ file: import("../../field/link/LinkField").LinkField<import("../..").EntryReference, import("../..").EntryLink<undefined>>;
23
+ withFields: import("../../field/link/LinkField").LinkField<import("../../core/Reference").Reference, import("../..").AnyLink<{
24
24
  fieldA: string;
25
25
  fieldB: string;
26
- }) | (import("../..").UrlReference & {
27
- fieldA: string;
28
- fieldB: string;
29
- }) | (import("../..").FileReference & {
30
- fieldA: string;
31
- fieldB: string;
32
- })>;
33
- multipleWithFields: import("../../field/link/LinkField").LinksField<(import("../..").EntryReference & {
34
- fieldA: string;
35
- fieldB: string;
36
- } & import("../../core/shape/ListShape").ListRow) | (import("../..").UrlReference & {
26
+ }>>;
27
+ multipleWithFields: import("../../field/link/LinkField").LinksField<import("../../core/shape/ListShape").ListRow, import("../..").AnyLink<{
37
28
  fieldA: string;
38
29
  fieldB: string;
39
- } & import("../../core/shape/ListShape").ListRow)>;
30
+ }>>;
40
31
  list: import("../../core").ListField<({
41
- id: string;
42
- type: "Text";
43
- index: string;
32
+ _type: "Text";
33
+ title: string;
34
+ text: import("../..").TextDoc<{}>;
35
+ } | {
36
+ _type: "Image";
37
+ image: import("../..").EntryReference;
38
+ }) & import("../../core/shape/ListShape").ListRow, ({
39
+ _type: "Text";
44
40
  title: string;
45
41
  text: import("../..").TextDoc<{}>;
46
42
  } | {
47
- id: string;
48
- type: "Image";
49
- index: string;
50
- image: import("../..").ImageReference & {};
51
- }) & import("../../field/list").ListRow, import("../../field/list").ListOptions<{
43
+ _type: "Image";
44
+ image: import("../..").ImageLink<undefined>;
45
+ }) & import("../../core/shape/ListShape").ListRow, import("../../field/list").ListOptions<{
52
46
  Text: import("alinea/core/Type").Type<{
53
47
  title: import("../../field/text").TextField;
54
48
  text: import("../../core").RichTextField<{}, import("../../field/richtext").RichTextOptions<{}>>;
55
49
  }>;
56
50
  Image: import("alinea/core/Type").Type<{
57
- image: import("../../field/link/LinkField").LinkField<import("../..").ImageReference & {}>;
51
+ image: import("../../field/link").ImageField<undefined>;
58
52
  }>;
59
53
  }>>;
60
54
  withInitial: import("../../core").RichTextField<{}, import("../../field/richtext").RichTextOptions<{}>>;
@@ -5,7 +5,6 @@ import { document } from "alinea/core/Document";
5
5
  import { Entry } from "alinea/core/Entry";
6
6
  import { page } from "alinea/core/Page";
7
7
  import { root } from "alinea/core/Root";
8
- import { schema } from "alinea/core/Schema";
9
8
  import { type } from "alinea/core/Type";
10
9
  import { workspace } from "alinea/core/Workspace";
11
10
  import { createTestCMS } from "alinea/core/driver/TestDriver";
@@ -31,171 +30,183 @@ import {
31
30
  } from "alinea/field";
32
31
  function createExample() {
33
32
  const Page = type("Type", {
34
- title: text("Title"),
35
- path: path("Path"),
36
- ...tabs(
37
- tab("Tab 1", {
38
- fields: {
39
- name: path("Name")
40
- }
41
- }),
42
- tab("Tab 2", {
43
- fields: {
44
- name: text("Name"),
45
- name2: text("Name")
46
- }
47
- })
48
- ),
49
- [type.meta]: {
50
- isContainer: true
33
+ isContainer: true,
34
+ fields: {
35
+ title: text("Title"),
36
+ path: path("Path"),
37
+ ...tabs(
38
+ tab("Tab 1", {
39
+ fields: {
40
+ name: path("Name")
41
+ }
42
+ }),
43
+ tab("Tab 2", {
44
+ fields: {
45
+ name: text("Name"),
46
+ name2: text("Name")
47
+ }
48
+ })
49
+ )
51
50
  }
52
51
  });
53
52
  const Container = type("TypeB", {
54
- title: text("Title"),
55
- path: path("Path"),
56
- name: text("name"),
57
- [type.meta]: {
58
- isContainer: true
53
+ isContainer: true,
54
+ fields: {
55
+ title: text("Title"),
56
+ path: path("Path"),
57
+ name: text("name")
59
58
  }
60
59
  });
61
60
  const Fields = document("Fields", {
62
- text: text("Text field"),
63
- hello: text("Validated text field", {
64
- help: 'This field only accepts "hello"',
65
- validate: (value) => {
66
- if (value !== "hello") {
67
- return 'Only "hello" is allowed';
61
+ fields: {
62
+ text: text("Text field"),
63
+ hello: text("Validated text field", {
64
+ help: 'This field only accepts "hello"',
65
+ validate: (value) => {
66
+ if (value !== "hello") {
67
+ return 'Only "hello" is allowed';
68
+ }
68
69
  }
69
- }
70
- }),
71
- richText: richText("Rich text field"),
72
- select: select("Select field", {
73
- options: {
74
- a: "Option a",
75
- b: "Option b"
76
- }
77
- }),
78
- number: number("Number field", {
79
- minValue: 0,
80
- maxValue: 10
81
- }),
82
- check: check("Check field", { description: "Check me please" }),
83
- date: date("Date field"),
84
- code: code("Code field"),
85
- externalLink: url("External link"),
86
- entry: entry("Internal link"),
87
- entryWithCondition: entry("With condition", {
88
- help: `Show only entries of type Fields`,
89
- condition: Entry.type.is("Fields")
90
- }),
91
- linkMultiple: link.multiple("Mixed links, multiple"),
92
- image: image("Image link"),
93
- images: image.multiple("Image link (multiple)"),
94
- file: entry("File link"),
95
- withFields: link("With extra fields", {
96
- fields: type({
97
- fieldA: text("Field A", { width: 0.5 }),
98
- fieldB: text("Field B", { width: 0.5 })
99
- })
100
- }),
101
- multipleWithFields: link.multiple("Multiple With extra fields", {
102
- fields: type({
70
+ }),
71
+ richText: richText("Rich text field"),
72
+ select: select("Select field", {
73
+ options: {
74
+ a: "Option a",
75
+ b: "Option b"
76
+ }
77
+ }),
78
+ number: number("Number field", {
79
+ minValue: 0,
80
+ maxValue: 10
81
+ }),
82
+ check: check("Check field", { description: "Check me please" }),
83
+ date: date("Date field"),
84
+ code: code("Code field"),
85
+ externalLink: url("External link"),
86
+ entry: entry("Internal link"),
87
+ entryWithCondition: entry("With condition", {
88
+ help: `Show only entries of type Fields`,
89
+ condition: Entry.type.is("Fields")
90
+ }),
91
+ linkMultiple: link.multiple("Mixed links, multiple"),
92
+ image: image("Image link"),
93
+ images: image.multiple("Image link (multiple)"),
94
+ file: entry("File link"),
95
+ withFields: link("With extra fields", {
96
+ fields: {
97
+ fieldA: text("Field A", { width: 0.5 }),
98
+ fieldB: text("Field B", { width: 0.5 })
99
+ }
100
+ }),
101
+ multipleWithFields: link.multiple("Multiple With extra fields", {
103
102
  fields: {
104
103
  fieldA: text("Field A", { width: 0.5 }),
105
104
  fieldB: text("Field B", { width: 0.5, required: true })
106
105
  }
107
- })
108
- }),
109
- list: list("My list field", {
110
- schema: schema({
111
- Text: type("Text", {
112
- title: text("Item title"),
113
- text: richText("Item body text")
114
- }),
115
- Image: type("Image", {
116
- image: image("Image")
117
- })
118
- })
119
- }),
120
- withInitial: richText("With initial value", {
121
- required: true,
122
- initialValue: [
123
- {
124
- type: "paragraph",
125
- content: [
126
- { type: "text", text: "This is a paragraph with initial value" }
127
- ]
106
+ }),
107
+ list: list("My list field", {
108
+ schema: {
109
+ Text: type("Text", {
110
+ fields: {
111
+ title: text("Item title"),
112
+ text: richText("Item body text")
113
+ }
114
+ }),
115
+ Image: type("Image", {
116
+ fields: {
117
+ image: image("Image")
118
+ }
119
+ })
128
120
  }
129
- ]
130
- }),
131
- nested: richText("With nested blocks", {
132
- schema: {
133
- Inner: type("Inner", {
134
- checkbox1: check("Checkbox 1"),
135
- checkbox2: check("Checkbox 2"),
136
- title: text("Title"),
137
- content: richText("Inner rich text")
138
- }),
139
- NestLayout: type("Nested layout fields", {
140
- object: object("Object field", {
141
- fields: type("Fields", {
142
- fieldA: text("Field A", { width: 0.5 }),
143
- fieldB: text("Field B", { width: 0.5 })
144
- })
121
+ }),
122
+ withInitial: richText("With initial value", {
123
+ required: true,
124
+ initialValue: [
125
+ {
126
+ _type: "paragraph",
127
+ content: [
128
+ { _type: "text", text: "This is a paragraph with initial value" }
129
+ ]
130
+ }
131
+ ]
132
+ }),
133
+ nested: richText("With nested blocks", {
134
+ schema: {
135
+ Inner: type("Inner", {
136
+ fields: {
137
+ checkbox1: check("Checkbox 1"),
138
+ checkbox2: check("Checkbox 2"),
139
+ title: text("Title"),
140
+ content: richText("Inner rich text")
141
+ }
145
142
  }),
146
- ...tabs(
147
- tab("Tab A", {
148
- tabA: text("Tab A")
149
- }),
150
- tab("Tab B", {
151
- tabB: text("Tab B")
152
- })
153
- )
154
- })
155
- }
156
- })
143
+ NestLayout: type("Nested layout fields", {
144
+ fields: {
145
+ object: object("Object field", {
146
+ fields: {
147
+ fieldA: text("Field A", { width: 0.5 }),
148
+ fieldB: text("Field B", { width: 0.5 })
149
+ }
150
+ }),
151
+ ...tabs(
152
+ tab("Tab A", {
153
+ fields: {
154
+ tabA: text("Tab A")
155
+ }
156
+ }),
157
+ tab("Tab B", {
158
+ fields: {
159
+ tabB: text("Tab B")
160
+ }
161
+ })
162
+ )
163
+ }
164
+ })
165
+ }
166
+ })
167
+ }
157
168
  });
158
169
  const main = workspace("Main", {
159
- pages: root("Pages", {
160
- entry1: page(Page({ title: "Test title" })),
161
- entry2: page(Container({ title: "Entry 2" }), {
162
- entry3: page(Page({ title: "Entry 3" }))
163
- }),
164
- [root.meta]: {
165
- contains: ["Page", "Container"]
166
- }
167
- }),
168
- multiLanguage: root("Multi language", {
169
- localised1: page(Page({ title: "Test title" })),
170
- localised2: page(Container({ title: "Entry 2" }), {
171
- localised3: page(Page({ title: "Entry 3" }))
170
+ source: ".",
171
+ roots: {
172
+ pages: root("Pages", {
173
+ contains: ["Page", "Container"],
174
+ entries: {
175
+ entry1: page(Page({ title: "Test title" })),
176
+ entry2: page(Container({ title: "Entry 2" }), {
177
+ entry3: page(Page({ title: "Entry 3" }))
178
+ })
179
+ }
172
180
  }),
173
- [root.meta]: {
181
+ multiLanguage: root("Multi language", {
174
182
  contains: ["Page", "Container"],
175
183
  i18n: {
176
184
  locales: ["en", "fr"]
185
+ },
186
+ entries: {
187
+ localised1: page(Page({ title: "Test title" })),
188
+ localised2: page(Container({ title: "Entry 2" }), {
189
+ localised3: page(Page({ title: "Entry 3" }))
190
+ })
177
191
  }
178
- }
179
- }),
180
- media: createMediaRoot({
181
- dir: page(MediaLibrary({ title: "Media folder" })),
182
- "file1.png": page(
183
- MediaFile({
184
- title: "File 1",
185
- path: "file1.png",
186
- extension: ".png",
187
- size: 1e3,
188
- width: 120,
189
- height: 120,
190
- hash: "hash1",
191
- preview: `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAIAAAC2BqGFAAAACXBIWXMAAAsTAAALEwEAmpwYAAAHIklEQVR4nO2bz2sTTxTAZ2aTLCYhaWstUlqlHlSwVm0UlaKCPxAhFg9FD3qp1Iul5KoeelD6N0g9FKWK3qLSgqKCB1F6SNEmxYqChRyqptJaZVs3uzsehuTbb6Cb7SZ5E+37HMIWJtO3n32ZnXm7QznnBKk8THYAawUUDQSKBgJFA4GigUDRQKBoIFA0ECgaCBQNBIoGAkUDgaKBQNFAoGggUDQQKBoIFA0EigYCRQOBooFA0UCgaCBQNBAoGggUDQSKBgJFA4GigUDRQKBoIFA0ECgaCBQNBIoGAkUDgaKB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.5, y: 0.5 }
194
- })
195
- )
196
- }),
197
- [workspace.meta]: {
198
- source: "."
192
+ }),
193
+ media: createMediaRoot({
194
+ dir: page(MediaLibrary({ title: "Media folder" })),
195
+ "file1.png": page(
196
+ MediaFile({
197
+ title: "File 1",
198
+ path: "file1.png",
199
+ extension: ".png",
200
+ size: 1e3,
201
+ width: 120,
202
+ height: 120,
203
+ hash: "hash1",
204
+ preview: `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAIAAAC2BqGFAAAACXBIWXMAAAsTAAALEwEAmpwYAAAHIklEQVR4nO2bz2sTTxTAZ2aTLCYhaWstUlqlHlSwVm0UlaKCPxAhFg9FD3qp1Iul5KoeelD6N0g9FKWK3qLSgqKCB1F6SNEmxYqChRyqptJaZVs3uzsehuTbb6Cb7SZ5E+37HMIWJtO3n32ZnXm7QznnBKk8THYAawUUDQSKBgJFA4GigUDRQKBoIFA0ECgaCBQNBIoGAkUDgaKBQNFAoGggUDQQKBoIFA0EigYCRQOBooFA0UCgaCBQNBAoGggUDQSKBgJFA4GigUDRQKBoIFA0ECgaCBQNBIoGAkUDgaKB8MgOoBDLsiilnHPxSQjRdX12dnZubk7XdcaY3+/fsGFDTU0NpZQQIlqKA0IIpVT8uVLnnHPGmE2bClF1ovO+0un0o0ePnj9/Pj4+vrCwsLi4aJomIcTn8/n9/sbGxoMHD54+ffrEiROKoiiKIr67sLCwtLS0UueWZRFCwuFwIBCAOqEcvGoQ6Waa5sePH/v6+urr60XqCfLHhBDxp6IoXq83EokMDw9ns1nDMLLZ7JUrV2pXpq6ubv369SMjI/BnVy2ihab5+flr164Fg0HnP21KqaIohw4dSqVSuq7HYrGiX4nH4/AnWC1DB2MskUhcunQpmUyKzOXOtvRyzimlr1+/Pnbs2J07dyodp3vgr20BpmlalvX48WMxVrg4BZH+jLFwONzR0VG0/RrNaM75w4cPz58/r+s6d7Uxnefun5qmvXnzptwBlgeZosWlfvXqVU9Pj7DsTnS+N9M0S+mhosgUb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DrCMiJNtJDV39+/d+/ev86aC6SJFq/sh0Kh4eHhpqYmxliJW0tEh+5e/AVAZljintbS0hKPxzdu3Fj6mFu1lkmVbH/btWvXkydPtm7d6vouJ65ZY2NjZ2dnBQIsA/JFixFjx44dL1++7OrqUlV1VSOAeG2MUtrW1vbixYtNmzZVNFrXyBct4JzX1dXdu3fv9u3b27Ztc35v5JyL18aePXvW3NxctaOH/K0VAnEzJIScPXv21KlT8Xj85s2biUQiv27Mr/2Wb4Lz+/1dXV2XL19ub28X16apqcmm7sE5VxQlHA6DnNP/kLAEtydvlnOuadrU1NTY2NinT5++fv2qaZqiKDU1Nc3Nza2trZFIRExXCkZ2myFeTMPzFxWSqhOdj2clX3zZ7uX8ZmYnXyzooWwRO6PqRP+rVOmt498DRQOBooFA0UCgaCBQNBAoGggUDQSKBgJFA4GigUDRQKBoIFA0ECgaCBQNBIoGAkUDgaKBQNFAoGggUDQQKBoIFA0EigYCRQOBooFA0UCgaCBQNBAoGggUDQSKBgJFA4GigUDRQKBoIP4AP2+to8vlbgYAAAAASUVORK5CYII=`,
205
+ averageColor: "#ffffff",
206
+ focus: { x: 0.5, y: 0.5 }
207
+ })
208
+ )
209
+ })
199
210
  }
200
211
  });
201
212
  return createTestCMS({
@@ -2,7 +2,7 @@
2
2
  var package_default = {
3
3
  bin: "./dist/cli.js",
4
4
  name: "alinea",
5
- version: "0.8.3",
5
+ version: "0.9.0",
6
6
  license: "MIT",
7
7
  type: "module",
8
8
  scripts: {
@@ -44,7 +44,7 @@ var package_default = {
44
44
  dependencies: {
45
45
  "@alinea/iso": "^0.3.2",
46
46
  "@alinea/sqlite-wasm": "^0.1.16",
47
- esbuild: "^0.19.12"
47
+ esbuild: "^0.20.1"
48
48
  },
49
49
  peerDependencies: {
50
50
  react: "*",
@@ -82,7 +82,7 @@ var package_default = {
82
82
  },
83
83
  packageManager: "yarn@4.1.0",
84
84
  resolutions: {
85
- esbuild: "0.19.12",
85
+ esbuild: "0.20.1",
86
86
  yjs: "13.6.11",
87
87
  lib0: "0.2.88"
88
88
  },