@tunasand/sdk 0.0.0-stage → 0.7.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 (169) hide show
  1. package/CHANGELOG.md +114 -0
  2. package/README.md +516 -2
  3. package/dist/analytics.d.ts +1 -0
  4. package/dist/analytics.js +43 -0
  5. package/dist/app.d.ts +1 -0
  6. package/dist/app.js +825 -0
  7. package/dist/apps-9u4XMi7E.js +114 -0
  8. package/dist/body.d.ts +1 -0
  9. package/dist/body.js +455 -0
  10. package/dist/bridge-DYAYGV7t.js +74 -0
  11. package/dist/bridge.d.ts +1 -0
  12. package/dist/bridge.js +189 -0
  13. package/dist/cli.d.ts +1 -0
  14. package/dist/cli.js +283 -0
  15. package/dist/client-Derrexwr.js +159 -0
  16. package/dist/customers-C_vJY2_v.js +84 -0
  17. package/dist/customers.d.ts +1 -0
  18. package/dist/customers.js +185 -0
  19. package/dist/declared-C_GvPiGF.js +397 -0
  20. package/dist/delivery.d.ts +1 -0
  21. package/dist/delivery.js +394 -0
  22. package/dist/dev.d.ts +1 -0
  23. package/dist/dev.js +93 -0
  24. package/dist/embed-R-OvDYAw.js +90 -0
  25. package/dist/errorLabels-CPKiPabZ.js +1510 -0
  26. package/dist/i18n.d.ts +1 -0
  27. package/dist/i18n.js +4 -0
  28. package/dist/integrations.d.ts +1 -0
  29. package/dist/integrations.js +62 -0
  30. package/dist/ja-C1HEWWTQ.js +241 -0
  31. package/dist/ja-C6lX0CeJ.js +213 -0
  32. package/dist/model-pmXzGX12.js +152 -0
  33. package/dist/model.d.ts +1 -0
  34. package/dist/model.js +345 -0
  35. package/dist/page-E_cYgZx-.js +138 -0
  36. package/dist/preview.d.ts +1 -0
  37. package/dist/preview.js +1 -0
  38. package/dist/profile-D6t1QMQh.js +223 -0
  39. package/dist/schema-BPHL7Qr-.js +115 -0
  40. package/dist/schema-UQJWRyfJ.js +995 -0
  41. package/dist/schema.d.ts +1 -0
  42. package/dist/schema.js +1 -0
  43. package/dist/src-sazhzYui.js +71 -0
  44. package/dist/types/access/src/handoff.d.ts +52 -0
  45. package/dist/types/access/src/index.d.ts +5 -0
  46. package/dist/types/access/src/jws.d.ts +5 -0
  47. package/dist/types/access/src/jwt.d.ts +35 -0
  48. package/dist/types/access/src/oidc.d.ts +50 -0
  49. package/dist/types/access/src/signed.d.ts +15 -0
  50. package/dist/types/analytics/src/day.d.ts +2 -0
  51. package/dist/types/analytics/src/index.d.ts +5 -0
  52. package/dist/types/analytics/src/schedule.d.ts +2 -0
  53. package/dist/types/analytics/src/shared.d.ts +21 -0
  54. package/dist/types/analytics/src/source.d.ts +19 -0
  55. package/dist/types/analytics/src/store.d.ts +24 -0
  56. package/dist/types/analytics/src/view.d.ts +33 -0
  57. package/dist/types/body/src/components.d.ts +25 -0
  58. package/dist/types/body/src/declared.d.ts +34 -0
  59. package/dist/types/body/src/derive.d.ts +13 -0
  60. package/dist/types/body/src/description.d.ts +8 -0
  61. package/dist/types/body/src/embed.d.ts +16 -0
  62. package/dist/types/body/src/href.d.ts +4 -0
  63. package/dist/types/body/src/html.d.ts +30 -0
  64. package/dist/types/body/src/index.d.ts +19 -0
  65. package/dist/types/body/src/inline.d.ts +20 -0
  66. package/dist/types/body/src/labels/en.d.ts +90 -0
  67. package/dist/types/body/src/labels/ja.d.ts +153 -0
  68. package/dist/types/body/src/library.d.ts +113 -0
  69. package/dist/types/body/src/markdown.d.ts +14 -0
  70. package/dist/types/body/src/normalize.d.ts +5 -0
  71. package/dist/types/body/src/problems.d.ts +103 -0
  72. package/dist/types/body/src/profile.d.ts +80 -0
  73. package/dist/types/body/src/render.d.ts +29 -0
  74. package/dist/types/body/src/schema.d.ts +6 -0
  75. package/dist/types/body/src/standard.d.ts +20 -0
  76. package/dist/types/body/src/types.d.ts +140 -0
  77. package/dist/types/cms-contract/src/apiKeys.d.ts +41 -0
  78. package/dist/types/cms-contract/src/app.d.ts +35 -0
  79. package/dist/types/cms-contract/src/appDependencies.d.ts +265 -0
  80. package/dist/types/cms-contract/src/appProblems.d.ts +22 -0
  81. package/dist/types/cms-contract/src/apps.d.ts +195 -0
  82. package/dist/types/cms-contract/src/assets.d.ts +12 -0
  83. package/dist/types/cms-contract/src/authorize.d.ts +146 -0
  84. package/dist/types/cms-contract/src/bridge.d.ts +318 -0
  85. package/dist/types/cms-contract/src/consents.d.ts +97 -0
  86. package/dist/types/cms-contract/src/customerLabels.d.ts +33 -0
  87. package/dist/types/cms-contract/src/customers.d.ts +266 -0
  88. package/dist/types/cms-contract/src/embeds.d.ts +165 -0
  89. package/dist/types/cms-contract/src/errorLabels.d.ts +269 -0
  90. package/dist/types/cms-contract/src/errorLabelsEn.d.ts +228 -0
  91. package/dist/types/cms-contract/src/errors.d.ts +105 -0
  92. package/dist/types/cms-contract/src/failureStatus.d.ts +124 -0
  93. package/dist/types/cms-contract/src/functionLabels.d.ts +5 -0
  94. package/dist/types/cms-contract/src/functions.d.ts +144 -0
  95. package/dist/types/cms-contract/src/identifiers.d.ts +117 -0
  96. package/dist/types/cms-contract/src/import.d.ts +277 -0
  97. package/dist/types/cms-contract/src/issueLabels.d.ts +435 -0
  98. package/dist/types/cms-contract/src/issueLabelsEn.d.ts +217 -0
  99. package/dist/types/cms-contract/src/migration.d.ts +103 -0
  100. package/dist/types/cms-contract/src/paths.d.ts +23 -0
  101. package/dist/types/cms-contract/src/permissionLabels.d.ts +8 -0
  102. package/dist/types/cms-contract/src/permissions.d.ts +77 -0
  103. package/dist/types/cms-contract/src/problems.d.ts +34 -0
  104. package/dist/types/cms-contract/src/roles.d.ts +57 -0
  105. package/dist/types/cms-contract/src/settingProblems.d.ts +13 -0
  106. package/dist/types/cms-contract/src/settings.d.ts +19 -0
  107. package/dist/types/cms-contract/src/siteArtifact.d.ts +45 -0
  108. package/dist/types/cms-contract/src/siteDeclaration.d.ts +70 -0
  109. package/dist/types/cms-contract/src/transfer.d.ts +57 -0
  110. package/dist/types/cms-contract/src/urlLabel.d.ts +13 -0
  111. package/dist/types/cms-contract/src/views.d.ts +21 -0
  112. package/dist/types/cms-contract/src/webhookLabels.d.ts +7 -0
  113. package/dist/types/cms-contract/src/webhooks.d.ts +139 -0
  114. package/dist/types/i18n/src/index.d.ts +50 -0
  115. package/dist/types/i18n/src/problems.d.ts +21 -0
  116. package/dist/types/model/src/asset.d.ts +111 -0
  117. package/dist/types/model/src/audience.d.ts +38 -0
  118. package/dist/types/model/src/brand.d.ts +25 -0
  119. package/dist/types/model/src/capabilities.d.ts +28 -0
  120. package/dist/types/model/src/changes.d.ts +34 -0
  121. package/dist/types/model/src/check.d.ts +15 -0
  122. package/dist/types/model/src/contact.d.ts +22 -0
  123. package/dist/types/model/src/image.d.ts +38 -0
  124. package/dist/types/model/src/index.d.ts +26 -0
  125. package/dist/types/model/src/input.d.ts +26 -0
  126. package/dist/types/model/src/integrity.d.ts +79 -0
  127. package/dist/types/model/src/json.d.ts +2 -0
  128. package/dist/types/model/src/labels/en.d.ts +169 -0
  129. package/dist/types/model/src/labels/ja.d.ts +198 -0
  130. package/dist/types/model/src/legacy.d.ts +2 -0
  131. package/dist/types/model/src/media.d.ts +5 -0
  132. package/dist/types/model/src/mediaUrl.d.ts +67 -0
  133. package/dist/types/model/src/model.d.ts +415 -0
  134. package/dist/types/model/src/page.d.ts +52 -0
  135. package/dist/types/model/src/problems.d.ts +184 -0
  136. package/dist/types/model/src/refs.d.ts +27 -0
  137. package/dist/types/model/src/rules.d.ts +15 -0
  138. package/dist/types/model/src/schema.d.ts +58 -0
  139. package/dist/types/model/src/screens.d.ts +76 -0
  140. package/dist/types/model/src/selfOps.d.ts +30 -0
  141. package/dist/types/model/src/time.d.ts +25 -0
  142. package/dist/types/model/src/typesSource.d.ts +8 -0
  143. package/dist/types/model/src/values.d.ts +24 -0
  144. package/dist/types/platform/src/defaultModel.d.ts +8 -0
  145. package/dist/types/sdk/src/analytics.d.ts +2 -0
  146. package/dist/types/sdk/src/app.d.ts +20 -0
  147. package/dist/types/sdk/src/body.d.ts +2 -0
  148. package/dist/types/sdk/src/bridge.d.ts +92 -0
  149. package/dist/types/sdk/src/cli.d.ts +2 -0
  150. package/dist/types/sdk/src/customers.d.ts +190 -0
  151. package/dist/types/sdk/src/delivery/cache.d.ts +18 -0
  152. package/dist/types/sdk/src/delivery/changes.d.ts +28 -0
  153. package/dist/types/sdk/src/delivery/client.d.ts +90 -0
  154. package/dist/types/sdk/src/delivery/fields.d.ts +48 -0
  155. package/dist/types/sdk/src/delivery/index.d.ts +9 -0
  156. package/dist/types/sdk/src/delivery/media.d.ts +28 -0
  157. package/dist/types/sdk/src/delivery/query.d.ts +85 -0
  158. package/dist/types/sdk/src/delivery/schema.d.ts +19 -0
  159. package/dist/types/sdk/src/delivery/values.d.ts +82 -0
  160. package/dist/types/sdk/src/delivery.d.ts +3 -0
  161. package/dist/types/sdk/src/dev.d.ts +29 -0
  162. package/dist/types/sdk/src/i18n.d.ts +12 -0
  163. package/dist/types/sdk/src/integrations.d.ts +33 -0
  164. package/dist/types/sdk/src/model.d.ts +5 -0
  165. package/dist/types/sdk/src/preview.d.ts +1 -0
  166. package/dist/types/sdk/src/schema.d.ts +21 -0
  167. package/dist/types/sdk/src/site.d.ts +43 -0
  168. package/dist/typesSource-bO0jFw1I.js +88 -0
  169. package/package.json +86 -3
