@tunasand/sdk 0.7.0 → 0.8.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 (187) hide show
  1. package/CHANGELOG.md +112 -88
  2. package/README.md +202 -198
  3. package/dist/analytics.js +638 -2
  4. package/dist/app.js +230 -24
  5. package/dist/apps-BxnJ1RlU.js +435 -0
  6. package/dist/{bridge-DYAYGV7t.js → bridge-DtHw9hS6.js} +3 -3
  7. package/dist/bridge.js +2 -2
  8. package/dist/cli.js +5 -4
  9. package/dist/{model-pmXzGX12.js → collection-BEOxeISR.js} +49 -12
  10. package/dist/{customers-C_vJY2_v.js → customers-DTbL0qn6.js} +5 -3
  11. package/dist/customers.js +2 -2
  12. package/dist/{declared-C_GvPiGF.js → declared-DuNMsdXw.js} +93 -5
  13. package/dist/delivery.js +15 -30
  14. package/dist/embeds-B5V54Zur.js +34 -0
  15. package/dist/{errorLabels-CPKiPabZ.js → errorLabels-BgtQ_zUn.js} +276 -263
  16. package/dist/i18n.js +4 -4
  17. package/dist/ids--RF7hGyC.js +36 -0
  18. package/dist/integrations.js +4 -29
  19. package/dist/{ja-C1HEWWTQ.js → ja-CeHU0EaY.js} +3 -3
  20. package/dist/{ja-C6lX0CeJ.js → ja-Du6ooL6i.js} +12 -11
  21. package/dist/{page-E_cYgZx-.js → page-Bzrj24sJ.js} +4 -4
  22. package/dist/{profile-D6t1QMQh.js → profile-1em_lcxq.js} +5 -5
  23. package/dist/rich-text.d.ts +1 -0
  24. package/dist/{body.js → rich-text.js} +6 -7
  25. package/dist/{schema-UQJWRyfJ.js → schema-WnobuwLg.js} +136 -97
  26. package/dist/schema.js +346 -1
  27. package/dist/types/access/src/handoff.d.ts +3 -3
  28. package/dist/types/access/src/jwt.d.ts +1 -1
  29. package/dist/types/access/src/oidc.d.ts +1 -1
  30. package/dist/types/{cms-contract → contract}/src/apiKeys.d.ts +1 -1
  31. package/dist/types/{cms-contract → contract}/src/app.d.ts +8 -15
  32. package/dist/types/contract/src/appDefinition.d.ts +127 -0
  33. package/dist/types/{cms-contract → contract}/src/appDependencies.d.ts +6 -13
  34. package/dist/types/contract/src/appServer.d.ts +136 -0
  35. package/dist/types/contract/src/approvalLabels.d.ts +26 -0
  36. package/dist/types/contract/src/approvals.d.ts +63 -0
  37. package/dist/types/{cms-contract → contract}/src/apps.d.ts +72 -29
  38. package/dist/types/contract/src/auditActions.d.ts +18 -0
  39. package/dist/types/contract/src/auditLabels.d.ts +127 -0
  40. package/dist/types/{cms-contract → contract}/src/authorize.d.ts +22 -63
  41. package/dist/types/{cms-contract → contract}/src/bridge.d.ts +6 -6
  42. package/dist/types/{cms-contract → contract}/src/customers.d.ts +6 -6
  43. package/dist/types/{cms-contract → contract}/src/embeds.d.ts +13 -7
  44. package/dist/types/{cms-contract → contract}/src/errorLabels.d.ts +17 -15
  45. package/dist/types/{cms-contract → contract}/src/errorLabelsEn.d.ts +9 -7
  46. package/dist/types/{cms-contract → contract}/src/errors.d.ts +11 -11
  47. package/dist/types/{cms-contract → contract}/src/failureStatus.d.ts +4 -3
  48. package/dist/types/contract/src/fieldAccess.d.ts +45 -0
  49. package/dist/types/contract/src/fieldRules.d.ts +41 -0
  50. package/dist/types/{cms-contract/src/assets.d.ts → contract/src/files.d.ts} +5 -5
  51. package/dist/types/{cms-contract → contract}/src/functions.d.ts +3 -3
  52. package/dist/types/contract/src/hostingRpc.d.ts +143 -0
  53. package/dist/types/contract/src/hostnames.d.ts +30 -0
  54. package/dist/types/{cms-contract → contract}/src/identifiers.d.ts +31 -28
  55. package/dist/types/contract/src/ids.d.ts +104 -0
  56. package/dist/types/{cms-contract → contract}/src/import.d.ts +3 -3
  57. package/dist/types/contract/src/importLabels.d.ts +3 -0
  58. package/dist/types/contract/src/index.d.ts +67 -0
  59. package/dist/types/{cms-contract → contract}/src/issueLabels.d.ts +27 -23
  60. package/dist/types/{cms-contract → contract}/src/issueLabelsEn.d.ts +15 -13
  61. package/dist/types/contract/src/labels.d.ts +11 -0
  62. package/dist/types/contract/src/legacyAuditLabels.d.ts +10 -0
  63. package/dist/types/contract/src/livePeriods.d.ts +18 -0
  64. package/dist/types/contract/src/manage.d.ts +47 -0
  65. package/dist/types/contract/src/manageLabels.d.ts +9 -0
  66. package/dist/types/contract/src/mcpAuth.d.ts +139 -0
  67. package/dist/types/contract/src/mcpLabels.d.ts +5 -0
  68. package/dist/types/{cms-contract → contract}/src/migration.d.ts +1 -1
  69. package/dist/types/contract/src/operatorOperations.d.ts +703 -0
  70. package/dist/types/contract/src/operators.d.ts +33 -0
  71. package/dist/types/{cms-contract → contract}/src/paths.d.ts +6 -8
  72. package/dist/types/contract/src/pending.d.ts +4 -0
  73. package/dist/types/{cms-contract → contract}/src/permissions.d.ts +2 -0
  74. package/dist/types/contract/src/principal.d.ts +110 -0
  75. package/dist/types/{cms-contract → contract}/src/problems.d.ts +4 -4
  76. package/dist/types/contract/src/projectRole.d.ts +6 -0
  77. package/dist/types/{cms-contract → contract}/src/roles.d.ts +4 -3
  78. package/dist/types/{cms-contract → contract}/src/settingProblems.d.ts +2 -2
  79. package/dist/types/{cms-contract → contract}/src/settings.d.ts +2 -2
  80. package/dist/types/contract/src/settingsLabels.d.ts +3 -0
  81. package/dist/types/contract/src/slugs.d.ts +6 -0
  82. package/dist/types/{cms-contract → contract}/src/transfer.d.ts +3 -3
  83. package/dist/types/contract/src/trial.d.ts +10 -0
  84. package/dist/types/contract/src/versions.d.ts +9 -0
  85. package/dist/types/{cms-contract → contract}/src/webhooks.d.ts +33 -58
  86. package/dist/types/contract/src/workflow.d.ts +49 -0
  87. package/dist/types/contract/src/workspaceItems.d.ts +73 -0
  88. package/dist/types/contract/src/workspacePaths.d.ts +4 -0
  89. package/dist/types/{body → rich-text}/src/declared.d.ts +2 -2
  90. package/dist/types/{body → rich-text}/src/embed.d.ts +1 -1
  91. package/dist/types/{body → rich-text}/src/labels/ja.d.ts +2 -2
  92. package/dist/types/{body → rich-text}/src/profile.d.ts +1 -1
  93. package/dist/types/{model → schema}/src/audience.d.ts +11 -11
  94. package/dist/types/schema/src/brand.d.ts +5 -0
  95. package/dist/types/{model → schema}/src/capabilities.d.ts +5 -5
  96. package/dist/types/{model → schema}/src/changes.d.ts +6 -6
  97. package/dist/types/{model → schema}/src/check.d.ts +2 -2
  98. package/dist/types/{model/src/model.d.ts → schema/src/collection.d.ts} +25 -23
  99. package/dist/types/{platform/src/defaultModel.d.ts → schema/src/defaultSchema.d.ts} +4 -3
  100. package/dist/types/{model/src/asset.d.ts → schema/src/file.d.ts} +16 -16
  101. package/dist/types/{model → schema}/src/image.d.ts +3 -3
  102. package/dist/types/{model → schema}/src/index.d.ts +11 -10
  103. package/dist/types/{model → schema}/src/input.d.ts +3 -3
  104. package/dist/types/{model → schema}/src/integrity.d.ts +1 -1
  105. package/dist/types/{model → schema}/src/labels/en.d.ts +8 -7
  106. package/dist/types/{model → schema}/src/labels/ja.d.ts +9 -8
  107. package/dist/types/schema/src/legacy.d.ts +2 -0
  108. package/dist/types/{model → schema}/src/media.d.ts +1 -1
  109. package/dist/types/{model → schema}/src/mediaUrl.d.ts +5 -5
  110. package/dist/types/{model → schema}/src/page.d.ts +2 -2
  111. package/dist/types/{model → schema}/src/problems.d.ts +14 -13
  112. package/dist/types/{model → schema}/src/refs.d.ts +1 -1
  113. package/dist/types/{model → schema}/src/rules.d.ts +2 -2
  114. package/dist/types/{model → schema}/src/schema.d.ts +10 -10
  115. package/dist/types/{model → schema}/src/selfOps.d.ts +1 -1
  116. package/dist/types/schema/src/typesSource.d.ts +16 -0
  117. package/dist/types/{model → schema}/src/values.d.ts +2 -2
  118. package/dist/types/sdk/src/analytics.d.ts +2 -2
  119. package/dist/types/sdk/src/app.d.ts +44 -16
  120. package/dist/types/sdk/src/bridge.d.ts +12 -12
  121. package/dist/types/sdk/src/customers.d.ts +14 -20
  122. package/dist/types/sdk/src/delegation.d.ts +39 -0
  123. package/dist/types/sdk/src/delivery/client.d.ts +11 -10
  124. package/dist/types/sdk/src/delivery/fields.d.ts +2 -2
  125. package/dist/types/sdk/src/delivery/index.d.ts +1 -1
  126. package/dist/types/sdk/src/delivery/media.d.ts +6 -6
  127. package/dist/types/sdk/src/delivery/query.d.ts +1 -1
  128. package/dist/types/sdk/src/delivery/schema.d.ts +4 -4
  129. package/dist/types/sdk/src/delivery/values.d.ts +6 -6
  130. package/dist/types/sdk/src/delivery.d.ts +2 -2
  131. package/dist/types/sdk/src/i18n.d.ts +11 -11
  132. package/dist/types/sdk/src/integrations.d.ts +10 -10
  133. package/dist/types/sdk/src/{body.d.ts → rich-text.d.ts} +2 -2
  134. package/dist/types/sdk/src/schema.d.ts +5 -21
  135. package/dist/types/sdk/src/site.d.ts +1 -1
  136. package/dist/types/sdk/src/types.d.ts +21 -0
  137. package/dist/{schema-BPHL7Qr-.js → types-B77qvqPJ.js} +5 -4
  138. package/dist/types.d.ts +1 -0
  139. package/dist/types.js +1 -0
  140. package/dist/{typesSource-bO0jFw1I.js → typesSource-CWybQYus.js} +58 -12
  141. package/package.json +12 -12
  142. package/dist/apps-9u4XMi7E.js +0 -114
  143. package/dist/body.d.ts +0 -1
  144. package/dist/embed-R-OvDYAw.js +0 -90
  145. package/dist/model.d.ts +0 -1
  146. package/dist/model.js +0 -345
  147. package/dist/types/analytics/src/index.d.ts +0 -5
  148. package/dist/types/analytics/src/schedule.d.ts +0 -2
  149. package/dist/types/analytics/src/shared.d.ts +0 -21
  150. package/dist/types/analytics/src/source.d.ts +0 -19
  151. package/dist/types/analytics/src/store.d.ts +0 -24
  152. package/dist/types/cms-contract/src/urlLabel.d.ts +0 -13
  153. package/dist/types/model/src/brand.d.ts +0 -25
  154. package/dist/types/model/src/legacy.d.ts +0 -2
  155. package/dist/types/model/src/typesSource.d.ts +0 -8
  156. package/dist/types/sdk/src/model.d.ts +0 -5
  157. /package/dist/types/{cms-contract → contract}/src/appProblems.d.ts +0 -0
  158. /package/dist/types/{cms-contract → contract}/src/consents.d.ts +0 -0
  159. /package/dist/types/{cms-contract → contract}/src/customerLabels.d.ts +0 -0
  160. /package/dist/types/{analytics → contract}/src/day.d.ts +0 -0
  161. /package/dist/types/{cms-contract → contract}/src/functionLabels.d.ts +0 -0
  162. /package/dist/types/{cms-contract → contract}/src/permissionLabels.d.ts +0 -0
  163. /package/dist/types/{cms-contract → contract}/src/siteArtifact.d.ts +0 -0
  164. /package/dist/types/{cms-contract → contract}/src/siteDeclaration.d.ts +0 -0
  165. /package/dist/types/{analytics/src/view.d.ts → contract/src/viewEvent.d.ts} +0 -0
  166. /package/dist/types/{cms-contract → contract}/src/views.d.ts +0 -0
  167. /package/dist/types/{cms-contract → contract}/src/webhookLabels.d.ts +0 -0
  168. /package/dist/types/{body → rich-text}/src/components.d.ts +0 -0
  169. /package/dist/types/{body → rich-text}/src/derive.d.ts +0 -0
  170. /package/dist/types/{body → rich-text}/src/description.d.ts +0 -0
  171. /package/dist/types/{body → rich-text}/src/href.d.ts +0 -0
  172. /package/dist/types/{body → rich-text}/src/html.d.ts +0 -0
  173. /package/dist/types/{body → rich-text}/src/index.d.ts +0 -0
  174. /package/dist/types/{body → rich-text}/src/inline.d.ts +0 -0
  175. /package/dist/types/{body → rich-text}/src/labels/en.d.ts +0 -0
  176. /package/dist/types/{body → rich-text}/src/library.d.ts +0 -0
  177. /package/dist/types/{body → rich-text}/src/markdown.d.ts +0 -0
  178. /package/dist/types/{body → rich-text}/src/normalize.d.ts +0 -0
  179. /package/dist/types/{body → rich-text}/src/problems.d.ts +0 -0
  180. /package/dist/types/{body → rich-text}/src/render.d.ts +0 -0
  181. /package/dist/types/{body → rich-text}/src/schema.d.ts +0 -0
  182. /package/dist/types/{body → rich-text}/src/standard.d.ts +0 -0
  183. /package/dist/types/{body → rich-text}/src/types.d.ts +0 -0
  184. /package/dist/types/{model → schema}/src/contact.d.ts +0 -0
  185. /package/dist/types/{model → schema}/src/json.d.ts +0 -0
  186. /package/dist/types/{model → schema}/src/screens.d.ts +0 -0
  187. /package/dist/types/{model → schema}/src/time.d.ts +0 -0
