@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
package/dist/schema.js CHANGED
@@ -1 +1,346 @@
1
- export { t as TYPES_EXIT_CODES, n as fetchDeliveredCollections, r as runTypesCli } from "./schema-BPHL7Qr-.js";
1
+ import { M as usesReview, O as optionLabelOf, T as isStoredCollection, g as initialValueOf, j as roleFieldOf, k as optionsOf, p as collectionOf } from "./collection-BEOxeISR.js";
2
+ import { a as cropRect, c as stillOf, i as coverStart, l as createClock, n as publicPathOf, o as croppedHotspot, r as coverPosition, s as objectPosition, t as pagePathOf, u as isDateOnly } from "./page-Bzrj24sJ.js";
3
+ import { a as requiredPrimaryCollectionOf, i as dateRoleFieldsOf, l as schemaProblemText, o as sourceIdsOf, r as parseSchema, s as sourcesFieldOf } from "./schema-WnobuwLg.js";
4
+ import { t as PRODUCT_FIELD_LABELS } from "./ja-Du6ooL6i.js";
5
+ import { n as typesSourceOf, r as valueFieldsOf } from "./typesSource-CWybQYus.js";
6
+ import { z } from "zod";
7
+ // ../schema/src/file.ts
8
+ const unit = z.number().min(0).max(1);
9
+ /** 見せたい点の検査 */
10
+ const hotspotSchema = z.object({
11
+ x: unit,
12
+ y: unit,
13
+ width: unit.optional(),
14
+ height: unit.optional()
15
+ });
16
+ z.object({
17
+ top: unit,
18
+ bottom: unit,
19
+ left: unit,
20
+ right: unit
21
+ }).refine((c) => c.left + c.right <= .9 && c.top + c.bottom <= .9, schemaProblemText("crop_too_large"));
22
+ const mediaBase = z.object({
23
+ src: z.string().min(1),
24
+ width: z.number().int().positive(),
25
+ height: z.number().int().positive(),
26
+ alt: z.string(),
27
+ hotspot: hotspotSchema.optional()
28
+ });
29
+ /** 解決後の素材の検査(src は URL、ビルドで読み込んだ画像は JSON に含めないため対象外) */
30
+ const mediaSchema = z.union([mediaBase.extend({ kind: z.literal("image") }), mediaBase.extend({
31
+ kind: z.literal("video"),
32
+ poster: mediaBase
33
+ })]);
34
+ /** 使用する側が保存する実体の参照の検査 */
35
+ const fileRefSchema = z.object({ file: z.string().min(1) });
36
+ // ../schema/src/media.ts
37
+ const file = [
38
+ {
39
+ key: "mime_type",
40
+ label: PRODUCT_FIELD_LABELS.mimeType,
41
+ type: "text",
42
+ required: "save",
43
+ description: PRODUCT_FIELD_LABELS.mimeTypeDescription
44
+ },
45
+ {
46
+ key: "size",
47
+ label: PRODUCT_FIELD_LABELS.size,
48
+ type: "number",
49
+ required: "save",
50
+ description: PRODUCT_FIELD_LABELS.sizeDescription
51
+ },
52
+ {
53
+ key: "width",
54
+ label: PRODUCT_FIELD_LABELS.width,
55
+ type: "number",
56
+ required: "save",
57
+ description: "px"
58
+ },
59
+ {
60
+ key: "height",
61
+ label: PRODUCT_FIELD_LABELS.height,
62
+ type: "number",
63
+ required: "save",
64
+ description: "px"
65
+ },
66
+ {
67
+ key: "alt",
68
+ label: PRODUCT_FIELD_LABELS.alt,
69
+ type: "text",
70
+ description: PRODUCT_FIELD_LABELS.altDescription
71
+ }
72
+ ];
73
+ /** 画像のコレクション */
74
+ const IMAGE_TYPE = {
75
+ id: "image",
76
+ slug: "image",
77
+ label: PRODUCT_FIELD_LABELS.image,
78
+ description: PRODUCT_FIELD_LABELS.imageDescription,
79
+ fields: file
80
+ };
81
+ /** 動画のコレクション(配信と再生は最初に使用する場所が決まったときに実装) */
82
+ const VIDEO_TYPE = {
83
+ id: "video",
84
+ slug: "video",
85
+ label: PRODUCT_FIELD_LABELS.video,
86
+ fields: [
87
+ ...file,
88
+ {
89
+ key: "duration",
90
+ label: PRODUCT_FIELD_LABELS.duration,
91
+ type: "number",
92
+ description: PRODUCT_FIELD_LABELS.durationDescription
93
+ },
94
+ {
95
+ key: "poster",
96
+ label: PRODUCT_FIELD_LABELS.poster,
97
+ type: "file",
98
+ accept: ["image"],
99
+ description: PRODUCT_FIELD_LABELS.posterDescription
100
+ }
101
+ ]
102
+ };
103
+ // ../schema/src/screens.ts
104
+ /** メニューのグループの id(運用のサイドバーのグループはこの1つだけ) */
105
+ const MENU_GROUP_ID = "collections";
106
+ const COLLECTION_PREFIX = "collection:";
107
+ /** メニュー項目の id(コレクション) */
108
+ const collectionItem = (collection) => `${COLLECTION_PREFIX}${collection}`;
109
+ /** メニューにある全項目の id(グループの中も、上から順) */
110
+ const menuItemsOf = (menu) => menu.flatMap((e) => typeof e === "string" ? [e] : e.items);
111
+ /** 編集画面に配置した項目の id(セクションの順) */
112
+ const placedItemsOf = (layout) => layout.sections.flatMap((s) => s.items);
113
+ const id = z.string().regex(/^[a-z][a-z0-9_:-]*$/, schemaProblemText("invalid_screen_id"));
114
+ const item = z.string().min(1);
115
+ const unique = (values) => new Set(values).size === values.length;
116
+ const group = z.object({
117
+ id: z.literal(MENU_GROUP_ID),
118
+ collapsed: z.boolean().optional(),
119
+ items: z.array(item)
120
+ });
121
+ const section = z.object({
122
+ id,
123
+ label: z.string().trim(),
124
+ collapsed: z.boolean().optional(),
125
+ items: z.array(item)
126
+ });
127
+ const layout = z.object({
128
+ sections: z.array(section),
129
+ hidden: z.array(item).optional()
130
+ }).refine((l) => unique(l.sections.map((s) => s.id)), { message: schemaProblemText("duplicate_section_id") }).refine((l) => unique([...placedItemsOf(l), ...l.hidden ?? []]), { message: schemaProblemText("duplicate_placement") });
131
+ const screensSchema = z.object({
132
+ menu: z.array(z.union([item, group])).refine((m) => m.filter((e) => typeof e !== "string").length <= 1, { message: schemaProblemText("duplicate_menu_group") }).refine((m) => unique(menuItemsOf(m)), { message: schemaProblemText("duplicate_menu_item") }),
133
+ editors: z.record(z.string(), layout).default({}),
134
+ columns: z.record(z.string(), z.array(item).refine(unique, { message: schemaProblemText("duplicate_column") })).default({})
135
+ });
136
+ /** 画面の設定の JSON を検査(形の誤りは ZodError) */
137
+ const parseScreens = (json) => screensSchema.parse(json);
138
+ /** 中立の既定のスキーマ(新しいプロジェクトの作成で適用するコレクション: post・author・tag・image・video、設定の移入の土台) */
139
+ const DEFAULT_SCHEMA = { collections: [
140
+ {
141
+ id: "post",
142
+ slug: "post",
143
+ label: "投稿",
144
+ publishing: "review",
145
+ roles: {
146
+ title: "title",
147
+ image: "image",
148
+ body: "body"
149
+ },
150
+ fields: [
151
+ {
152
+ key: "title",
153
+ label: "タイトル",
154
+ type: "text",
155
+ required: "save"
156
+ },
157
+ {
158
+ key: "writers",
159
+ label: "著者",
160
+ type: "reference",
161
+ to: "author",
162
+ multiple: true
163
+ },
164
+ {
165
+ key: "image",
166
+ label: "メインの画像",
167
+ type: "file",
168
+ accept: ["image"]
169
+ },
170
+ {
171
+ key: "body",
172
+ label: "本文",
173
+ type: "rich_text",
174
+ profile: {
175
+ headings: [
176
+ 2,
177
+ 3,
178
+ 4
179
+ ],
180
+ marks: [
181
+ "strong",
182
+ "em",
183
+ "code",
184
+ "strike"
185
+ ],
186
+ list: {
187
+ ordered: true,
188
+ nested: true
189
+ },
190
+ quote: {
191
+ multiple: true,
192
+ cite: true
193
+ },
194
+ code: { caption: false },
195
+ table: {
196
+ head: "optional",
197
+ caption: "optional"
198
+ },
199
+ divider: true,
200
+ components: ["gallery", "link-card"]
201
+ }
202
+ },
203
+ {
204
+ key: "revised_at",
205
+ label: "更新日時",
206
+ type: "datetime"
207
+ },
208
+ {
209
+ key: "tags",
210
+ label: "タグ",
211
+ type: "reference",
212
+ to: "tag",
213
+ multiple: true
214
+ },
215
+ {
216
+ key: "excerpt",
217
+ label: "抜粋",
218
+ type: "long_text",
219
+ computed: {
220
+ kind: "excerpt",
221
+ from: "body"
222
+ }
223
+ },
224
+ {
225
+ key: "read_min",
226
+ label: "読了の分",
227
+ type: "number",
228
+ computed: {
229
+ kind: "read_min",
230
+ from: "body"
231
+ }
232
+ },
233
+ {
234
+ key: "links",
235
+ label: "リンク先",
236
+ type: "text",
237
+ multiple: true,
238
+ computed: {
239
+ kind: "links",
240
+ from: "body"
241
+ }
242
+ }
243
+ ],
244
+ pages: [{
245
+ path: "/posts/{slug}",
246
+ public: [{
247
+ key: "status",
248
+ in: ["published"]
249
+ }, {
250
+ key: "published_at",
251
+ notFuture: true
252
+ }]
253
+ }]
254
+ },
255
+ {
256
+ id: "author",
257
+ slug: "author",
258
+ label: "著者",
259
+ roles: {
260
+ title: "name",
261
+ image: "portrait"
262
+ },
263
+ fields: [
264
+ {
265
+ key: "name",
266
+ label: "名前",
267
+ type: "text",
268
+ required: "save"
269
+ },
270
+ {
271
+ key: "bio",
272
+ label: "紹介",
273
+ type: "long_text"
274
+ },
275
+ {
276
+ key: "portrait",
277
+ label: "顔の画像",
278
+ type: "file",
279
+ accept: ["image"]
280
+ }
281
+ ],
282
+ pages: [{ path: "/authors/{slug}" }]
283
+ },
284
+ {
285
+ id: "tag",
286
+ slug: "tag",
287
+ label: "タグ",
288
+ roles: { title: "label" },
289
+ fields: [{
290
+ key: "label",
291
+ label: "名前",
292
+ type: "text",
293
+ required: "save"
294
+ }]
295
+ },
296
+ IMAGE_TYPE,
297
+ VIDEO_TYPE
298
+ ] };
299
+ /** 既定の画面設定(新しいプロジェクトの作成で適用する中立の値、移入する screens の土台) */
300
+ const DEFAULT_SCREENS = {
301
+ menu: [
302
+ "calendar",
303
+ {
304
+ id: "collections",
305
+ items: [
306
+ collectionItem("post"),
307
+ collectionItem("tag"),
308
+ collectionItem("author")
309
+ ]
310
+ },
311
+ "files"
312
+ ],
313
+ editors: { post: { sections: [
314
+ {
315
+ id: "classify",
316
+ label: "分類",
317
+ items: ["writers", "tags"]
318
+ },
319
+ {
320
+ id: "publish",
321
+ label: "公開",
322
+ items: ["published_at", "revised_at"]
323
+ },
324
+ {
325
+ id: "excerpt",
326
+ label: "説明",
327
+ items: ["excerpt"]
328
+ },
329
+ {
330
+ id: "image",
331
+ label: "メインの画像",
332
+ items: ["image"]
333
+ }
334
+ ] } },
335
+ columns: { post: [
336
+ "status",
337
+ "writers",
338
+ "assignee",
339
+ "published_at",
340
+ "updated_at"
341
+ ] }
342
+ };
343
+ // ../contract/src/transfer.ts
344
+ /** スキーマと設定の形式の名前 */
345
+ const CONFIG_FORMAT = "cms-config";
346
+ export { CONFIG_FORMAT, DEFAULT_SCHEMA, DEFAULT_SCREENS, IMAGE_TYPE, VIDEO_TYPE, collectionOf, coverPosition, coverStart, createClock, cropRect, croppedHotspot, dateRoleFieldsOf, fileRefSchema, initialValueOf, isDateOnly, isStoredCollection, mediaSchema, objectPosition, optionLabelOf, optionsOf, pagePathOf, parseSchema, parseScreens, publicPathOf, requiredPrimaryCollectionOf, roleFieldOf, sourceIdsOf, sourcesFieldOf, stillOf, typesSourceOf, usesReview, valueFieldsOf };
@@ -6,7 +6,7 @@ export type HostSession = Readonly<{
6
6
  project: string;
7
7
  issuedAt: number;
8
8
  }>;