@@ -0,0 +1,15 @@
1
+ import type { DeclaredComponent } from '../../body/src/index.js';
2
+ import type { Collection, FieldDef, FieldProblem } from './model.js';
3
+ /** 項目が値の組に当てはまるか(条件なしは常に当てはまる、values は同じ階層の値) */
4
+ export declare const appliesTo: (field: FieldDef, values: Readonly<Record<string, unknown>>) => boolean;
5
+ /** 値の組に当てはまる項目だけ */
6
+ export declare const fieldsFor: <F extends FieldDef>(fields: readonly F[], values: Readonly<Record<string, unknown>>) => F[];
7
+ /** 値をコレクションの定義で検査(stage は保存か提出、提出は保存の必須も含む、まとまりの中は path を key・行の番号で連結、components はスキーマで宣言した本文の部品) */
8
+ export declare const checkFields: (collection: Collection, values: Readonly<Record<string, unknown>>, stage: "save" | "submit", components?: readonly DeclaredComponent[]) => FieldProblem[];
9
+ /** 配列でないオブジェクトか */
10
+ export declare const isRecord: (v: unknown) => v is Readonly<Record<string, unknown>>;
11
+ /**
12
+ * 値の形だけの検査(項目の種類ごとの JSON の形と長さの上限、keys は対象の最上位の項目の key)
13
+ * - 見ないもの: 必須、条件 when、選択肢、形式 pattern、下限、範囲(保存の差に当てる規則の側)
14
+ */
15
+ export declare function shapeProblems(collection: Collection, values: Readonly<Record<string, unknown>>, keys: ReadonlySet<string>): FieldProblem[];
@@ -0,0 +1,22 @@
1
+ /** 電話番号の国と国番号(国内の番号は先頭の0を国番号に替える) */
2
+ export declare const PHONE_REGIONS: {
3
+ readonly JP: "81";
4
+ readonly KR: "82";
5
+ readonly TW: "886";
6
+ readonly CN: "86";
7
+ readonly GB: "44";
8
+ };
9
+ export type PhoneRegion = keyof typeof PHONE_REGIONS;
10
+ export declare const PHONE_REGION_IDS: [PhoneRegion, ...PhoneRegion[]];
11
+ export declare const DEFAULT_PHONE_REGION: PhoneRegion;
12
+ /** URL の項目が受け付ける scheme */
13
+ export declare const URL_SCHEMES: readonly ["https", "http"];
14
+ export type UrlScheme = (typeof URL_SCHEMES)[number];
15
+ /** 入力の電話番号を E.164 に(+ で始まれば国番号つき、ほかは region の国内の番号。全角は半角に読む。読めなければ null) */
16
+ export declare function phoneE164Of(input: string, region?: PhoneRegion): string | null;
17
+ /** E.164 の番号を region の国内の形に(ほかの国の番号と E.164 でない値はそのまま) */
18
+ export declare function phoneNationalOf(value: string, region?: PhoneRegion): string;
19
+ /** メールアドレスの形(@ とドメイン、保存は小文字) */
20
+ export declare const isEmailText: (v: string) => boolean;
21
+ /** URL として読めて scheme が schemes にあるか */
22
+ export declare function isUrlText(v: string, schemes?: readonly UrlScheme[]): boolean;
@@ -0,0 +1,38 @@
1
+ import type { Crop, Hotspot, Media } from './asset.js';
2
+ /** 静止画として表示する画像(動画は代わりの画像 poster) */
3
+ export declare const stillOf: (media: Media) => Readonly<{
4
+ src: string | import("./asset.js").LocalImage;
5
+ width: number;
6
+ height: number;
7
+ alt: string;
8
+ hotspot?: Hotspot;
9
+ }>;
10
+ /** 見せたい点を CSS の object-position に(なしは undefined で中央、枠の比が分からない表示の代わり) */
11
+ export declare const objectPosition: (hotspot?: Hotspot) => string | undefined;
12
+ /**
13
+ * 枠を覆う表示で、枠に見える範囲(窓)の始まりの位置: 1次元、画像に対する割合で0〜1 - window
14
+ * - 見せたい範囲の中心を窓の中央に寄せ、画像の端を越えるときは端と同じ位置
15
+ * - 範囲が窓に収まる大きさなら、この位置で範囲は必ず窓に入る(範囲が窓より大きいときは範囲の中央を表示)
16
+ * - center なしは中央、CMS のプレビュー(apps/admin の crop.ts)とサイトの表示で共通
17
+ */
18
+ export declare function coverStart(center: number | undefined, window: number): number;
19
+ /**
20
+ * 枠を覆う表示(object-fit: cover)の object-position: 見せたい範囲が枠に入る位置
21
+ * - size: 画像の幅と高さ、frame: 枠の幅 / 高さ(なしは見せたい点の百分率で代用)
22
+ * - 帯や余白はなし、枠いっぱいに画像を敷いたまま位置だけを合わせる
23
+ */
24
+ export declare function coverPosition(hotspot: Hotspot | undefined, size: Readonly<{
25
+ width: number;
26
+ height: number;
27
+ }>, frame?: number): string | undefined;
28
+ /** 切り抜いた範囲(元の画像の画素、左上と大きさ、1画素以上) */
29
+ export type CropRect = Readonly<{
30
+ left: number;
31
+ top: number;
32
+ width: number;
33
+ height: number;
34
+ }>;
35
+ /** 切り抜きの割合から、元画像での画素の範囲 */
36
+ export declare function cropRect(width: number, height: number, crop: Crop): CropRect;
37
+ /** 元の画像に対する見せたい点を、切り抜いた後の画像に対する割合に変換(範囲の外は端に寄せる) */
38
+ export declare function croppedHotspot(hotspot: Hotspot, crop: Crop): Hotspot;
@@ -0,0 +1,26 @@
1
+ export { BRAND_MARK, BRAND_NAME, BRAND_WORDMARK } from './brand.js';
2
+ export { fieldZod, jsonSchemaOf, normalizeValues, zodOf, type ValueOptions } from './input.js';
3
+ export { assetRefSchema, cropSchema, hotspotSchema, mediaSchema, type Asset, type AssetRef, type Crop, type DeliveredAsset, type Hotspot, type LocalImage, type Media } from './asset.js';
4
+ export { coverPosition, coverStart, cropRect, croppedHotspot, objectPosition, stillOf, type CropRect } from './image.js';
5
+ export { IMAGE_TYPE, VIDEO_TYPE } from './media.js';
6
+ export { IMAGE_SIZE_MAX, imageParamsOf, isMediaId, MEDIA_SIGNING_KEY_BLOB, MEDIA_SIGNING_KEY_SPOT, mediaBlobKeyOf, mediaExtOf, mediaKindOf, mediaMimeOf, mediaPathOf, parseMediaPath, signMediaUrl, verifyMediaUrl, withImageParams, type ImageParams, type AssetKind, type MediaPath } from './mediaUrl.js';
7
+ export { diffSchema, type ChangeKind, type ChangeLevel, type DiffOptions, type SchemaChange } from './changes.js';
8
+ export { dateRoleFieldsOf, primaryCollectionOf, requiredPrimaryCollectionOf, SOURCES_FIELD, sourceIdsOf, sourcesFieldOf, sourceCollectionOf, type SourcesField } from './capabilities.js';
9
+ export { appliesTo, checkFields, fieldsFor, shapeProblems } from './check.js';
10
+ export { deliveredFields, emptyValues, pickValues, referencedIds, referencesOf, valueFieldsOf } from './values.js';
11
+ export { typesSourceOf } from './typesSource.js';
12
+ export { mapReferences, recordRefsOf, type RecordRef, referencedIdsOf, referenceInputOf, type ReferenceValue, renameRecordRefs } from './refs.js';
13
+ export { sameJson } from './json.js';
14
+ export { isSelfField, isSelfRow, ownerFieldOf, type SelfWrite, selfFieldsOf, selfWritableKeysOf, selfWritableOf, selfWritableProblems, type CustomerOperation, selfOpsOf, selfOpsProblems, type CustomerProof, surveyInputField } from './selfOps.js';
15
+ export { ledgerAdditions, resolvedModel, type AudienceLedgerEntry } from './audience.js';
16
+ export { acceptsRole, addedFieldAudienceOf, defaultPiiOf, fieldPiiOf, isPersonalCollection, isCustomerLinkedCollection, PII_CLASSES, PII_STRENGTH, type PiiClass, anonymizedKeysOf, audienceOf, withoutAudience, declaredAudienceOf, innerAudienceOf, AUDIENCES, type Audience, bodyFieldsOf, cascadeDepths, type CascadeCollection, ON_DELETE, onDeleteOf, type OnDelete, type CustomerOnDelete, grantedKeysOf, isDeliveredAudience, computedFieldsOf, FIELD_ROLES, hasCustomerRules, editsSlug, SLUG_MODES, type SlugMode, initialValueOf, isPublishable, isInputField, isSequenceField, isListCollection, isDeliveredCollection, isMediaCollection, isPrivateCollection, isSingleton, isStoredCollection, isUndeliveredField, MEDIA_COLLECTION_IDS, CUSTOMER_FIELD_TYPE, SELF_OPS, type SelfOp, customerFieldsOf, type CustomerField, type ReferenceField, optionLabelOf, optionsOf, publishingOf, requestReferencesOf, resolvedRolesOf, roleFieldOf, toneOf, collectionOf, collectionByRef, isUuidShape, type ComputedKind, type FieldRole, type FieldRoles, type FieldComputed, type ContentFormat, type ContentModel, type Collection, type ResolvedModel, type FieldCondition, type FieldDef, type FieldDerive, type FieldFixedBy, type CountDef, type FieldProblem, type MediaKind, type OptionTone, type Publishing, type ReferenceRules, type SelectOption, usesReview } from './model.js';
17
+ export { hasPublicPage, imageFrameOf, pagePathOf, publicPathOf, withPagesFrom, type ImageFrame, type ImageFrameDef, type PageDef, type PageRecord, type PageRule } from './page.js';
18
+ export { schemaRulesOf, type SchemaRule } from './rules.js';
19
+ export { acceptsUnique, hasTransitions, integrityProblems, transitionAllowed, transitionFieldsOf, transitionProblems, transitionTargets, type Transition, type TransitionActor, type TransitionActors, type TransitionField, sequenceFieldsOf, UNIQUE_FIELDS_MAX, UNIQUE_NORMALIZATION_VERSION, uniqueDefsOf, uniquePartOf, uniqueDuplicatesOf, uniquesColumnOf, uniqueValueOf, type UniqueDef, type UniqueDuplicate } from './integrity.js';
20
+ export { fieldDefSchema, MAX_CASCADE_DEPTH, parseModel, RESERVED_FIELD_KEYS, RETENTION_DAYS_MAX, retentionProblems, ruleIssues, undeclaredDeleteProblems, validateModelForSave } from './schema.js';
21
+ export { MENU_GROUP_ID, menuItemsOf, parseScreens, placedItemsOf, resolveLayout, resolveMenu, embedItem, collectionItem, collectionOfItem, viewItem, viewOfItem, type EditorLayout, type EditorSection, type MenuEntry, type MenuGroup, type ResolvedMenuEntry, type ScreenSettings } from './screens.js';
22
+ export { createClock, isDateOnly, isDateTimeText, type Clock, type DateString } from './time.js';
23
+ export { phoneNationalOf, type PhoneRegion, type UrlScheme } from './contact.js';
24
+ export { AUDIENCE_LABELS, MODEL_PROBLEM_MESSAGES } from './labels/ja.js';
25
+ export { MODEL_PROBLEM_MESSAGES_EN } from './labels/en.js';
26
+ export { type ModelProblemCode, modelProblemText } from './problems.js';
@@ -0,0 +1,26 @@
1
+ import { type DeclaredComponent } from '../../body/src/index.js';
2
+ import { z } from 'zod';
3
+ import type { FieldDef } from './model.js';
4
+ /** 検査の時点(保存か提出、提出は保存の必須も含む) */
5
+ type Stage = 'save' | 'submit';
6
+ /** 値の検査の設定(toDateTime は日時の変換で、プロジェクトのタイムゾーンを持つ側が指定、components はスキーマで宣言した本文の部品) */
7
+ export type ValueOptions = Readonly<{
8
+ toDateTime?: (value: string) => string | null;
9
+ components?: readonly DeclaredComponent[];
10
+ }>;
11
+ /** MCP のツールで入力する1項目の JSON Schema */
12
+ type JsonSchema = Readonly<Record<string, unknown>>;
13
+ /** 1項目の定義から入力の検査を作成(stage が save なら提出の必須は任意、options は日時の変換) */
14
+ export declare function fieldZod(field: FieldDef, stage: Stage, options?: ValueOptions): z.ZodType;
15
+ /** 項目の一覧から入力の検査を作成(key ごとに fieldZod を持つ object) */
16
+ export declare const zodOf: (fields: readonly FieldDef[], stage: Stage, options?: ValueOptions) => z.ZodObject<Record<string, z.ZodType>>;
17
+ /**
18
+ * 値を保存の形に整形(すべての格納先で共通、まとまりの中も)
19
+ * - 日時: `ISO 8601` の UTC(options の toDateTime)、本文: 注の記法の変換と未知のキーの除去、メディア: { asset } だけ
20
+ * - 形の誤りのある値: そのまま(checkFields が検出)
21
+ * - 定義にないキー・項目を定義しないまとまり: そのまま
22
+ */
23
+ export declare function normalizeValues(fields: readonly FieldDef[], values: Readonly<Record<string, unknown>>, options: ValueOptions): Record<string, unknown>;
24
+ /** 項目の定義から MCP のツールで入力する JSON Schema を作成(説明は表示名・説明・必須の時点、参照は ID の文字列) */
25
+ export declare function jsonSchemaOf(field: FieldDef): JsonSchema;
26
+ export {};
@@ -0,0 +1,79 @@
1
+ import { type Collection, type FieldDef } from './model.js';
2
+ /** 一意の組(key は組の名前で、コレクションの中で項目の key と同じ文字の規則、exact は文字を表記の揺れで揃えない) */
3
+ export type UniqueDef = Readonly<{
4
+ key: string;
5
+ fields: readonly string[];
6
+ exact?: boolean;
7
+ }>;
8
+ /** 1つの組に含められる項目の数 */
9
+ export declare const UNIQUE_FIELDS_MAX = 3;
10
+ /** 一意の組に含められる項目か(最上位・単数・入力する項目で、値を文字にできる種類) */
11
+ export declare function acceptsUnique(f: FieldDef): boolean;
12
+ /** コレクションの一意の組(宣言 unique と、unique を付けた顧客フィールドと、連番の項目) */
13
+ export declare const uniqueDefsOf: (collection: Collection) => UniqueDef[];
14
+ /** 一意の比較の値の規則(uniquePartOf)の版。規則を変えたら上げる(一意の組の索引の名前が変わり、列 uniques を補充し直す) */
15
+ export declare const UNIQUE_NORMALIZATION_VERSION = 1;
16
+ /** 一意の比較に使う値(空は null、exact は文字を表記の揺れで揃えない、日時は UTC の ISO に揃える) */
17
+ export declare function uniquePartOf(f: FieldDef, v: unknown, exact?: boolean): string | null;
18
+ /** 組の値(項目の1つでも空なら null、複数の項目は JSON の配列) */
19
+ export declare function uniqueValueOf(collection: Collection, def: UniqueDef, values: Readonly<Record<string, unknown>>): string | null;
20
+ /** 表 records の列 uniques の値(組の名前と値の JSON、一意の組がないか値がすべて空なら null) */
21
+ export declare function uniquesColumnOf(collection: Collection, values: Readonly<Record<string, unknown>>): string | null;
22
+ /** コレクションの連番の項目(最上位) */
23
+ export declare const sequenceFieldsOf: (collection: Collection) => FieldDef[];
24
+ /** コレクションの整合の宣言の誤り(スキーマの検査、schema.ts) */
25
+ export declare function integrityProblems(collection: Collection): string[];
26
+ /** 一意の組で値が重なるレコード(key は組の名前、ids は重なるレコードの ID) */
27
+ export type UniqueDuplicate = Readonly<{
28
+ collection: string;
29
+ key: string;
30
+ ids: readonly string[];
31
+ }>;
32
+ /** コレクションのレコードのうち、一意の組で値が重なるレコード(rows はレコードの ID と項目の値) */
33
+ export declare function uniqueDuplicatesOf(collection: Collection, rows: readonly Readonly<{
34
+ id: string;
35
+ values: Readonly<Record<string, unknown>>;
36
+ }>[]): UniqueDuplicate[];
37
+ /** 遷移を移せる者 */
38
+ export type TransitionActors = Readonly<{
39
+ roles?: readonly string[];
40
+ self?: boolean;
41
+ apps?: readonly string[];
42
+ }>;
43
+ /** 1つの遷移(from の null は作成) */
44
+ export type Transition = Readonly<{
45
+ from: readonly (string | null)[];
46
+ to: string;
47
+ by: TransitionActors;
48
+ }>;
49
+ /** 遷移を求める主体(self は保存するレコードの本人の人、app は登録簿のアプリの ID) */
50
+ export type TransitionActor = Readonly<{
51
+ kind: 'account';
52
+ role: string;
53
+ } | {
54
+ kind: 'self';
55
+ } | {
56
+ kind: 'app';
57
+ app: string;
58
+ } | {
59
+ kind: 'system';
60
+ }>;
61
+ /** 遷移の宣言を持つ項目 */
62
+ export type TransitionField = Extract<FieldDef, {
63
+ type: 'select';
64
+ }> & Readonly<{
65
+ transitions: readonly Transition[];
66
+ }>;
67
+ /** 遷移の宣言を持つ項目か */
68
+ export declare const hasTransitions: (f: FieldDef) => f is TransitionField;
69
+ /** コレクションの遷移の宣言を持つ項目(最上位) */
70
+ export declare const transitionFieldsOf: (collection: Collection) => TransitionField[];
71
+ /**
72
+ * 値 from から to への変更を actor に許すか(from の null は作成)
73
+ * - 変わらない値と主体 system は常に可。作成の初期値は主体によらず可(項目を持つレコードを作れる者が置く値)
74
+ */
75
+ export declare function transitionAllowed(field: TransitionField, from: string | null, to: string, actor: TransitionActor): boolean;
76
+ /** 値 from から actor が移れる先(画面とアプリの候補、from の null は作成) */
77
+ export declare function transitionTargets(field: TransitionField, from: string | null, actor: TransitionActor): string[];
78
+ /** 遷移の宣言の誤り(スキーマの検査) */
79
+ export declare function transitionProblems(collection: Collection): string[];
@@ -0,0 +1,2 @@
1
+ /** 2つの JSON の値が同じか(キーの順と undefined のキーを問わない) */
2
+ export declare const sameJson: (a: unknown, b: unknown) => boolean;
@@ -0,0 +1,169 @@
1
+ /** コンテンツスキーマの検査の問題の英語の文 */
2
+ export declare const MODEL_PROBLEM_MESSAGES_EN: {
3
+ readonly model_unreadable_input: "Cannot read the collection list types (each collection needs an id and an array of fields, groups also need an array of fields)";
4
+ readonly invalid_collection_id: "id must start with a lowercase letter and contain only lowercase letters, digits and underscores";
5
+ readonly invalid_field_key: "key must start with a lowercase letter and contain only letters, digits, underscores and hyphens";
6
+ readonly page_path_slash: "The page template must start with /";
7
+ readonly og_path_slash: "The OG image template must start with /";
8
+ readonly invalid_pattern: "The pattern is not a valid regular expression";
9
+ readonly initial_not_option: "The initial value is not one of the options";
10
+ readonly derive_not_option: "The derived value is not one of the options";
11
+ readonly fixed_not_option: "The fixed value is not one of the options";
12
+ readonly customer_restrict: "Customer fields cannot use restrict (it would block deletion requests from people)";
13
+ readonly entitlement_renamed: "The required entitlement of a collection was renamed to grant (entitlement is no longer accepted)";
14
+ readonly duplicate_field_key: "Duplicate field key";
15
+ readonly condition_invalid: "The field condition does not point to an option field and value at the same level";
16
+ readonly page_condition_invalid: "The page condition does not point to an option field and value of the collection";
17
+ readonly duplicate_collection_id: "Duplicate collection id";
18
+ readonly duplicate_collection_slug: "Duplicate collection slug";
19
+ readonly reserved_key: "Collection {collection}: key {key} is the same as a system value (use another key)";
20
+ readonly reserved_query_key: "Collection {collection}: key {key} is reserved for Delivery API filters (use another key)";
21
+ readonly nested_rule: "Collection {collection}, field {field}: fields inside a group cannot have derive or fixedBy";
22
+ readonly computed_nested: "Collection {collection}, field {field}: fields inside a group cannot be computed";
23
+ readonly computed_from_not_body: "Collection {collection}, field {field}: the computed source {from} is not a body field of the same collection";
24
+ readonly computed_type_mismatch: "Collection {collection}, field {field}: field type {type} does not match computed kind {kind}";
25
+ readonly role_field_not_top: "Collection {collection}, role {role}: field {field} is not at the top level";
26
+ readonly role_field_mismatch: "Collection {collection}, role {role}: field {field} ({type}) does not fit the role";
27
+ readonly audience_nested_wider: "Collection {collection}, field {field}: the audience inside a group must be the same as the outer field or staff";
28
+ readonly audience_customer_field: "Collection {collection}, field {field}: the audience of a customer field must be self or staff";
29
+ readonly audience_self_without_marker: "Collection {collection}: fields with the self audience need a customer field marked self";
30
+ readonly grant_not_reference: "Collection {collection}, required grant {grant}: not a top-level public access reference field";
31
+ readonly audience_wider_than_source: "Collection {collection}, field {field}: the audience cannot be wider than its {source, select, computed {computed} derive {derive} other {condition}} source {from} (the source value would leak)";
32
+ readonly template_id_placeholder: "Collection {collection}, template {template}: '{id}' is not allowed (use '{slug}')";
33
+ readonly template_private_placeholder: "Collection {collection}, template {template}, '{'{key}'}': only public fields (the value appears in delivery and page paths)";
34
+ readonly fixed_by_wider: "Collection {collection}, field {field}: the audience cannot be wider than the fixedBy source (the source value would leak)";
35
+ readonly count_reference_private: "Collection {collection}, reference count {key}: reference field {field} of collection {fromCollection} is not public (the count would leak values)";
36
+ readonly count_reference_mismatch: "Collection {collection}, reference count {key}: reference field {field} of collection {fromCollection} does not point to this collection";
37
+ readonly count_key_duplicate: "Collection {collection}: reference count {key} duplicates a field key";
38
+ readonly customer_field_nested: "Collection {collection}, field {field}: customer fields cannot be inside a group";
39
+ readonly on_delete_nested: "Collection {collection}, field {field}: references inside a group cannot have onDelete or anonymize";
40
+ readonly on_delete_required: "Collection {collection}, field {field}: required fields cannot use onDelete {onDelete}";
41
+ readonly on_delete_min_items: "Collection {collection}, field {field}: references with a minimum count cannot use onDelete {onDelete}";
42
+ readonly anonymize_without_on_delete: "Collection {collection}, field {field}: anonymize fields require onDelete anonymize";
43
+ readonly anonymize_field_missing: "Collection {collection}, field {field}: anonymize field {target} is not at the top level of the same collection";
44
+ readonly anonymize_field_unclearable: "Collection {collection}, field {field}: anonymize field {target} ({type}) cannot be cleared";
45
+ readonly anonymize_field_required: "Collection {collection}, field {field}: anonymize field {target} is required";
46
+ readonly cascade_cycle: "onDelete cascade forms a cycle: {cycle}";
47
+ readonly cascade_too_deep: "Collection {collection}: onDelete cascade depth from people {depth, number} exceeds the limit {max, number}";
48
+ readonly cascade_self_customer: "Collection {collection}, field {field}: collections reached by a reference cascade cannot have a self customer field (it would delete other people's records)";
49
+ readonly restrict_reachable: "Collection {collection}, field {field}: cannot restrict collection {to}, which is reachable from people by cascade (it would block deletion requests)";
50
+ readonly on_delete_undeclared_reference: "Collection {collection}, field {field}: references to collection {to}, which is reachable from people by cascade, must declare onDelete{nested, select, yes { (not possible inside a group, move it to the top level)} other {}}";
51
+ readonly private_object: "Collection {collection} is private: it cannot use the object format";
52
+ readonly private_publishing: "Collection {collection} is private: turn off publishing";
53
+ readonly private_pages: "Collection {collection} is private: it cannot have pages";
54
+ readonly private_grant: "Collection {collection} is private: it cannot require a grant";
55
+ readonly reference_target_missing: "Collection {collection}: reference target {to} is not in the schema";
56
+ readonly component_unknown: "Collection {collection}, body field {field}: component {name} is neither a core component nor declared in components";
57
+ readonly customer_on_delete_undeclared: "Collection {collection}, field {field}: customer fields must declare onDelete (cascade, anonymize or clear)";
58
+ readonly customer_in_object_collection: "Collection {collection}, field {field}: object collections cannot have customer fields (version history cannot be handled by deletion requests)";
59
+ readonly retention_days_undeclared: "Collection {collection}: collections with selfOps must declare retentionDays";
60
+ readonly audience_invalid: "Collection {collection}, field {field}: invalid audience (public, granted, self or staff)";
61
+ readonly audience_undeclared: "Collection {collection}, field {field}: declare audience for added or changed fields (public, granted, self or staff)";
62
+ readonly audience_undeclared_personal: "Collection {collection}, field {field}: fields added to a collection with customer fields must declare audience (public, granted, self or staff; staff for personal data)";
63
+ readonly unique_list_only: "Collection {collection}: unique constraints are only for list collections";
64
+ readonly unique_name_duplicate: "Collection {collection}: duplicate unique constraint name {key} (unique customer fields and sequences are named by the field key)";
65
+ readonly unique_field_count: "Collection {collection}, unique constraint {key}: 1 to {max, number} fields";
66
+ readonly unique_field_duplicate: "Collection {collection}, unique constraint {key}: duplicate field";
67
+ readonly unique_field_not_top: "Collection {collection}, unique constraint {key}: field {field} is not at the top level";
68
+ readonly unique_field_unsupported: "Collection {collection}, unique constraint {key}: field {field} ({type}) cannot be unique (single text, number, option, reference, date and customer fields only)";
69
+ readonly sequence_nested: "Collection {collection}, field {field}: sequences cannot be inside a group";
70
+ readonly sequence_list_only: "Collection {collection}, field {field}: sequences are only for list collections";
71
+ readonly sequence_plain: "Collection {collection}, field {field}: sequences cannot be required, computed or conditional (assigned on creation)";
72
+ readonly transition_nested: "Collection {collection}, field {field}: transitions cannot be inside a group";
73
+ readonly transition_field_kind: "Collection {collection}, field {field}: transitions are only for single option fields without derive or fixedBy";
74
+ readonly transition_to_not_option: "Collection {collection}, field {field}, transition {index, number}: target {to} is not one of the options";
75
+ readonly transition_from_empty: "Collection {collection}, field {field}, transition {index, number}: no source values";
76
+ readonly transition_from_not_option: "Collection {collection}, field {field}, transition {index, number}: source value {value} is not one of the options";
77
+ readonly transition_no_actor: "Collection {collection}, field {field}, transition {index, number}: no one can make the transition";
78
+ readonly self_ops_private_only: "Collection {collection}: selfOps are only for private collections (values written by people and self values are not delivered)";
79
+ readonly self_ops_list_only: "Collection {collection}: selfOps are only for list collections (object collections have a single record)";
80
+ readonly self_ops_unpublished: "Collection {collection}: collections with selfOps cannot have publishing or a published field (self records are shown regardless of publishing)";
81
+ readonly self_ops_one_self: "Collection {collection}: selfOps require exactly one self customer field";
82
+ readonly self_ops_on_delete: "Collection {collection}: the self customer field {field} of a selfOps collection must use onDelete cascade or anonymize (deletion requests must not keep self records)";
83
+ readonly self_ops_unique: "Collection {collection}: unique constraint {key} of a selfOps collection must include the self customer field {field} (to avoid conflicts with other people's values)";
84
+ readonly self_writable_nested: "Collection {collection}, field {field}: selfWritable cannot be set inside a group";
85
+ readonly self_writable_blocked: "Collection {collection}, field {field}: selfWritable cannot be set on {block, select, customer {customer fields} group {groups} media {media fields} rich_text {body fields} staff {staff fields} admin_only {admin-only fields} computed {computed fields} other {sequence fields}}";
86
+ readonly self_writable_without_ops: "Collection {collection}, field {field}: selfWritable requires a collection that accepts create_self or update_self";
87
+ readonly field_key_reused: "Field \"{label}\": key {key} was a {type} field in a past version (values remain in records, use another key)";
88
+ readonly field_removed: "Remove field \"{label}\" (values are kept and hidden)";
89
+ readonly field_added: "Add field \"{label}\"";
90
+ readonly field_added_required: "Added field \"{label}\" is required";
91
+ readonly field_type_changed: "Change the type of field \"{label}\" from {from} to {to} (incompatible, create a new field and move the values)";
92
+ readonly field_required: "Make field \"{label}\" required";
93
+ readonly field_pii_narrowed: "Weaken the personal data class of field \"{label}\" (values remain in environment copies)";
94
+ readonly field_tightened: "Tighten the value rules of field \"{label}\" (values that do not match must be fixed on the next save)";
95
+ readonly option_removed: "Remove option \"{option}\" from field \"{label}\"";
96
+ readonly option_added: "Add option \"{option}\" to field \"{label}\"";
97
+ readonly field_changed: "Change the settings or order of field \"{label}\"";
98
+ readonly collection_label_changed: "Change the name or description of collection \"{label}\"";
99
+ readonly collection_format_changed: "Change the format of collection \"{label}\" (create a new collection and move the records)";
100
+ readonly collection_publishing_removed: "Turn off publishing for collection \"{label}\" (draft records also become public)";
101
+ readonly collection_publishing_changed: "Change publishing for collection \"{label}\"";
102
+ readonly collection_slug_mode: "Record slugs in collection \"{label}\" become {mode, select, editor {chosen by editors} other {automatic}}";
103
+ readonly collection_slug_changed: "Change the slug of collection \"{label}\" from {from} to {to} (the delivery path becomes /content/v1/{to}, the old slug path returns 404)";
104
+ readonly collection_roles_changed: "Change the field roles of collection \"{label}\"";
105
+ readonly collection_private_changed: "Make collection \"{label}\" {private, select, yes {private} other {delivered}}";
106
+ readonly collection_unlinked: "Collection \"{label}\" is no longer linked to people (records remain when excluded from environment copies)";
107
+ readonly collection_grant_changed: "Change the required grant field of collection \"{label}\"";
108
+ readonly collection_unique_added: "Add or change unique constraints of collection \"{label}\" (cannot save while duplicates remain)";
109
+ readonly collection_unique_removed: "Remove unique constraints of collection \"{label}\"";
110
+ readonly collection_pages_changed: "Change the page templates of collection \"{label}\"";
111
+ readonly collection_counts_changed: "Change the reference counts of collection \"{label}\"";
112
+ readonly collection_og_changed: "Change the OG image template of collection \"{label}\"";
113
+ readonly collection_self_ops_added: "Add selfOps to collection \"{label}\" (consented installations can read and write on behalf of the customer)";
114
+ readonly collection_self_ops_removed: "Remove selfOps from collection \"{label}\"";
115
+ readonly collection_retention_shortened: "Set the retention of collection \"{label}\" to {days, number} days (expired records are deleted by the daily cleanup)";
116
+ readonly collection_retention_changed: "Change the retention of collection \"{label}\"";
117
+ readonly media_fixed: "The fields, format and publishing of collection \"{label}\" are fixed by the product (name and description can be changed)";
118
+ readonly media_not_removable: "Collection \"{label}\" is fixed by the product and cannot be deleted";
119
+ readonly collection_removed: "Delete collection \"{label}\" (records are kept and hidden)";
120
+ readonly media_defined: "The fields and format of collection \"{label}\" are defined by the product";
121
+ readonly collection_added: "Add collection \"{label}\"";
122
+ readonly confidential_key_reused: "The key of field {field} was a confidential field ({type}) (values remain in records, use another key)";
123
+ readonly audience_widened: "Widen the audience of field {field} from {from, select, public {public} granted {granted customers} self {self} other {staff}} to {to, select, public {public} granted {granted customers} self {self} other {staff}} (recorded in the ledger)";
124
+ readonly component_removed: "Remove the declaration of body component \"{label}\" (bodies using it are rejected on the next save)";
125
+ readonly component_added: "Declare body component \"{label}\"";
126
+ readonly component_changed: "Change the declaration of body component \"{label}\"";
127
+ readonly value_missing: "{field} is required";
128
+ readonly value_undetermined: "{field} is undetermined";
129
+ readonly value_shape: "{field} has an invalid shape";
130
+ readonly value_duplicate: "{field} is duplicated";
131
+ readonly value_max_length: "{field} must be at most {max} characters";
132
+ readonly value_min_length: "{field} must be at least {min} characters";
133
+ readonly value_pattern: "{field} does not match the format";
134
+ readonly value_not_option: "{field} is not one of the options";
135
+ readonly value_id: "{field} must be an ID";
136
+ readonly value_text: "{field} must be a string";
137
+ readonly value_number: "{field} must be a number";
138
+ readonly value_min: "{field} must be at least {min}";
139
+ readonly value_max: "{field} must be at most {max}";
140
+ readonly value_boolean: "{field} must be a boolean";
141
+ readonly value_date: "{field} must be a date (YYYY-MM-DD)";
142
+ readonly value_datetime: "{field} must be a date and time (ISO 8601)";
143
+ readonly value_email: "{field} must be an email address";
144
+ readonly value_phone: "{field} must be a phone number";
145
+ readonly value_url: "{field} must be a URL";
146
+ readonly value_max_items: "{field} allows at most {max} items";
147
+ readonly value_min_items: "{field} requires at least {min} items";
148
+ readonly invalid_screen_id: "id must start with a lowercase letter and contain only lowercase letters, digits, underscores, colons and hyphens";
149
+ readonly duplicate_section_id: "Duplicate section id";
150
+ readonly duplicate_placement: "The same field is placed twice";
151
+ readonly duplicate_menu_group: "Duplicate menu group id";
152
+ readonly duplicate_menu_item: "The same item appears twice in the menu";
153
+ readonly duplicate_column: "The same column appears twice in the list";
154
+ readonly crop_too_large: "The crop is too large (keep at least 10%)";
155
+ readonly option_restricted: "Only accounts with the publish permission can choose this {field}.";
156
+ readonly reference_missing: "{field}: {id} does not exist";
157
+ readonly reference_after_create: "{field} can be selected after creation";
158
+ readonly reference_unmatched: "{field}: {id} does not meet the selection conditions";
159
+ readonly pending_masters: "Additions to masters are awaiting approval: {labels} (can be published after approval)";
160
+ readonly uncited_sources: "{collection}: {count, plural, one {# citation is} other {# citations are}} not in the sources";
161
+ readonly images_without_alt: "{count, plural, one {# image has} other {# images have}} no alternative text (enter it in media)";
162
+ readonly page_field_required: "{field} is required to publish the page";
163
+ readonly referenced_page_fields: "Publishing creates a page for {target}, so {fields} of {target} are required";
164
+ readonly fixed_value: "For this {target}, set {field} of {collection} to {option}";
165
+ readonly body_field_missing: "Collection {collection} has no body field {field}";
166
+ readonly date_time_invalid: "Invalid date and time format";
167
+ readonly comment_required: "Comment is required";
168
+ readonly reject_note_required: "Reason for returning is required";
169
+ };