@@ -1,13 +1,13 @@
1
- import { i as CORE_COMPONENTS, t as declaredComponentsSchema } from "./declared-C_GvPiGF.js";
2
- import { f as problemText, l as problemFactory } from "./ja-C1HEWWTQ.js";
3
- import { n as PRODUCT_FIELD_LABELS, t as MODEL_PROBLEM_MESSAGES } from "./ja-C6lX0CeJ.js";
4
- import { C as isSurveyShape, S as isSingleton, a as PII_CLASSES, c as acceptsRole, d as cascadeTargetsOf, i as ON_DELETE, l as audienceOf, m as declaredAudienceOf, n as CUSTOMER_FIELD_TYPE, o as SELF_OPS, r as FIELD_ROLES, s as SLUG_MODES, t as AUDIENCES, u as cascadeDepths, v as isListCollection, w as narrower, x as isSequenceField } from "./model-pmXzGX12.js";
1
+ import { i as CORE_COMPONENTS, t as declaredComponentsSchema } from "./declared-DuNMsdXw.js";
2
+ import { f as problemText, l as problemFactory } from "./ja-CeHU0EaY.js";
3
+ import { n as SCHEMA_PROBLEM_MESSAGES, t as PRODUCT_FIELD_LABELS } from "./ja-Du6ooL6i.js";
4
+ import { A as publishingOf, C as isSequenceField, D as narrower, E as isSurveyShape, a as PII_CLASSES, c as acceptsRole, d as cascadeTargetsOf, i as ON_DELETE, j as roleFieldOf, l as audienceOf, m as declaredAudienceOf, n as CUSTOMER_FIELD_TYPE, o as SELF_OPS, r as FIELD_ROLES, s as SLUG_MODES, t as AUDIENCES, u as cascadeDepths, w as isSingleton, y as isListCollection } from "./collection-BEOxeISR.js";
5
5
  import { z } from "zod";