9
- /** ホスト名のプロジェクトの ID(台帳にないホスト名は null) */
9
+ /** ホスト名のプロジェクトの ID(レジストリにないホスト名は null) */
10
10
  export type ProjectOfHost = (host: string) => Promise<string | null>;
11
11
  /** プロジェクトの一括の取り消しの時刻(ミリ秒、取り消しなしは null) */
12
12
  export type SessionsValidAfter = (project: string) => Promise<number | null>;
@@ -28,7 +28,7 @@ export declare const openSession: <T>(request: Request, secret: string) => Promi
28
28
  export type HandoffLoginOptions = Readonly<{
29
29
  /** Cookie の署名の鍵 */
30
30
  secret: string;
31
- /** manage のログインの URL(例: https://console.example.com/login) */
31
+ /** console のログインの URL(例: https://console.example.com/login) */
32
32
  loginUrl: string;
33
33
  /** トークンを消して使い、メールアドレスを返す(使えないトークンは null、host は CMS のホスト名) */
34
34
  consume(token: string, host: string): Promise<string | null>;
@@ -43,7 +43,7 @@ export type HandoffLoginOptions = Readonly<{
43
43
  /** 今の時刻(ミリ秒、試験で差し替える) */
44
44
  now?: () => number;
45
45
  }>;
46
- /** manage からの引き継ぎのログイン */
46
+ /** console からの引き継ぎのログイン */
47
47
  export declare function handoffLogin({ secret, loginUrl, consume, projectOf, validAfter, basePath, sessionTtlSec, now }: HandoffLoginOptions): LoginAuth;
48
48
  /**
49
49
  * 2つのログインを順に試す(emailOf は first が null なら second、入り口とログアウトは first)
@@ -20,7 +20,7 @@ export type JwtOptions = Readonly<{
20
20
  export declare function verifyJwt(token: string, options: JwtOptions): Promise<JwtClaims | null>;
21
21
  /**
22
22
  * Cloudflare Access の JWT を検証する設定(teamDomain は <チーム>.cloudflareaccess.com、aud はアプリの AUD)
23
- * - aud: カンマ区切りで複数のアプリ(ホスト名ごとにアプリが分かれる管理画面、どのアプリを通すかは Access がホスト名で判定)
23
+ * - aud: カンマ区切りで複数のアプリ(ホスト名ごとにアプリが分かれるワークスペース、どのアプリを通すかは Access がホスト名で判定)
24
24
  */
25
25
  export declare const accessJwtOptions: ({ teamDomain, aud }: Readonly<{
26
26
  teamDomain: string;
@@ -1,6 +1,6 @@
1
1
  import { type FetchCerts, type JwtClaims, type JwtOptions } from './jwt.js';
2
2
  import { type ProjectOfHost } from './handoff.js';
3
- /** ログイン(Auth のポートと同じ形) */
3
+ /** ログイン(Auth のインターフェースと同じ形) */
4
4
  export type LoginAuth = {
5
5
  emailOf(request: Request): Promise<string | null>;
6
6
  /** ログインの入り口の応答(対象外のパスは null) */
@@ -18,7 +18,7 @@ export declare const DEFAULT_API_KEY_PERMISSIONS: {
18
18
  };
19
19
  /** 鍵の権限がコレクションの操作を許すか(read は read_drafts でも満たす、verify_customers は鍵の操作そのもの。新しい判定は判定の関数 authorize) */
20
20
  export declare function apiKeyAllows(permissions: ApiKeyPermissions, collection: string, operation: ApiKeyOperation): boolean;
21
- /** 一覧に表示する API の鍵(environments は読める環境で live か環境の URL のラベル、tail は鍵の末尾、revokedAt は失効の日時で有効なら null) */
21
+ /** 一覧に表示する API の鍵(environments は読める環境で live か環境の ID、tail は鍵の末尾、revokedAt は失効の日時で有効なら null) */
22
22
  export type ApiKey = Readonly<{
23
23
  id: string;
24
24
  label: string;
@@ -1,17 +1,21 @@
1
+ import type { AppScope } from './appServer.js';
1
2
  import type { SettingsArea } from './settings.js';
2
- /** 経路の権限の判定の種類(account はログイン中のすべて、admin は管理者だけ、settings:<領域> は設定の領域の権限) */
3
- export type AppRoutePolicy = 'account' | 'permission' | 'admin' | `settings:${SettingsArea}`;
3
+ /** 経路の権限の判定の種類(account はログイン中のすべて、own は本人か管理者で持ち主の判定は handle、admin は管理者だけ、settings:<領域> は設定の領域の権限) */
4
+ export type AppRoutePolicy = 'account' | 'own' | 'permission' | 'admin' | `settings:${SettingsArea}`;
4
5
  /** アプリの経路のメソッド */
5
6
  export type AppRouteMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
6
7
  /** 管理の API を呼ぶクライアント(path は /api から、呼んだ人の資格のまま) */
7
8
  export type CmsClient = Readonly<{
8
9
  fetch(path: `/api/${string}`, init?: RequestInit): Promise<Response>;
9
10
  }>;
10
- /** 経路の処理に渡す文脈(params は経路の名前つきの区間の値、egress はサーバーの宣言の egress の宛先だけへの GET と HEAD) */
11
+ /** 経路の処理に渡す文脈(params は経路の名前つきの区間の値、egress はサーバーの宣言の egress の宛先だけへの GET と HEAD、scope は呼び出しのプロジェクトの文脈) */
11
12
  export type AppContext = Readonly<{
12
13
  cms: CmsClient;
14
+ scope: AppScope;
13
15
  egress: (input: string | URL, init?: RequestInit) => Promise<Response>;
14
16
  params: Readonly<Record<string, string>>;
17
+ /** 応答の後へ回す処理(実行の文脈がない呼び出しではなし) */
18
+ defer?: (task: Promise<unknown>) => void;
15
19
  }>;
16
20
  /** アプリの経路(path は /api からの経路、`:<名前>` は1つの区間) */
17
21
  export type AppRoute = Readonly<{
@@ -20,16 +24,5 @@ export type AppRoute = Readonly<{
20
24
  policy: AppRoutePolicy;
21
25
  handle: (request: Request, ctx: AppContext) => Promise<Response>;
22
26
  }>;
23
- /**
24
- * 同じ Worker の中で動くアプリのサーバーの側の宣言(登録簿のマニフェスト apps.ts の AppManifest とは別)
25
- * - egress: 外への読み込みの宛先(https のオリジン、ホスト名の先頭の `*.` は1つ以上の区間)
26
- */
27
- export type AppServer = Readonly<{
28
- id: string;
29
- routes: readonly AppRoute[];
30
- egress?: readonly string[];
31
- }>;
32
- /** サーバーの側の宣言(コレクションの確認だけ) */
33
- export declare const defineAppServer: (manifest: AppServer) => AppServer;
34
- /** 宛先の宣言に URL が当たるか(https だけ、ポートの指定なし) */
27
+ /** 外への読み込みの宛先の宣言に URL が当たるか(宣言は https のオリジン、ホスト名の先頭の `*.` は1つ以上の区間。https だけ、ポートの指定なし) */
35
28
  export declare function egressAllows(declared: readonly string[], url: URL): boolean;
@@ -0,0 +1,127 @@
1
+ import type { Collection } from '../../schema/src/index.js';
2
+ import type { AppManifest, AppScreen, ConnectionPoint, PermissionTarget } from './apps.js';
3
+ import type { AppSettingDef } from './appDependencies.js';
4
+ import type { TargetMessages } from './errorLabels.js';
5
+ /** 導入先に入れたアプリ(キーはアプリの id、値はアプリの設定値) */
6
+ export type AppSettingsInput = Readonly<Record<string, Readonly<Record<string, unknown>>>>;
7
+ type SettingsRecord = Readonly<Record<string, unknown>>;
8
+ /** 設定値の項目の値(key はドットで区切った道、例: art.enabled) */
9
+ export declare function settingAt(settings: SettingsRecord, key: string): unknown;
10
+ /** 設定値の項目を置き換えた設定値(key はドットで区切った道、途中の節がなければ作る) */
11
+ export declare function withSettingAt(settings: SettingsRecord, key: string, value: unknown): SettingsRecord;
12
+ /** 導入先の指定に保存した値を重ねた設定値(節は節ごとに重ね、一覧と値は置き換え) */
13
+ export declare function mergedSettings(base: SettingsRecord, stored: SettingsRecord): SettingsRecord;
14
+ /** 設定値の解釈(S はアプリの設定値。メソッドの形で引数を双変にし、AppDefinition<unknown> の一覧に入れられるように) */
15
+ export type AppSettings<S> = Readonly<{
16
+ /** 導入先の指定・画面で保存した値からアプリの設定値(不正な値は SettingProblem の例外) */
17
+ parse(input: Readonly<Record<string, unknown>>): S;
18
+ }>;
19
+ /** コードを持つアプリの定義(id はアプリの名前、manifest は宣言) */
20
+ export type AppDefinition<S = Readonly<Record<string, never>>> = Readonly<{
21
+ id: string;
22
+ manifest: AppManifest;
23
+ settings: AppSettings<S>;
24
+ }>;
25
+ /** 設定値のないアプリの設定値の解釈 */
26
+ export declare const NO_SETTINGS: AppSettings<Readonly<Record<string, never>>>;
27
+ /** アプリの宣言の一覧の部分(アプリの画面に使用) */
28
+ export type AppAbout = Readonly<{
29
+ description: string;
30
+ permissions: readonly PermissionTarget[];
31
+ connections: readonly ConnectionPoint[];
32
+ settings: readonly AppSettingDef[];
33
+ }>;
34
+ /** 各側の create の引数(site は導入先の設定値) */
35
+ export type AppSetupContext<S> = Readonly<{
36
+ settings: S;
37
+ site: Readonly<{
38
+ id: string;
39
+ name: string;
40
+ origin: string;
41
+ timeZone: string;
42
+ }>;
43
+ }>;
44
+ /** 各側のアプリ(P は側ごとの内容、create は組み立ての時点で1回) */
45
+ export type AppSide<S, P> = Readonly<{
46
+ app: AppDefinition<S>;
47
+ create(ctx: AppSetupContext<S>): P;
48
+ }>;
49
+ /** 組み立てたアプリの共通の部分 */
50
+ export type AppBase = Readonly<{
51
+ id: string;
52
+ label: string;
53
+ targets: Readonly<Record<string, string>>;
54
+ auditActions: Readonly<Record<string, string>>;
55
+ problems: Readonly<Record<string, string>>;
56
+ en: Readonly<{
57
+ targets: Readonly<Record<string, string>>;
58
+ problems: Readonly<Record<string, string>>;
59
+ }>;
60
+ about: AppAbout;
61
+ messages: TargetMessages;
62
+ emits: Readonly<Record<string, string>>;
63
+ screens: readonly AppScreen[];
64
+ }>;
65
+ /** 組み立てたアプリ(共通の定義と、側ごとの内容) */
66
+ export type AppInstance<P> = AppBase & P;
67
+ /** 定義から組み立てたアプリの共通の部分 */
68
+ export declare function appBaseOf(app: AppDefinition<unknown>): AppBase;
69
+ /** MCP の側から CMS の API の呼び出し(パスと JSON の本文、応答は JSON) */
70
+ export type CallApi = (method: string, path: string, body?: unknown) => Promise<{
71
+ status: number;
72
+ data: unknown;
73
+ }>;
74
+ /** MCP のツール */
75
+ export type McpTool = {
76
+ name: string;
77
+ description: string;
78
+ inputSchema: Record<string, unknown>;
79
+ /** クライアント向けの付加情報(ChatGPT の openai/fileParams など) */
80
+ _meta?: Record<string, unknown>;
81
+ run: (args: Record<string, unknown>, api: CallApi) => Promise<{
82
+ status: number;
83
+ data: unknown;
84
+ }>;
85
+ };
86
+ /** MCP のプロンプトと案内の文の材料(projectName はプロジェクトの名前、primary は MCP で書くコレクション) */
87
+ export type McpProjectContext = Readonly<{
88
+ projectName: string;
89
+ primary: Collection;
90
+ }>;
91
+ /** MCP のプロンプト(name と arguments の名前はクライアントが保存するため変えない) */
92
+ export type McpPrompt = Readonly<{
93
+ name: string;
94
+ title: (ctx: McpProjectContext) => string;
95
+ description: (ctx: McpProjectContext) => string;
96
+ arguments: readonly Readonly<{
97
+ name: string;
98
+ description: string;
99
+ required: boolean;
100
+ }>[];
101
+ text: (ctx: McpProjectContext, args: Readonly<Record<string, string>>) => string;
102
+ }>;
103
+ /** MCP の側の内容(instructions は initialize の案内に足す文) */
104
+ export type McpParts = Readonly<{
105
+ tools?: readonly McpTool[];
106
+ prompts?: readonly McpPrompt[];
107
+ instructions?: (ctx: McpProjectContext) => string;
108
+ }>;
109
+ /** MCP の側のアプリ */
110
+ export type McpApp<S = unknown> = AppSide<S, McpParts>;
111
+ /**
112
+ * 登録した側のアプリを導入先の設定で組み立て
113
+ * - 登録は導入先の設定 apps にある id だけ(ない id・重複は例外)
114
+ * - complete: 設定にある id がすべて登録されているか(サーバーの側、DB と migration を持つため)
115
+ */
116
+ export declare function createApps<P>(registered: readonly AppSide<unknown, P>[], config: Readonly<{
117
+ settings: AppSetupContext<unknown>['site'];
118
+ apps?: AppSettingsInput;
119
+ }>, options?: Readonly<{
120
+ complete?: boolean;
121
+ }>): AppInstance<P>[];
122
+ /** アプリの対象の表示名をまとめた表(キーの重複は例外) */
123
+ export declare function appTargetsOf(apps: readonly Readonly<{
124
+ id: string;
125
+ targets: Readonly<Record<string, string>>;
126
+ }>[], core: Readonly<Record<string, string>>): Readonly<Record<string, string>>;
127
+ export {};
@@ -1,4 +1,4 @@
1
- import { type FieldDef, type SchemaChange } from '../../model/src/index.js';
1
+ import { type FieldDef, type SchemaChange } from '../../schema/src/index.js';
2
2
  import { z } from 'zod';
3
3
  /** ポートの id(`<発行者>:<名前>@<世代>`、例 tunasand:message@1) */
4
4
  export type PortId = `${string}:${string}@${number}`;
@@ -36,7 +36,7 @@ export type AppCollection = Readonly<{
36
36
  private?: boolean;
37
37
  fields: readonly FieldDef[];
38
38
  }>;
39
- /** アプリの設定(requires は設定を使うのに要る任意の依存のアプリの id) */
39
+ /** アプリの設定(key はドットで区切ると節の中の項目、requires は設定を使うのに要る任意の依存のアプリの id、min・unit は number の下限と単位) */
40
40
  export type AppSettingDef = Readonly<{
41
41
  key: string;
42
42
  label: string;
@@ -44,6 +44,8 @@ export type AppSettingDef = Readonly<{
44
44
  options?: readonly string[];
45
45
  default?: AppSettingValue;
46
46
  requires?: string;
47
+ min?: number;
48
+ unit?: string;
47
49
  }>;
48
50
  /** 値段(円、usage は従量の説明の文) */
49
51
  export type AppPrice = Readonly<{
@@ -74,17 +76,6 @@ export declare const DEFAULT_APP_MAJOR = 1;
74
76
  export declare const IMPORTER_FIELD_PREFIX = "x_";
75
77
  /** アプリのフィールドに使えない key(予約の key の凍結の一覧。slug はスラッグの導入で予約に入る) */
76
78
  export declare const APP_RESERVED_FIELD_KEYS: readonly string[];
77
- /**
78
- * 最初から入っている自社のアプリの登録簿の識別子(台帳の基準の版 0000_baseline.sql の apps の行と同じ値、Q7)
79
- * - コードはコアと一緒にデプロイされ、全部のプロジェクトで同時に変わる。インストールの行を持たず、計画ではいつも keep
80
- */
81
- export declare const BUILTIN_APP_IDS: {
82
- readonly forms: "01a1e1a7-4c00-7f02-9b4a-2e8c7d6a5f02";
83
- readonly line: "01a1e1a7-4c00-7e13-a6c2-91b0f3d4e803";
84
- readonly newsletter: "01a1e1a7-4c00-7b24-b7d1-0a5e6c8f9d04";
85
- };
86
- /** 自社のアプリか */
87
- export declare const isBuiltinApp: (appId: string) => boolean;
88
79
  /** 依存の宣言の形(zod。マニフェストのほかの項目は apps.ts の appManifestProblems が見る) */
89
80
  export declare const appDependencyManifestSchema: z.ZodObject<{
90
81
  major: z.ZodOptional<z.ZodNumber>;
@@ -126,6 +117,8 @@ export declare const appDependencyManifestSchema: z.ZodObject<{
126
117
  options: z.ZodOptional<z.ZodArray<z.ZodString>>;
127
118
  default: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString, z.ZodNumber]>>;
128
119
  requires: z.ZodOptional<z.ZodString>;
120
+ min: z.ZodOptional<z.ZodNumber>;
121
+ unit: z.ZodOptional<z.ZodString>;
129
122
  }, z.core.$strict>>>;
130
123
  price: z.ZodOptional<z.ZodObject<{
131
124
  setup: z.ZodOptional<z.ZodNumber>;