6
- // ../model/src/problems.ts
6
+ // ../schema/src/problems.ts
7
7
  /** コンテンツスキーマの検査の問題を作る */
8
- const modelProblem = problemFactory(MODEL_PROBLEM_MESSAGES);
8
+ const schemaProblem = problemFactory(SCHEMA_PROBLEM_MESSAGES);
9
9
  /** 問題の英語の既定の文(zod の message と検査の issues の message に入れ、problemOf で戻す) */
10
- const modelProblemText = (code, ...params) => problemText(modelProblem(code, ...params));
10
+ const schemaProblemText = (code, ...params) => problemText(schemaProblem(code, ...params));
11
11
  const PHONE_REGION_IDS = Object.keys({
12
12
  JP: "81",
13
13
  KR: "82",
@@ -17,7 +17,7 @@ const PHONE_REGION_IDS = Object.keys({
17
17
  });
18
18
  /** URL の項目が受け付ける scheme */
19
19
  const URL_SCHEMES = ["https", "http"];
20
- // ../model/src/check.ts
20
+ // ../schema/src/check.ts
21
21
  /** 配列でないオブジェクトか */
22
22
  const isRecord$1 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
23
23
  /** 一意の組に含められる項目か(最上位・単数・入力する項目で、値を文字にできる種類) */
@@ -47,30 +47,30 @@ function integrityProblems(collection) {
47
47
  const id = collection.slug;
48
48
  const problems = [];
49
49
  const defs = uniqueDefsOf(collection);
50
- if (collection.unique?.length && !isListCollection(collection)) problems.push(modelProblemText("unique_list_only", { collection: id }));
50
+ if (collection.unique?.length && !isListCollection(collection)) problems.push(schemaProblemText("unique_list_only", { collection: id }));
51
51
  const names = defs.map((d) => d.key);
52
- for (const n of new Set(names)) if (names.filter((x) => x === n).length > 1) problems.push(modelProblemText("unique_name_duplicate", {
52
+ for (const n of new Set(names)) if (names.filter((x) => x === n).length > 1) problems.push(schemaProblemText("unique_name_duplicate", {
53
53
  collection: id,
54
54
  key: n
55
55
  }));
56
56
  for (const d of collection.unique ?? []) {
57
- if (!d.fields.length || d.fields.length > 3) problems.push(modelProblemText("unique_field_count", {
57
+ if (!d.fields.length || d.fields.length > 3) problems.push(schemaProblemText("unique_field_count", {
58
58
  collection: id,
59
59
  key: d.key,
60
60
  max: 3
61
61
  }));
62
- if (new Set(d.fields).size !== d.fields.length) problems.push(modelProblemText("unique_field_duplicate", {
62
+ if (new Set(d.fields).size !== d.fields.length) problems.push(schemaProblemText("unique_field_duplicate", {
63
63
  collection: id,
64
64
  key: d.key
65
65
  }));
66
66
  for (const key of d.fields) {
67
67
  const f = collection.fields.find((x) => x.key === key);
68
- if (!f) problems.push(modelProblemText("unique_field_not_top", {
68
+ if (!f) problems.push(schemaProblemText("unique_field_not_top", {
69
69
  collection: id,
70
70
  key: d.key,
71
71
  field: key
72
72
  }));
73
- else if (!acceptsUnique(f)) problems.push(modelProblemText("unique_field_unsupported", {
73
+ else if (!acceptsUnique(f)) problems.push(schemaProblemText("unique_field_unsupported", {
74
74
  collection: id,
75
75
  key: d.key,
76
76
  field: key,
@@ -78,18 +78,18 @@ function integrityProblems(collection) {
78
78
  }));
79
79
  }
80
80
  }
81
- const nested = (fields, path) => fields.flatMap((f) => [...isSequenceField(f) ? [modelProblemText("sequence_nested", {
81
+ const nested = (fields, path) => fields.flatMap((f) => [...isSequenceField(f) ? [schemaProblemText("sequence_nested", {
82
82
  collection: id,
83
83
  field: `${path}${f.key}`
84
84
  })] : [], ...f.type === "group" ? nested(f.fields, `${path}${f.key}.`) : []]);
85
85
  for (const f of collection.fields) {
86
86
  if (f.type === "group") problems.push(...nested(f.fields, `${f.key}.`));
87
87
  if (!isSequenceField(f)) continue;
88
- if (!isListCollection(collection)) problems.push(modelProblemText("sequence_list_only", {
88
+ if (!isListCollection(collection)) problems.push(schemaProblemText("sequence_list_only", {
89
89
  collection: id,
90
90
  field: f.key
91
91
  }));
92
- if (f.required || f.computed || f.when) problems.push(modelProblemText("sequence_plain", {
92
+ if (f.required || f.computed || f.when) problems.push(schemaProblemText("sequence_plain", {
93
93
  collection: id,
94
94
  field: f.key
95
95
  }));
@@ -99,7 +99,7 @@ function integrityProblems(collection) {
99
99
  /** 遷移の宣言の誤り(スキーマの検査) */
100
100
  function transitionProblems(collection) {
101
101
  const id = collection.slug;
102
- const nested = (fields, path) => fields.flatMap((f) => [...f.type === "select" && f.transitions ? [modelProblemText("transition_nested", {
102
+ const nested = (fields, path) => fields.flatMap((f) => [...f.type === "select" && f.transitions ? [schemaProblemText("transition_nested", {
103
103
  collection: id,
104
104
  field: `${path}${f.key}`
105
105
  })] : [], ...f.type === "group" ? nested(f.fields, `${path}${f.key}.`) : []]);
@@ -108,7 +108,7 @@ function transitionProblems(collection) {
108
108
  if (f.type !== "select" || !f.transitions) return [];
109
109
  const values = new Set(f.options.map((o) => o.value));
110
110
  const problems = [];
111
- if (f.multiple || f.derive || f.fixedBy) problems.push(modelProblemText("transition_field_kind", {
111
+ if (f.multiple || f.derive || f.fixedBy) problems.push(schemaProblemText("transition_field_kind", {
112
112
  collection: id,
113
113
  field: f.key
114
114
  }));
@@ -118,21 +118,21 @@ function transitionProblems(collection) {
118
118
  field: f.key,
119
119
  index: i + 1
120
120
  };
121
- if (!values.has(t.to)) problems.push(modelProblemText("transition_to_not_option", {
121
+ if (!values.has(t.to)) problems.push(schemaProblemText("transition_to_not_option", {
122
122
  ...at,
123
123
  to: t.to
124
124
  }));
125
- if (!t.from.length) problems.push(modelProblemText("transition_from_empty", at));
126
- for (const v of t.from) if (v !== null && !values.has(v)) problems.push(modelProblemText("transition_from_not_option", {
125
+ if (!t.from.length) problems.push(schemaProblemText("transition_from_empty", at));
126
+ for (const v of t.from) if (v !== null && !values.has(v)) problems.push(schemaProblemText("transition_from_not_option", {
127
127
  ...at,
128
128
  value: v
129
129
  }));
130
- if (!t.by.roles?.length && !t.by.self && !t.by.apps?.length) problems.push(modelProblemText("transition_no_actor", at));
130
+ if (!t.by.roles?.length && !t.by.self && !t.by.apps?.length) problems.push(schemaProblemText("transition_no_actor", at));
131
131
  }
132
132
  return problems;
133
133
  });
134
134
  }
135
- // ../model/src/selfOps.ts
135
+ // ../schema/src/selfOps.ts
136
136
  /** 本人の顧客フィールドか(コレクションの最上位の項目) */
137
137
  const isSelfField = (f, collection) => f.type === "customer" && (f.self === true || f.self === void 0 && declaredAudienceOf(f) === void 0 && isSurveyShape(collection));
138
138
  /** コレクションの本人の顧客フィールド */
@@ -140,7 +140,7 @@ const selfFieldsOf = (collection) => collection.fields.filter((f) => isSelfField
140
140
  /** 本人が書ける印を付けられない項目の理由(付けられれば null) */
141
141
  function selfWritableBlock(f, collection) {
142
142
  if (f.type === "customer") return "customer";
143
- if (f.type === "group" || f.type === "media" || f.type === "rich_text") return f.type;
143
+ if (f.type === "group" || f.type === "file" || f.type === "rich_text") return f.type;
144
144
  if (audienceOf(f, collection) === "staff") return "staff";
145
145
  if (f.adminOnly) return "admin_only";
146
146
  if (f.computed) return "computed";
@@ -153,16 +153,16 @@ function selfOpsProblems(collection) {
153
153
  const self = selfFieldsOf(collection);
154
154
  const at = { collection: collection.slug };
155
155
  const problems = [];
156
- if (collection.private !== true) problems.push(modelProblemText("self_ops_private_only", at));
157
- if (isSingleton(collection)) problems.push(modelProblemText("self_ops_list_only", at));
158
- if ((collection.publishing ?? "none") !== "none" || collection.fields.some((f) => f.key === "published" && f.type === "boolean")) problems.push(modelProblemText("self_ops_unpublished", at));
159
- if (self.length !== 1) problems.push(modelProblemText("self_ops_one_self", at));
156
+ if (collection.private !== true) problems.push(schemaProblemText("self_ops_private_only", at));
157
+ if (isSingleton(collection)) problems.push(schemaProblemText("self_ops_list_only", at));
158
+ if ((collection.publishing ?? "none") !== "none" || collection.fields.some((f) => f.key === "published" && f.type === "boolean")) problems.push(schemaProblemText("self_ops_unpublished", at));
159
+ if (self.length !== 1) problems.push(schemaProblemText("self_ops_one_self", at));
160
160
  const key = self.length === 1 ? self[0].key : null;
161
- if (key && self[0].onDelete !== "cascade" && self[0].onDelete !== "anonymize") problems.push(modelProblemText("self_ops_on_delete", {
161
+ if (key && self[0].onDelete !== "cascade" && self[0].onDelete !== "anonymize") problems.push(schemaProblemText("self_ops_on_delete", {
162
162
  ...at,
163
163
  field: key
164
164
  }));
165
- for (const d of uniqueDefsOf(collection)) if (key && !d.fields.includes(key)) problems.push(modelProblemText("self_ops_unique", {
165
+ for (const d of uniqueDefsOf(collection)) if (key && !d.fields.includes(key)) problems.push(schemaProblemText("self_ops_unique", {
166
166
  ...at,
167
167
  key: d.key,
168
168
  field: key
@@ -171,7 +171,7 @@ function selfOpsProblems(collection) {
171
171
  }
172
172
  /** 本人が書ける印の誤り(付けられない項目、まとまりの中、create_self か update_self を受けないコレクション) */
173
173
  function selfWritableProblems(collection) {
174
- const nested = (fields, path) => fields.flatMap((f) => [...f.selfWritable !== void 0 ? [modelProblemText("self_writable_nested", {
174
+ const nested = (fields, path) => fields.flatMap((f) => [...f.selfWritable !== void 0 ? [schemaProblemText("self_writable_nested", {
175
175
  collection: collection.slug,
176
176
  field: `${path}${f.key}`
177
177
  })] : [], ...f.type === "group" ? nested(f.fields, `${path}${f.key}.`) : []]);
@@ -181,12 +181,12 @@ function selfWritableProblems(collection) {
181
181
  if (!f.selfWritable) return inner;
182
182
  const block = selfWritableBlock(f, collection);
183
183
  return [
184
- ...block ? [modelProblemText("self_writable_blocked", {
184
+ ...block ? [schemaProblemText("self_writable_blocked", {
185
185
  collection: collection.slug,
186
186
  field: f.key,
187
187
  block
188
188
  })] : [],
189
- ...writes ? [] : [modelProblemText("self_writable_without_ops", {
189
+ ...writes ? [] : [schemaProblemText("self_writable_without_ops", {
190
190
  collection: collection.slug,
191
191
  field: f.key
192
192
  })],
@@ -194,14 +194,52 @@ function selfWritableProblems(collection) {
194
194
  ];
195
195
  });
196
196
  }
197
- // ../model/src/capabilities.ts
197
+ /** コレクションが本人の確認の方法 proof で受ける人の操作 */
198
+ function selfOpsOf(collection, proof) {
199
+ if (collection.selfOps?.length) return proof === "site" && !selfOpsProblems(collection).length ? [...new Set(collection.selfOps)] : [];
200
+ return proof === "id_token" && isSurveyShape(collection) ? ["submit"] : [];
201
+ }
202
+ // ../schema/src/capabilities.ts
198
203
  /** 出典の項目と、内側の項目の key */
199
204
  const SOURCES_FIELD = {
200
205
  key: "sources",
201
206
  source: "source",
202
207
  note: "note"
203
208
  };
204
- // ../model/src/legacy.ts
209
+ /** 主のコレクションか(公開の管理と本文の項目を持つ一覧のコレクション) */
210
+ const isPrimaryCandidate = (collection) => isListCollection(collection) && publishingOf(collection) !== "none" && roleFieldOf(collection, "body") !== null;
211
+ /** 主のコレクション(スキーマの順で先頭、なければ null) */
212
+ const primaryCollectionOf = (schema) => schema.collections.find(isPrimaryCandidate) ?? null;
213
+ /** 主のコレクション(なければ例外: そのコレクションを前提にする画面・処理だけが使用) */
214
+ function requiredPrimaryCollectionOf(collectionSchema) {
215
+ const collection = primaryCollectionOf(collectionSchema);
216
+ if (!collection) throw new Error("content schema has no collection with publishing and a body field");
217
+ return collection;
218
+ }
219
+ /** 暦の日付(日付の役割の項目を持つ一覧のコレクションと項目の key、スキーマの順、役割は宣言だけで推測なし) */
220
+ const dateRoleFieldsOf = (schema) => schema.collections.filter(isListCollection).flatMap((t) => {
221
+ const f = roleFieldOf(t, "date");
222
+ return f ? [{
223
+ collection: t.id,
224
+ field: f.key
225
+ }] : [];
226
+ });
227
+ /** コレクションの出典の項目(なければ null) */
228
+ function sourcesFieldOf(collection) {
229
+ const f = collection.fields.find((x) => x.key === SOURCES_FIELD.key);
230
+ if (f?.type !== "group" || !f.multiple) return null;
231
+ const source = f.fields.find((x) => x.key === SOURCES_FIELD.source);
232
+ return source?.type === "reference" && !source.multiple ? {
233
+ ...f,
234
+ to: source.to
235
+ } : null;
236
+ }
237
+ /** 出典の値にある参照の ID(注の順、空と形の誤りは除外) */
238
+ const sourceIdsOf = (value) => (Array.isArray(value) ? value : []).flatMap((item) => {
239
+ const id = item && typeof item === "object" ? item[SOURCES_FIELD.source] : void 0;
240
+ return typeof id === "string" && id ? [id] : [];
241
+ });
242
+ // ../schema/src/legacy.ts
205
243
  const isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
206
244
  /** 記事の表のコレクションだった目印(古いバージョンの table の値) */
207
245
  const ARTICLES = "articles";
@@ -279,19 +317,19 @@ function normalizeCollection(t) {
279
317
  fields: [...fields, ...computed]
280
318
  };
281
319
  }
282
- /** 古い形のスキーマの JSON を今の形に(形の分からない値はそのまま、検査は parseModel) */
283
- function normalizeLegacyModel(json) {
320
+ /** 古い形のスキーマの JSON を今の形に(形の分からない値はそのまま、検査は parseSchema) */
321
+ function normalizeLegacySchema(json) {
284
322
  if (!isRecord(json) || !Array.isArray(json.collections)) return json;
285
323
  return {
286
324
  ...json,
287
325
  collections: json.collections.map((t) => isRecord(t) ? normalizeCollection(t) : t)
288
326
  };
289
327
  }
290
- // ../model/src/schema.ts
328
+ // ../schema/src/schema.ts
291
329
  /** 保持の日数の上限(100年) */
292
330
  const RETENTION_DAYS_MAX = 36500;
293
- const key = z.string().regex(/^[a-z][a-z0-9_]*$/, modelProblemText("invalid_collection_id"));
294
- const fieldKey = z.string().regex(/^[a-z][a-zA-Z0-9_-]*$/, modelProblemText("invalid_field_key"));
331
+ const key = z.string().regex(/^[a-z][a-z0-9_]*$/, schemaProblemText("invalid_collection_id"));
332
+ const fieldKey = z.string().regex(/^[a-z][a-zA-Z0-9_-]*$/, schemaProblemText("invalid_field_key"));
295
333
  const condition = z.object({
296
334
  key: fieldKey,
297
335
  in: z.array(z.string().min(1)).min(1)
@@ -351,7 +389,7 @@ const pageRule = z.union([
351
389
  ]);
352
390
  const page = z.object({
353
391
  when: condition.optional(),
354
- path: z.string().startsWith("/", modelProblemText("page_path_slash")),
392
+ path: z.string().startsWith("/", schemaProblemText("page_path_slash")),
355
393
  public: z.array(pageRule).optional()
356
394
  });
357
395
  const field = z.lazy(() => fieldUnion);
@@ -377,7 +415,7 @@ const regex = z.string().refine((p) => {
377
415
  } catch {
378
416
  return false;
379
417
  }
380
- }, modelProblemText("invalid_pattern"));
418
+ }, schemaProblemText("invalid_pattern"));
381
419
  const anonymize = z.array(fieldKey).min(1).optional();
382
420
  const fieldUnion = z.discriminatedUnion("type", [
383
421
  z.object({
@@ -448,13 +486,13 @@ const fieldUnion = z.discriminatedUnion("type", [
448
486
  }).optional(),
449
487
  transitions: z.array(transition).optional()
450
488
  }).refine((f) => f.initial === void 0 || f.options.some((o) => o.value === f.initial), {
451
- message: modelProblemText("initial_not_option"),
489
+ message: schemaProblemText("initial_not_option"),
452
490
  path: ["initial"]
453
491
  }).refine((f) => !f.derive || [...Object.values(f.derive.map), f.derive.otherwise].every((v) => f.options.some((o) => o.value === v)), {
454
- message: modelProblemText("derive_not_option"),
492
+ message: schemaProblemText("derive_not_option"),
455
493
  path: ["derive"]
456
494
  }).refine((f) => !f.fixedBy || Object.values(f.fixedBy.map).every((v) => f.options.some((o) => o.value === v)), {
457
- message: modelProblemText("fixed_not_option"),
495
+ message: schemaProblemText("fixed_not_option"),
458
496
  path: ["fixedBy"]
459
497
  }),
460
498
  z.object({
@@ -475,7 +513,7 @@ const fieldUnion = z.discriminatedUnion("type", [
475
513
  z.object({
476
514
  ...base,
477
515
  ...counts,
478
- type: z.literal("media"),
516
+ type: z.literal("file"),
479
517
  accept: z.array(z.enum(["image", "video"])).optional(),
480
518
  multiple: z.boolean().optional(),
481
519
  frames: z.array(frame).optional(),
@@ -506,7 +544,7 @@ const fieldUnion = z.discriminatedUnion("type", [
506
544
  onDelete: z.enum(ON_DELETE).optional(),
507
545
  anonymize
508
546
  }).refine((f) => f.onDelete !== "restrict", {
509
- message: modelProblemText("customer_restrict"),
547
+ message: schemaProblemText("customer_restrict"),
510
548
  path: ["onDelete"]
511
549
  })
512
550
  ]);
@@ -521,7 +559,7 @@ const conditionsValid = (fields) => fields.every((f) => conditionValid(f.when, f
521
559
  const nestedRules = (fields) => fields.flatMap((f) => (f.fields ?? []).flatMap((c) => [...c.derive || c.fixedBy ? [`${f.key}.${c.key}`] : [], ...nestedRules([c]).map((k) => `${f.key}.${k}`)]));
522
560
  /**
523
561
  * システムの値と同じ名前で、項目の key に使用できない名前(API・配信が項目の値を上書きするため)
524
- * - すべてのコレクション: レコードの ID とスラッグ・作成と更新の日時・作成者、管理画面の一覧で参照する行の数 uses
562
+ * - すべてのコレクション: レコードの ID とスラッグ・作成と更新の日時・作成者、ワークスペースの一覧で参照する行の数 uses
525
563
  * - 公開の管理があるコレクション: 公開の機能の値
526
564
  * - 対象外: API・配信の値に出ない列 type、導入先の設定で決まるアカウントの email・account_role
527
565
  */
@@ -566,18 +604,18 @@ const COMPUTED_TYPES = {
566
604
  };
567
605
  /** 計算の項目の誤り(最上位の項目と、まとまりの中にある計算の項目) */
568
606
  function computedProblems(collection, fields) {
569
- const nested = (fs, path) => fs.flatMap((f) => [...f.computed ? [modelProblemText("computed_nested", {
607
+ const nested = (fs, path) => fs.flatMap((f) => [...f.computed ? [schemaProblemText("computed_nested", {
570
608
  collection,
571
609
  field: `${path}${f.key}`
572
610
  })] : [], ...nested(f.fields ?? [], `${path}${f.key}.`)]);
573
611
  return fields.flatMap((f) => {
574
612
  const inner = nested(f.fields ?? [], `${f.key}.`);
575
613
  if (!f.computed) return inner;
576
- return [...[...fields.find((g) => g.key === f.computed.from)?.type === "rich_text" ? [] : [modelProblemText("computed_from_not_body", {
614
+ return [...[...fields.find((g) => g.key === f.computed.from)?.type === "rich_text" ? [] : [schemaProblemText("computed_from_not_body", {
577
615
  collection,
578
616
  field: f.key,
579
617
  from: f.computed.from
580
- })], ...COMPUTED_TYPES[f.computed.kind]?.(f) ? [] : [modelProblemText("computed_type_mismatch", {
618
+ })], ...COMPUTED_TYPES[f.computed.kind]?.(f) ? [] : [schemaProblemText("computed_type_mismatch", {
581
619
  collection,
582
620
  field: f.key,
583
621
  kind: f.computed.kind,
@@ -588,12 +626,12 @@ function computedProblems(collection, fields) {
588
626
  /** 役割の宣言の誤り(最上位にない key・役割が受け付けない項目) */
589
627
  const roleProblems = (collection, roles, fields) => Object.entries(roles).flatMap(([role, key]) => {
590
628
  const f = fields.find((g) => g.key === key);
591
- if (!f) return [modelProblemText("role_field_not_top", {
629
+ if (!f) return [schemaProblemText("role_field_not_top", {
592
630
  collection,
593
631
  role,
594
632
  field: String(key)
595
633
  })];
596
- return acceptsRole(role, f) ? [] : [modelProblemText("role_field_mismatch", {
634
+ return acceptsRole(role, f) ? [] : [schemaProblemText("role_field_mismatch", {
597
635
  collection,
598
636
  role,
599
637
  field: f.key,
@@ -605,23 +643,23 @@ function audienceProblems(collection, fields, grant) {
605
643
  const hasSelf = fields.some((f) => f.type === "customer" && f.self);
606
644
  const nested = (fs, path, outer) => fs.flatMap((f) => {
607
645
  const own = f.audience ?? outer;
608
- return [...own !== outer && own !== "staff" ? [modelProblemText("audience_nested_wider", {
646
+ return [...own !== outer && own !== "staff" ? [schemaProblemText("audience_nested_wider", {
609
647
  collection,
610
648
  field: `${path}${f.key}`
611
649
  })] : [], ...nested(f.fields ?? [], `${path}${f.key}.`, own)];
612
650
  });
613
- const own = fields.flatMap((f) => [...f.type === "customer" && f.audience !== "self" && f.audience !== "staff" ? [modelProblemText("audience_customer_field", {
651
+ const own = fields.flatMap((f) => [...f.type === "customer" && f.audience !== "self" && f.audience !== "staff" ? [schemaProblemText("audience_customer_field", {
614
652
  collection,
615
653
  field: f.key
616
654
  })] : [], ...nested(f.fields ?? [], `${f.key}.`, f.audience ?? "public")]);
617
655
  const anySelf = (fs) => fs.some((f) => f.audience === "self" || anySelf(f.fields ?? []));
618
- const self = !hasSelf && anySelf(fields) ? [modelProblemText("audience_self_without_marker", { collection })] : [];
656
+ const self = !hasSelf && anySelf(fields) ? [schemaProblemText("audience_self_without_marker", { collection })] : [];
619
657
  if (grant === void 0) return [...own, ...self];
620
658
  const ref = fields.find((f) => f.key === grant);
621
659
  return [
622
660
  ...own,
623
661
  ...self,
624
- ...ref?.type === "reference" && (ref.audience === "public" || ref.audience === "granted") ? [] : [modelProblemText("grant_not_reference", {
662
+ ...ref?.type === "reference" && (ref.audience === "public" || ref.audience === "granted") ? [] : [schemaProblemText("grant_not_reference", {
625
663
  collection,
626
664
  grant
627
665
  })]
@@ -642,7 +680,7 @@ const placeholdersOf = (template) => [...template.matchAll(/\{([A-Za-z0-9_-]+)\}
642
680
  */
643
681
  function derivedAudienceProblems(t) {
644
682
  const byKey = new Map(t.fields.map((f) => [f.key, f]));
645
- const narrowerSource = (f, from, source) => narrowerThan(byKey.get(from)?.audience, f.audience) && byKey.has(from) ? [modelProblemText("audience_wider_than_source", {
683
+ const narrowerSource = (f, from, source) => narrowerThan(byKey.get(from)?.audience, f.audience) && byKey.has(from) ? [schemaProblemText("audience_wider_than_source", {
646
684
  collection: t.slug,
647
685
  field: f.key,
648
686
  source,
@@ -655,11 +693,11 @@ function derivedAudienceProblems(t) {
655
693
  ]);
656
694
  const allowed = /* @__PURE__ */ new Set(["slug", ...(t.counts ?? []).map((c) => c.key)]);
657
695
  const templates = [...(t.pages ?? []).map((p) => p.path), ...t.og ? [t.og] : []];
658
- const ids = templates.filter((tpl) => placeholdersOf(tpl).includes("id")).map((tpl) => modelProblemText("template_id_placeholder", {
696
+ const ids = templates.filter((tpl) => placeholdersOf(tpl).includes("id")).map((tpl) => schemaProblemText("template_id_placeholder", {
659
697
  collection: t.slug,
660
698
  template: tpl
661
699
  }));
662
- const paths = templates.flatMap((tpl) => placeholdersOf(tpl).filter((k) => k !== "id" && !allowed.has(k) && (byKey.get(k)?.audience ?? "public") !== "public").map((k) => modelProblemText("template_private_placeholder", {
700
+ const paths = templates.flatMap((tpl) => placeholdersOf(tpl).filter((k) => k !== "id" && !allowed.has(k) && (byKey.get(k)?.audience ?? "public") !== "public").map((k) => schemaProblemText("template_private_placeholder", {
663
701
  collection: t.slug,
664
702
  template: tpl,
665
703
  key: k
@@ -675,14 +713,14 @@ function crossCollectionAudienceProblems(collections) {
675
713
  const fixed = collections.flatMap((t) => t.fields.flatMap((f) => {
676
714
  if (!f.fixedBy) return [];
677
715
  const ref = t.fields.find((g) => g.key === f.fixedBy.ref);
678
- return [ref, ref?.to ? collections.find((x) => x.id === ref.to)?.fields.find((g) => g.key === f.fixedBy.key) : void 0].some((src) => src && narrowerThan(src.audience, f.audience)) ? [modelProblemText("fixed_by_wider", {
716
+ return [ref, ref?.to ? collections.find((x) => x.id === ref.to)?.fields.find((g) => g.key === f.fixedBy.key) : void 0].some((src) => src && narrowerThan(src.audience, f.audience)) ? [schemaProblemText("fixed_by_wider", {
679
717
  collection: t.slug,
680
718
  field: f.key
681
719
  })] : [];
682
720
  }));
683
721
  const counts = collections.flatMap((t) => (t.counts ?? []).flatMap((c) => {
684
722
  const ref = collections.find((x) => x.id === c.from)?.fields.find((g) => g.key === c.field);
685
- return ref && (ref.audience ?? "public") !== "public" ? [modelProblemText("count_reference_private", {
723
+ return ref && (ref.audience ?? "public") !== "public" ? [schemaProblemText("count_reference_private", {
686
724
  collection: t.slug,
687
725
  key: c.key,
688
726
  fromCollection: collections.find((x) => x.id === c.from)?.slug ?? c.from,
@@ -693,7 +731,7 @@ function crossCollectionAudienceProblems(collections) {
693
731
  }
694
732
  /** 顧客フィールドの誤り(まとまりの中に置かない) */
695
733
  function customerFieldProblems(collection, fields) {
696
- const nested = (fs, path) => fs.flatMap((f) => [...f.type === "customer" ? [modelProblemText("customer_field_nested", {
734
+ const nested = (fs, path) => fs.flatMap((f) => [...f.type === "customer" ? [schemaProblemText("customer_field_nested", {
697
735
  collection,
698
736
  field: `${path}${f.key}`
699
737
  })] : [], ...nested(f.fields ?? [], `${path}${f.key}.`)]);
@@ -709,7 +747,7 @@ const UNCLEARABLE = /* @__PURE__ */ new Set([
709
747
  const isRequired = (f) => f.required !== void 0 && f.required !== false;
710
748
  /** 指す先が消えたときの扱いのコレクションの中の誤り(必須の項目の clear・anonymize、anonymize の項目、まとまりの中の宣言) */
711
749
  function onDeleteProblems(collection, fields) {
712
- const nested = (fs, path) => fs.flatMap((f) => [...f.onDelete !== void 0 || f.anonymize ? [modelProblemText("on_delete_nested", {
750
+ const nested = (fs, path) => fs.flatMap((f) => [...f.onDelete !== void 0 || f.anonymize ? [schemaProblemText("on_delete_nested", {
713
751
  collection,
714
752
  field: `${path}${f.key}`
715
753
  })] : [], ...nested(f.fields ?? [], `${path}${f.key}.`)]);
@@ -717,34 +755,34 @@ function onDeleteProblems(collection, fields) {
717
755
  const inner = nested(f.fields ?? [], `${f.key}.`);
718
756
  if (f.type !== "customer" && f.type !== "reference") return inner;
719
757
  return [...[
720
- ...isRequired(f) && (f.onDelete === "clear" || f.onDelete === "anonymize") ? [modelProblemText("on_delete_required", {
758
+ ...isRequired(f) && (f.onDelete === "clear" || f.onDelete === "anonymize") ? [schemaProblemText("on_delete_required", {
721
759
  collection,
722
760
  field: f.key,
723
761
  onDelete: f.onDelete
724
762
  })] : [],
725
- ...(f.minItems ?? 0) > 0 && (f.onDelete === "clear" || f.onDelete === "anonymize") ? [modelProblemText("on_delete_min_items", {
763
+ ...(f.minItems ?? 0) > 0 && (f.onDelete === "clear" || f.onDelete === "anonymize") ? [schemaProblemText("on_delete_min_items", {
726
764
  collection,
727
765
  field: f.key,
728
766
  onDelete: f.onDelete
729
767
  })] : [],
730
- ...f.anonymize && f.onDelete !== "anonymize" ? [modelProblemText("anonymize_without_on_delete", {
768
+ ...f.anonymize && f.onDelete !== "anonymize" ? [schemaProblemText("anonymize_without_on_delete", {
731
769
  collection,
732
770
  field: f.key
733
771
  })] : [],
734
772
  ...(f.anonymize ?? []).flatMap((k) => {
735
773
  const g = fields.find((x) => x.key === k);
736
- if (!g) return [modelProblemText("anonymize_field_missing", {
774
+ if (!g) return [schemaProblemText("anonymize_field_missing", {
737
775
  collection,
738
776
  field: f.key,
739
777
  target: k
740
778
  })];
741
- if (UNCLEARABLE.has(g.type) || g.computed) return [modelProblemText("anonymize_field_unclearable", {
779
+ if (UNCLEARABLE.has(g.type) || g.computed) return [schemaProblemText("anonymize_field_unclearable", {
742
780
  collection,
743
781
  field: f.key,
744
782
  target: k,
745
783
  type: g.type
746
784
  })];
747
- return isRequired(g) ? [modelProblemText("anonymize_field_required", {
785
+ return isRequired(g) ? [schemaProblemText("anonymize_field_required", {
748
786
  collection,
749
787
  field: f.key,
750
788
  target: k
@@ -774,16 +812,16 @@ function cascadeProblems(collections) {
774
812
  const found = cyclic.has(collection.id) ? null : cycleFrom(collection.id);
775
813
  if (!found) continue;
776
814
  found.forEach((id) => cyclic.add(id));
777
- problems.push(modelProblemText("cascade_cycle", { cycle: found.map((id) => collections.find((c) => c.id === id)?.slug ?? id).join(" → ") }));
815
+ problems.push(schemaProblemText("cascade_cycle", { cycle: found.map((id) => collections.find((c) => c.id === id)?.slug ?? id).join(" → ") }));
778
816
  }
779
817
  if (problems.length) return problems;
780
818
  const depth = cascadeDepths(collections);
781
- const tooDeep = [...depth].filter(([, d]) => d > 4).map(([id, d]) => modelProblemText("cascade_too_deep", {
819
+ const tooDeep = [...depth].filter(([, d]) => d > 4).map(([id, d]) => schemaProblemText("cascade_too_deep", {
782
820
  collection: collections.find((c) => c.id === id)?.slug ?? id,
783
821
  depth: d,
784
822
  max: 4
785
823
  }));
786
- const self = collections.filter((collection) => cascadeTargetsOf(collection).some((to) => depth.has(to))).flatMap((collection) => collection.fields.filter((f) => f.type === "customer" && f.self).map((f) => modelProblemText("cascade_self_customer", {
824
+ const self = collections.filter((collection) => cascadeTargetsOf(collection).some((to) => depth.has(to))).flatMap((collection) => collection.fields.filter((f) => f.type === "customer" && f.self).map((f) => schemaProblemText("cascade_self_customer", {
787
825
  collection: collection.slug,
788
826
  field: f.key
789
827
  })));
@@ -795,12 +833,12 @@ function restrictProblems(collections, undeclared) {
795
833
  const walk = (collectionId, fields, path) => fields.flatMap((f) => {
796
834
  if (f.type === "group") return walk(collectionId, f.fields ?? [], `${path}${f.key}.`);
797
835
  if (f.type !== "reference" || !f.to || !reachable.has(f.to)) return [];
798
- if (f.onDelete === "restrict") return [modelProblemText("restrict_reachable", {
836
+ if (f.onDelete === "restrict") return [schemaProblemText("restrict_reachable", {
799
837
  collection: collectionId,
800
838
  field: `${path}${f.key}`,
801
839
  to: f.to
802
840
  })];
803
- if (undeclared && f.onDelete === void 0) return [modelProblemText("on_delete_undeclared_reference", {
841
+ if (undeclared && f.onDelete === void 0) return [schemaProblemText("on_delete_undeclared_reference", {
804
842
  collection: collectionId,
805
843
  field: `${path}${f.key}`,
806
844
  to: f.to,
@@ -814,10 +852,10 @@ function restrictProblems(collections, undeclared) {
814
852
  function privateProblems(t) {
815
853
  const collection = t.slug;
816
854
  return [
817
- ...t.format === "object" ? [modelProblemText("private_object", { collection })] : [],
818
- ...(t.publishing ?? "none") !== "none" ? [modelProblemText("private_publishing", { collection })] : [],
819
- ...t.pages?.length ? [modelProblemText("private_pages", { collection })] : [],
820
- ...t.grant !== void 0 ? [modelProblemText("private_grant", { collection })] : []
855
+ ...t.format === "object" ? [schemaProblemText("private_object", { collection })] : [],
856
+ ...(t.publishing ?? "none") !== "none" ? [schemaProblemText("private_publishing", { collection })] : [],
857
+ ...t.pages?.length ? [schemaProblemText("private_pages", { collection })] : [],
858
+ ...t.grant !== void 0 ? [schemaProblemText("private_grant", { collection })] : []
821
859
  ];
822
860
  }
823
861
  /** 本文の項目が使用する部品の名前(まとまりの中も、key は項目の key) */
@@ -845,11 +883,11 @@ const contentType = z.object({
845
883
  from: z.string().min(1),
846
884
  field: fieldKey
847
885
  })).optional(),
848
- og: z.string().startsWith("/", modelProblemText("og_path_slash")).optional(),
886
+ og: z.string().startsWith("/", schemaProblemText("og_path_slash")).optional(),
849
887
  slugMode: z.enum(SLUG_MODES).optional(),
850
888
  roles: z.partialRecord(z.enum(FIELD_ROLES), fieldKey).optional(),
851
889
  grant: fieldKey.optional(),
852
- entitlement: z.never({ message: modelProblemText("entitlement_renamed") }).optional(),
890
+ entitlement: z.never({ message: schemaProblemText("entitlement_renamed") }).optional(),
853
891
  private: z.boolean().optional(),
854
892
  unique: z.array(z.object({
855
893
  key: fieldKey,
@@ -857,27 +895,28 @@ const contentType = z.object({
857
895
  exact: z.boolean().optional()
858
896
  })).optional(),
859
897
  selfOps: z.array(z.enum(SELF_OPS)).optional(),
860
- retentionDays: z.number().int().positive().max(RETENTION_DAYS_MAX).optional()
861
- }).refine((t) => new Set(t.fields.map((f) => f.key)).size === t.fields.length, { message: modelProblemText("duplicate_field_key") }).refine((t) => conditionsValid(t.fields), { message: modelProblemText("condition_invalid") }).refine((t) => (t.pages ?? []).every((p) => conditionValid(p.when, t.fields)), { message: modelProblemText("page_condition_invalid") }).superRefine((t, ctx) => {
898
+ retentionDays: z.number().int().positive().max(RETENTION_DAYS_MAX).optional(),
899
+ publishChecks: z.array(z.string().min(1)).optional()
900
+ }).refine((t) => new Set(t.fields.map((f) => f.key)).size === t.fields.length, { message: schemaProblemText("duplicate_field_key") }).refine((t) => conditionsValid(t.fields), { message: schemaProblemText("condition_invalid") }).refine((t) => (t.pages ?? []).every((p) => conditionValid(p.when, t.fields)), { message: schemaProblemText("page_condition_invalid") }).superRefine((t, ctx) => {
862
901
  const fields = t.fields;
863
902
  const asCollection = t;
864
903
  for (const k of reservedKeysOf(t)) ctx.addIssue({
865
904
  code: "custom",
866
- message: modelProblemText("reserved_key", {
905
+ message: schemaProblemText("reserved_key", {
867
906
  collection: t.slug,
868
907
  key: k
869
908
  })
870
909
  });
871
910
  for (const f of fields) if (RESERVED_QUERY.includes(f.key)) ctx.addIssue({
872
911
  code: "custom",
873
- message: modelProblemText("reserved_query_key", {
912
+ message: schemaProblemText("reserved_query_key", {
874
913
  collection: t.slug,
875
914
  key: f.key
876
915
  })
877
916
  });
878
917
  for (const k of nestedRules(fields)) ctx.addIssue({
879
918
  code: "custom",
880
- message: modelProblemText("nested_rule", {
919
+ message: schemaProblemText("nested_rule", {
881
920
  collection: t.slug,
882
921
  field: k
883
922
  })
@@ -913,11 +952,11 @@ const contentType = z.object({
913
952
  });
914
953
  z.object({
915
954
  components: declaredComponentsSchema.optional(),
916
- collections: z.array(contentType).refine((ts) => new Set(ts.map((t) => t.id)).size === ts.length, { message: modelProblemText("duplicate_collection_id") }).refine((ts) => new Set(ts.map((t) => t.slug)).size === ts.length, { message: modelProblemText("duplicate_collection_slug") }).superRefine((ts, ctx) => {
955
+ collections: z.array(contentType).refine((ts) => new Set(ts.map((t) => t.id)).size === ts.length, { message: schemaProblemText("duplicate_collection_id") }).refine((ts) => new Set(ts.map((t) => t.slug)).size === ts.length, { message: schemaProblemText("duplicate_collection_slug") }).superRefine((ts, ctx) => {
917
956
  const ids = new Set(ts.map((t) => t.id));
918
957
  for (const t of ts) for (const to of referenceTargets(t.fields)) if (!ids.has(to)) ctx.addIssue({
919
958
  code: "custom",
920
- message: modelProblemText("reference_target_missing", {
959
+ message: schemaProblemText("reference_target_missing", {
921
960
  collection: t.slug,
922
961
  to
923
962
  })
@@ -929,7 +968,7 @@ z.object({
929
968
  const ref = from && from.fields.find((f) => f.key === c.field);
930
969
  if (ref?.type !== "reference" || ref.to !== t.id) ctx.addIssue({
931
970
  code: "custom",
932
- message: modelProblemText("count_reference_mismatch", {
971
+ message: schemaProblemText("count_reference_mismatch", {
933
972
  collection: t.slug,
934
973
  key: c.key,
935
974
  fromCollection: from?.slug ?? c.from,
@@ -938,7 +977,7 @@ z.object({
938
977
  });
939
978
  if (keys.has(c.key)) ctx.addIssue({
940
979
  code: "custom",
941
- message: modelProblemText("count_key_duplicate", {
980
+ message: schemaProblemText("count_key_duplicate", {
942
981
  collection: t.slug,
943
982
  key: c.key
944
983
  })
@@ -973,7 +1012,7 @@ z.object({
973
1012
  const known = /* @__PURE__ */ new Set([...CORE_COMPONENTS.map((c) => c.name), ...(m.components ?? []).map((c) => c.name)]);
974
1013
  for (const t of m.collections) for (const { key, name } of bodyComponents(t.fields)) if (!known.has(name)) ctx.addIssue({
975
1014
  code: "custom",
976
- message: modelProblemText("component_unknown", {
1015
+ message: schemaProblemText("component_unknown", {
977
1016
  collection: t.slug,
978
1017
  field: key,
979
1018
  name
@@ -985,11 +1024,11 @@ const readable = (json) => isRecord$1(json) && Array.isArray(json.collections) &
985
1024
  /**
986
1025
  * 保存した版とファイルの読み込み(寛容: 旧い語を今の名前にした値をそのまま返し、規則で拒まない、既定を書き込まない)
987
1026
  * - コレクションの一覧として読めない値だけ例外(壊れた版)
988
- * - 見える範囲などの読み替えは audienceOf と resolvedModel(保存の形には書き戻さない)
1027
+ * - 見える範囲などの読み替えは audienceOf と resolvedSchema(保存の形には書き戻さない)
989
1028
  */
990
- function parseModel(json) {
991
- const normalized = normalizeLegacyModel(json);
992
- if (!readable(normalized)) throw new Error("model_unreadable");
1029
+ function parseSchema(json) {
1030
+ const normalized = normalizeLegacySchema(json);
1031
+ if (!readable(normalized)) throw new Error("schema_unreadable");
993
1032
  return normalized;
994
1033
  }
995
- export { modelProblemText as i, fieldDefSchema as n, parseModel as r, RESERVED_FIELD_KEYS as t };
1034
+ export { requiredPrimaryCollectionOf as a, selfOpsOf as c, dateRoleFieldsOf as i, schemaProblemText as l, fieldDefSchema as n, sourceIdsOf as o, parseSchema as r, sourcesFieldOf as s, RESERVED_FIELD_KEYS as t };