@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.
- package/CHANGELOG.md +114 -0
- package/README.md +516 -2
- package/dist/analytics.d.ts +1 -0
- package/dist/analytics.js +43 -0
- package/dist/app.d.ts +1 -0
- package/dist/app.js +825 -0
- package/dist/apps-9u4XMi7E.js +114 -0
- package/dist/body.d.ts +1 -0
- package/dist/body.js +455 -0
- package/dist/bridge-DYAYGV7t.js +74 -0
- package/dist/bridge.d.ts +1 -0
- package/dist/bridge.js +189 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +283 -0
- package/dist/client-Derrexwr.js +159 -0
- package/dist/customers-C_vJY2_v.js +84 -0
- package/dist/customers.d.ts +1 -0
- package/dist/customers.js +185 -0
- package/dist/declared-C_GvPiGF.js +397 -0
- package/dist/delivery.d.ts +1 -0
- package/dist/delivery.js +394 -0
- package/dist/dev.d.ts +1 -0
- package/dist/dev.js +93 -0
- package/dist/embed-R-OvDYAw.js +90 -0
- package/dist/errorLabels-CPKiPabZ.js +1510 -0
- package/dist/i18n.d.ts +1 -0
- package/dist/i18n.js +4 -0
- package/dist/integrations.d.ts +1 -0
- package/dist/integrations.js +62 -0
- package/dist/ja-C1HEWWTQ.js +241 -0
- package/dist/ja-C6lX0CeJ.js +213 -0
- package/dist/model-pmXzGX12.js +152 -0
- package/dist/model.d.ts +1 -0
- package/dist/model.js +345 -0
- package/dist/page-E_cYgZx-.js +138 -0
- package/dist/preview.d.ts +1 -0
- package/dist/preview.js +1 -0
- package/dist/profile-D6t1QMQh.js +223 -0
- package/dist/schema-BPHL7Qr-.js +115 -0
- package/dist/schema-UQJWRyfJ.js +995 -0
- package/dist/schema.d.ts +1 -0
- package/dist/schema.js +1 -0
- package/dist/src-sazhzYui.js +71 -0
- package/dist/types/access/src/handoff.d.ts +52 -0
- package/dist/types/access/src/index.d.ts +5 -0
- package/dist/types/access/src/jws.d.ts +5 -0
- package/dist/types/access/src/jwt.d.ts +35 -0
- package/dist/types/access/src/oidc.d.ts +50 -0
- package/dist/types/access/src/signed.d.ts +15 -0
- package/dist/types/analytics/src/day.d.ts +2 -0
- package/dist/types/analytics/src/index.d.ts +5 -0
- package/dist/types/analytics/src/schedule.d.ts +2 -0
- package/dist/types/analytics/src/shared.d.ts +21 -0
- package/dist/types/analytics/src/source.d.ts +19 -0
- package/dist/types/analytics/src/store.d.ts +24 -0
- package/dist/types/analytics/src/view.d.ts +33 -0
- package/dist/types/body/src/components.d.ts +25 -0
- package/dist/types/body/src/declared.d.ts +34 -0
- package/dist/types/body/src/derive.d.ts +13 -0
- package/dist/types/body/src/description.d.ts +8 -0
- package/dist/types/body/src/embed.d.ts +16 -0
- package/dist/types/body/src/href.d.ts +4 -0
- package/dist/types/body/src/html.d.ts +30 -0
- package/dist/types/body/src/index.d.ts +19 -0
- package/dist/types/body/src/inline.d.ts +20 -0
- package/dist/types/body/src/labels/en.d.ts +90 -0
- package/dist/types/body/src/labels/ja.d.ts +153 -0
- package/dist/types/body/src/library.d.ts +113 -0
- package/dist/types/body/src/markdown.d.ts +14 -0
- package/dist/types/body/src/normalize.d.ts +5 -0
- package/dist/types/body/src/problems.d.ts +103 -0
- package/dist/types/body/src/profile.d.ts +80 -0
- package/dist/types/body/src/render.d.ts +29 -0
- package/dist/types/body/src/schema.d.ts +6 -0
- package/dist/types/body/src/standard.d.ts +20 -0
- package/dist/types/body/src/types.d.ts +140 -0
- package/dist/types/cms-contract/src/apiKeys.d.ts +41 -0
- package/dist/types/cms-contract/src/app.d.ts +35 -0
- package/dist/types/cms-contract/src/appDependencies.d.ts +265 -0
- package/dist/types/cms-contract/src/appProblems.d.ts +22 -0
- package/dist/types/cms-contract/src/apps.d.ts +195 -0
- package/dist/types/cms-contract/src/assets.d.ts +12 -0
- package/dist/types/cms-contract/src/authorize.d.ts +146 -0
- package/dist/types/cms-contract/src/bridge.d.ts +318 -0
- package/dist/types/cms-contract/src/consents.d.ts +97 -0
- package/dist/types/cms-contract/src/customerLabels.d.ts +33 -0
- package/dist/types/cms-contract/src/customers.d.ts +266 -0
- package/dist/types/cms-contract/src/embeds.d.ts +165 -0
- package/dist/types/cms-contract/src/errorLabels.d.ts +269 -0
- package/dist/types/cms-contract/src/errorLabelsEn.d.ts +228 -0
- package/dist/types/cms-contract/src/errors.d.ts +105 -0
- package/dist/types/cms-contract/src/failureStatus.d.ts +124 -0
- package/dist/types/cms-contract/src/functionLabels.d.ts +5 -0
- package/dist/types/cms-contract/src/functions.d.ts +144 -0
- package/dist/types/cms-contract/src/identifiers.d.ts +117 -0
- package/dist/types/cms-contract/src/import.d.ts +277 -0
- package/dist/types/cms-contract/src/issueLabels.d.ts +435 -0
- package/dist/types/cms-contract/src/issueLabelsEn.d.ts +217 -0
- package/dist/types/cms-contract/src/migration.d.ts +103 -0
- package/dist/types/cms-contract/src/paths.d.ts +23 -0
- package/dist/types/cms-contract/src/permissionLabels.d.ts +8 -0
- package/dist/types/cms-contract/src/permissions.d.ts +77 -0
- package/dist/types/cms-contract/src/problems.d.ts +34 -0
- package/dist/types/cms-contract/src/roles.d.ts +57 -0
- package/dist/types/cms-contract/src/settingProblems.d.ts +13 -0
- package/dist/types/cms-contract/src/settings.d.ts +19 -0
- package/dist/types/cms-contract/src/siteArtifact.d.ts +45 -0
- package/dist/types/cms-contract/src/siteDeclaration.d.ts +70 -0
- package/dist/types/cms-contract/src/transfer.d.ts +57 -0
- package/dist/types/cms-contract/src/urlLabel.d.ts +13 -0
- package/dist/types/cms-contract/src/views.d.ts +21 -0
- package/dist/types/cms-contract/src/webhookLabels.d.ts +7 -0
- package/dist/types/cms-contract/src/webhooks.d.ts +139 -0
- package/dist/types/i18n/src/index.d.ts +50 -0
- package/dist/types/i18n/src/problems.d.ts +21 -0
- package/dist/types/model/src/asset.d.ts +111 -0
- package/dist/types/model/src/audience.d.ts +38 -0
- package/dist/types/model/src/brand.d.ts +25 -0
- package/dist/types/model/src/capabilities.d.ts +28 -0
- package/dist/types/model/src/changes.d.ts +34 -0
- package/dist/types/model/src/check.d.ts +15 -0
- package/dist/types/model/src/contact.d.ts +22 -0
- package/dist/types/model/src/image.d.ts +38 -0
- package/dist/types/model/src/index.d.ts +26 -0
- package/dist/types/model/src/input.d.ts +26 -0
- package/dist/types/model/src/integrity.d.ts +79 -0
- package/dist/types/model/src/json.d.ts +2 -0
- package/dist/types/model/src/labels/en.d.ts +169 -0
- package/dist/types/model/src/labels/ja.d.ts +198 -0
- package/dist/types/model/src/legacy.d.ts +2 -0
- package/dist/types/model/src/media.d.ts +5 -0
- package/dist/types/model/src/mediaUrl.d.ts +67 -0
- package/dist/types/model/src/model.d.ts +415 -0
- package/dist/types/model/src/page.d.ts +52 -0
- package/dist/types/model/src/problems.d.ts +184 -0
- package/dist/types/model/src/refs.d.ts +27 -0
- package/dist/types/model/src/rules.d.ts +15 -0
- package/dist/types/model/src/schema.d.ts +58 -0
- package/dist/types/model/src/screens.d.ts +76 -0
- package/dist/types/model/src/selfOps.d.ts +30 -0
- package/dist/types/model/src/time.d.ts +25 -0
- package/dist/types/model/src/typesSource.d.ts +8 -0
- package/dist/types/model/src/values.d.ts +24 -0
- package/dist/types/platform/src/defaultModel.d.ts +8 -0
- package/dist/types/sdk/src/analytics.d.ts +2 -0
- package/dist/types/sdk/src/app.d.ts +20 -0
- package/dist/types/sdk/src/body.d.ts +2 -0
- package/dist/types/sdk/src/bridge.d.ts +92 -0
- package/dist/types/sdk/src/cli.d.ts +2 -0
- package/dist/types/sdk/src/customers.d.ts +190 -0
- package/dist/types/sdk/src/delivery/cache.d.ts +18 -0
- package/dist/types/sdk/src/delivery/changes.d.ts +28 -0
- package/dist/types/sdk/src/delivery/client.d.ts +90 -0
- package/dist/types/sdk/src/delivery/fields.d.ts +48 -0
- package/dist/types/sdk/src/delivery/index.d.ts +9 -0
- package/dist/types/sdk/src/delivery/media.d.ts +28 -0
- package/dist/types/sdk/src/delivery/query.d.ts +85 -0
- package/dist/types/sdk/src/delivery/schema.d.ts +19 -0
- package/dist/types/sdk/src/delivery/values.d.ts +82 -0
- package/dist/types/sdk/src/delivery.d.ts +3 -0
- package/dist/types/sdk/src/dev.d.ts +29 -0
- package/dist/types/sdk/src/i18n.d.ts +12 -0
- package/dist/types/sdk/src/integrations.d.ts +33 -0
- package/dist/types/sdk/src/model.d.ts +5 -0
- package/dist/types/sdk/src/preview.d.ts +1 -0
- package/dist/types/sdk/src/schema.d.ts +21 -0
- package/dist/types/sdk/src/site.d.ts +43 -0
- package/dist/typesSource-bO0jFw1I.js +88 -0
- package/package.json +86 -3
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/** インラインの装飾(strong・em・code・s・mark・sup・sub・u) */
|
|
2
|
+
export type Mark = 'strong' | 'em' | 'code' | 'strike' | 'mark' | 'sup' | 'sub' | 'underline';
|
|
3
|
+
/** リンク(HTML の a の href・title・rel、target は別のタブ) */
|
|
4
|
+
export type Link = Readonly<{
|
|
5
|
+
href: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
rel?: string;
|
|
8
|
+
target?: '_blank';
|
|
9
|
+
}>;
|
|
10
|
+
/** 名前のついた値(name は本文の設定で宣言した名前、value は元の CSS の値、どちらか1つ以上) */
|
|
11
|
+
export type Named = Readonly<{
|
|
12
|
+
name?: string;
|
|
13
|
+
value?: string;
|
|
14
|
+
}>;
|
|
15
|
+
/** 名前のついた値の見た目の種類(色・背景・大きさ) */
|
|
16
|
+
export declare const STYLE_KINDS: readonly ["color", "background", "size"];
|
|
17
|
+
/** 名前のついた値の見た目の種類 */
|
|
18
|
+
export type StyleKind = (typeof STYLE_KINDS)[number];
|
|
19
|
+
/** 文字の見た目(styles は本文の設定で宣言した名前のついた装飾、例: microCMS のカスタム class) */
|
|
20
|
+
export type TextStyle = Readonly<{
|
|
21
|
+
color?: Named;
|
|
22
|
+
background?: Named;
|
|
23
|
+
size?: Named;
|
|
24
|
+
styles?: readonly string[];
|
|
25
|
+
}>;
|
|
26
|
+
/** 装飾・リンク・見た目つきの文字列 */
|
|
27
|
+
export type Text = Readonly<{
|
|
28
|
+
text: string;
|
|
29
|
+
marks?: readonly Mark[];
|
|
30
|
+
link?: Link;
|
|
31
|
+
style?: TextStyle;
|
|
32
|
+
}>;
|
|
33
|
+
/** インラインのコンポーネント(例: 注、属性は文字列だけ、text は中の文字) */
|
|
34
|
+
export type InlineComponent = Readonly<{
|
|
35
|
+
component: string;
|
|
36
|
+
props?: Readonly<Record<string, string>>;
|
|
37
|
+
text?: string;
|
|
38
|
+
}>;
|
|
39
|
+
/** インラインの断片(文字列は装飾なし) */
|
|
40
|
+
export type Inline = string | Text | InlineComponent;
|
|
41
|
+
/** インラインの断片の列(1つの段落・見出し・セルの内容) */
|
|
42
|
+
export type Rich = readonly Inline[];
|
|
43
|
+
/** 見出しの段階 */
|
|
44
|
+
export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
45
|
+
/** 揃えの値(段落・見出し・表のセル) */
|
|
46
|
+
export declare const ALIGNS: readonly ["left", "center", "right", "justify"];
|
|
47
|
+
/** 揃え(段落・見出し・表のセル) */
|
|
48
|
+
export type Align = (typeof ALIGNS)[number];
|
|
49
|
+
/** 画像の横の位置の値 */
|
|
50
|
+
export declare const IMAGE_ALIGNS: readonly ["left", "center", "right"];
|
|
51
|
+
/** 画像の横の位置 */
|
|
52
|
+
export type ImageAlign = (typeof IMAGE_ALIGNS)[number];
|
|
53
|
+
/** 属性つきの表のセル(content はセルの中の段落、header は見出しのセル、colspan・rowspan は結合) */
|
|
54
|
+
export type TableCell = Readonly<{
|
|
55
|
+
content: readonly Rich[];
|
|
56
|
+
header?: boolean;
|
|
57
|
+
colspan?: number;
|
|
58
|
+
rowspan?: number;
|
|
59
|
+
align?: Align;
|
|
60
|
+
}>;
|
|
61
|
+
/** 表のセル(断片の列だけのセルか、属性つきのセル) */
|
|
62
|
+
export type Cell = Rich | TableCell;
|
|
63
|
+
/** リストの1項目(children は入れ子のリスト) */
|
|
64
|
+
export type ListItem = Readonly<{
|
|
65
|
+
content: Rich;
|
|
66
|
+
children?: List;
|
|
67
|
+
}>;
|
|
68
|
+
/** リスト */
|
|
69
|
+
export type List = Readonly<{
|
|
70
|
+
type: 'list';
|
|
71
|
+
ordered?: boolean;
|
|
72
|
+
items: readonly ListItem[];
|
|
73
|
+
variant?: string;
|
|
74
|
+
}>;
|
|
75
|
+
/** 標準のブロック */
|
|
76
|
+
export type StandardBlock<M> = Readonly<{
|
|
77
|
+
type: 'paragraph';
|
|
78
|
+
content: Rich;
|
|
79
|
+
align?: Align;
|
|
80
|
+
variant?: string;
|
|
81
|
+
}> | Readonly<{
|
|
82
|
+
type: 'heading';
|
|
83
|
+
level: HeadingLevel;
|
|
84
|
+
content: Rich;
|
|
85
|
+
id?: string;
|
|
86
|
+
align?: Align;
|
|
87
|
+
variant?: string;
|
|
88
|
+
}> | List | Readonly<{
|
|
89
|
+
type: 'quote';
|
|
90
|
+
content: readonly Rich[];
|
|
91
|
+
cite?: Readonly<{
|
|
92
|
+
label: string;
|
|
93
|
+
href?: string;
|
|
94
|
+
}>;
|
|
95
|
+
variant?: string;
|
|
96
|
+
}> | Readonly<{
|
|
97
|
+
type: 'code';
|
|
98
|
+
code: string;
|
|
99
|
+
lang?: string;
|
|
100
|
+
caption?: string;
|
|
101
|
+
filename?: string;
|
|
102
|
+
variant?: string;
|
|
103
|
+
}> | Readonly<{
|
|
104
|
+
type: 'image';
|
|
105
|
+
media: M;
|
|
106
|
+
alt?: string;
|
|
107
|
+
caption?: string;
|
|
108
|
+
link?: Link;
|
|
109
|
+
align?: ImageAlign;
|
|
110
|
+
variant?: string;
|
|
111
|
+
}> | Readonly<{
|
|
112
|
+
type: 'table';
|
|
113
|
+
head?: readonly Rich[];
|
|
114
|
+
rows: readonly (readonly Cell[])[];
|
|
115
|
+
caption?: string;
|
|
116
|
+
variant?: string;
|
|
117
|
+
}> | Readonly<{
|
|
118
|
+
type: 'file';
|
|
119
|
+
media: M;
|
|
120
|
+
label?: string;
|
|
121
|
+
}> | Readonly<{
|
|
122
|
+
type: 'divider';
|
|
123
|
+
}> | Readonly<{
|
|
124
|
+
type: 'html';
|
|
125
|
+
html: string;
|
|
126
|
+
}>;
|
|
127
|
+
/** カスタムコンポーネントのブロック(props は JSON で表せる値) */
|
|
128
|
+
export type ComponentBlock = Readonly<{
|
|
129
|
+
type: 'component';
|
|
130
|
+
name: string;
|
|
131
|
+
props: unknown;
|
|
132
|
+
}>;
|
|
133
|
+
/** 本文のブロック */
|
|
134
|
+
export type Block<M> = StandardBlock<M> | ComponentBlock;
|
|
135
|
+
/** 本文 */
|
|
136
|
+
export type Body<M> = readonly Block<M>[];
|
|
137
|
+
/** 属性つきのセルか */
|
|
138
|
+
export declare const isTableCell: (cell: Cell) => cell is TableCell;
|
|
139
|
+
/** セルの中の段落(断片の列だけのセルは1段落) */
|
|
140
|
+
export declare const cellParagraphs: (cell: Cell) => readonly Rich[];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** 鍵の種類 */
|
|
2
|
+
export declare const API_KEY_KINDS: readonly ["server"];
|
|
3
|
+
/** 鍵の種類 */
|
|
4
|
+
export type ApiKeyKind = (typeof API_KEY_KINDS)[number];
|
|
5
|
+
/** 鍵の操作 */
|
|
6
|
+
export declare const API_KEY_OPERATIONS: readonly ["read", "read_drafts", "read_customers", "verify_customers", "create", "update", "publish", "delete"];
|
|
7
|
+
/** 鍵の操作 */
|
|
8
|
+
export type ApiKeyOperation = (typeof API_KEY_OPERATIONS)[number];
|
|
9
|
+
/** 書き込みの操作(書き込みの API(#500)まで画面で選べない) */
|
|
10
|
+
export declare const API_KEY_WRITE_OPERATIONS: readonly ["create", "update", "publish", "delete"];
|
|
11
|
+
/** 権限のキーで、すべてのコレクション(後から足すコレクションを含む) */
|
|
12
|
+
export declare const API_KEY_ALL_COLLECTIONS = "*";
|
|
13
|
+
/** 鍵の権限(キーはコレクションの id か API_KEY_ALL_TYPES) */
|
|
14
|
+
export type ApiKeyPermissions = Readonly<Record<string, readonly ApiKeyOperation[]>>;
|
|
15
|
+
/** 権限を省略した鍵と既存の鍵の権限 */
|
|
16
|
+
export declare const DEFAULT_API_KEY_PERMISSIONS: {
|
|
17
|
+
readonly "*": readonly ["read"];
|
|
18
|
+
};
|
|
19
|
+
/** 鍵の権限がコレクションの操作を許すか(read は read_drafts でも満たす、verify_customers は鍵の操作そのもの。新しい判定は判定の関数 authorize) */
|
|
20
|
+
export declare function apiKeyAllows(permissions: ApiKeyPermissions, collection: string, operation: ApiKeyOperation): boolean;
|
|
21
|
+
/** 一覧に表示する API の鍵(environments は読める環境で live か環境の URL のラベル、tail は鍵の末尾、revokedAt は失効の日時で有効なら null) */
|
|
22
|
+
export type ApiKey = Readonly<{
|
|
23
|
+
id: string;
|
|
24
|
+
label: string;
|
|
25
|
+
kind: ApiKeyKind;
|
|
26
|
+
permissions: ApiKeyPermissions;
|
|
27
|
+
environments: readonly string[];
|
|
28
|
+
tail: string;
|
|
29
|
+
createdAt: string;
|
|
30
|
+
revokedAt: string | null;
|
|
31
|
+
}>;
|
|
32
|
+
/** 公開のエンドポイントで鍵ごとの回数の上限(period は秒) */
|
|
33
|
+
export declare const API_KEY_RATE: {
|
|
34
|
+
readonly limit: 600;
|
|
35
|
+
readonly period: 60;
|
|
36
|
+
};
|
|
37
|
+
/** 公開のエンドポイントで鍵やプロジェクトの照合に失敗した要求の、接続元の IP ごとの上限(period 秒で limit 回、超えた IP は照合の前に429、platform#45) */
|
|
38
|
+
export declare const PUBLIC_FAILURE_RATE: {
|
|
39
|
+
readonly limit: 30;
|
|
40
|
+
readonly period: 60;
|
|
41
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { SettingsArea } from './settings.js';
|
|
2
|
+
/** 経路の権限の判定の種類(account はログイン中のすべて、admin は管理者だけ、settings:<領域> は設定の領域の権限) */
|
|
3
|
+
export type AppRoutePolicy = 'account' | 'permission' | 'admin' | `settings:${SettingsArea}`;
|
|
4
|
+
/** アプリの経路のメソッド */
|
|
5
|
+
export type AppRouteMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
6
|
+
/** 管理の API を呼ぶクライアント(path は /api から、呼んだ人の資格のまま) */
|
|
7
|
+
export type CmsClient = Readonly<{
|
|
8
|
+
fetch(path: `/api/${string}`, init?: RequestInit): Promise<Response>;
|
|
9
|
+
}>;
|
|
10
|
+
/** 経路の処理に渡す文脈(params は経路の名前つきの区間の値、egress はサーバーの宣言の egress の宛先だけへの GET と HEAD) */
|
|
11
|
+
export type AppContext = Readonly<{
|
|
12
|
+
cms: CmsClient;
|
|
13
|
+
egress: (input: string | URL, init?: RequestInit) => Promise<Response>;
|
|
14
|
+
params: Readonly<Record<string, string>>;
|
|
15
|
+
}>;
|
|
16
|
+
/** アプリの経路(path は /api からの経路、`:<名前>` は1つの区間) */
|
|
17
|
+
export type AppRoute = Readonly<{
|
|
18
|
+
method: AppRouteMethod;
|
|
19
|
+
path: `/api/${string}`;
|
|
20
|
+
policy: AppRoutePolicy;
|
|
21
|
+
handle: (request: Request, ctx: AppContext) => Promise<Response>;
|
|
22
|
+
}>;
|
|
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 だけ、ポートの指定なし) */
|
|
35
|
+
export declare function egressAllows(declared: readonly string[], url: URL): boolean;
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { type FieldDef, type SchemaChange } from '../../model/src/index.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/** ポートの id(`<発行者>:<名前>@<世代>`、例 tunasand:message@1) */
|
|
4
|
+
export type PortId = `${string}:${string}@${number}`;
|
|
5
|
+
/** 設定の値 */
|
|
6
|
+
export type AppSettingValue = boolean | string | number;
|
|
7
|
+
/** アプリの依存(major は依存先の互換の世代、minVersion はその世代の中の下限、なしは世代の最初) */
|
|
8
|
+
export type AppDependency = Readonly<{
|
|
9
|
+
/** 登録簿のアプリの id(kind: 'app' だけ。site・theme は書けない) */
|
|
10
|
+
app: string;
|
|
11
|
+
kind: 'required' | 'optional';
|
|
12
|
+
major: number;
|
|
13
|
+
minVersion?: number;
|
|
14
|
+
/** 一緒に入れたときだけ当てる依存先の設定(拡張パック。導入済みの依存の設定は上書きしない) */
|
|
15
|
+
defaults?: Readonly<Record<string, AppSettingValue>>;
|
|
16
|
+
/** 自分の設定の画面に並べる依存先の設定の key(展開。保存は依存先の設定へ、正は依存先) */
|
|
17
|
+
expose?: readonly string[];
|
|
18
|
+
}>;
|
|
19
|
+
/** ポートの利用(required はプロバイダーが1つもなければインストールできない) */
|
|
20
|
+
export type PortUse = Readonly<{
|
|
21
|
+
port: PortId;
|
|
22
|
+
required: boolean;
|
|
23
|
+
}>;
|
|
24
|
+
/** ポートの提供(route はアプリの経路) */
|
|
25
|
+
export type PortProvide = Readonly<{
|
|
26
|
+
port: PortId;
|
|
27
|
+
route: `/api/${string}`;
|
|
28
|
+
}>;
|
|
29
|
+
/** アプリのコレクション(name はアプリの中の名前でスラッグの既定。fields の key は予約の key と `x_` を使えない) */
|
|
30
|
+
export type AppCollection = Readonly<{
|
|
31
|
+
name: string;
|
|
32
|
+
label: string;
|
|
33
|
+
/** アプリの内部のレコード(データを消すの対象) */
|
|
34
|
+
internal?: boolean;
|
|
35
|
+
/** 配信しない */
|
|
36
|
+
private?: boolean;
|
|
37
|
+
fields: readonly FieldDef[];
|
|
38
|
+
}>;
|
|
39
|
+
/** アプリの設定(requires は設定を使うのに要る任意の依存のアプリの id) */
|
|
40
|
+
export type AppSettingDef = Readonly<{
|
|
41
|
+
key: string;
|
|
42
|
+
label: string;
|
|
43
|
+
type: 'boolean' | 'text' | 'number' | 'select';
|
|
44
|
+
options?: readonly string[];
|
|
45
|
+
default?: AppSettingValue;
|
|
46
|
+
requires?: string;
|
|
47
|
+
}>;
|
|
48
|
+
/** 値段(円、usage は従量の説明の文) */
|
|
49
|
+
export type AppPrice = Readonly<{
|
|
50
|
+
setup?: number;
|
|
51
|
+
monthly?: number;
|
|
52
|
+
usage?: string;
|
|
53
|
+
currency: 'JPY';
|
|
54
|
+
}>;
|
|
55
|
+
/** マニフェストの依存の宣言(apps.ts の AppManifest に入る項目) */
|
|
56
|
+
export type AppDependencyManifest = Readonly<{
|
|
57
|
+
major?: number;
|
|
58
|
+
requires?: readonly AppDependency[];
|
|
59
|
+
uses?: readonly PortUse[];
|
|
60
|
+
provides?: readonly PortProvide[];
|
|
61
|
+
collections?: readonly AppCollection[];
|
|
62
|
+
settings?: readonly AppSettingDef[];
|
|
63
|
+
price?: AppPrice;
|
|
64
|
+
}>;
|
|
65
|
+
/** 宣言の上限(計画のノードの数は一括の大きさを抑えるため。全部か無しなので分けられない) */
|
|
66
|
+
export declare const APP_DEPENDENCY_LIMITS: {
|
|
67
|
+
readonly entriesMax: 100;
|
|
68
|
+
readonly textMax: 500;
|
|
69
|
+
readonly planNodesMax: 20;
|
|
70
|
+
};
|
|
71
|
+
/** major を書かない旧いマニフェストの世代 */
|
|
72
|
+
export declare const DEFAULT_APP_MAJOR = 1;
|
|
73
|
+
/** 導入先がアプリのコレクションに足すフィールドの頭(アプリのフィールドは使えない) */
|
|
74
|
+
export declare const IMPORTER_FIELD_PREFIX = "x_";
|
|
75
|
+
/** アプリのフィールドに使えない key(予約の key の凍結の一覧。slug はスラッグの導入で予約に入る) */
|
|
76
|
+
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
|
+
/** 依存の宣言の形(zod。マニフェストのほかの項目は apps.ts の appManifestProblems が見る) */
|
|
89
|
+
export declare const appDependencyManifestSchema: z.ZodObject<{
|
|
90
|
+
major: z.ZodOptional<z.ZodNumber>;
|
|
91
|
+
requires: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
92
|
+
app: z.ZodString;
|
|
93
|
+
kind: z.ZodEnum<{
|
|
94
|
+
optional: "optional";
|
|
95
|
+
required: "required";
|
|
96
|
+
}>;
|
|
97
|
+
major: z.ZodNumber;
|
|
98
|
+
minVersion: z.ZodOptional<z.ZodNumber>;
|
|
99
|
+
defaults: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodBoolean, z.ZodString, z.ZodNumber]>>>;
|
|
100
|
+
expose: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
101
|
+
}, z.core.$strict>>>;
|
|
102
|
+
uses: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
103
|
+
port: z.ZodString;
|
|
104
|
+
required: z.ZodBoolean;
|
|
105
|
+
}, z.core.$strict>>>;
|
|
106
|
+
provides: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
107
|
+
port: z.ZodString;
|
|
108
|
+
route: z.ZodString;
|
|
109
|
+
}, z.core.$strict>>>;
|
|
110
|
+
collections: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
111
|
+
name: z.ZodString;
|
|
112
|
+
label: z.ZodString;
|
|
113
|
+
internal: z.ZodOptional<z.ZodBoolean>;
|
|
114
|
+
private: z.ZodOptional<z.ZodBoolean>;
|
|
115
|
+
fields: z.ZodArray<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
116
|
+
}, z.core.$strict>>>;
|
|
117
|
+
settings: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
118
|
+
key: z.ZodString;
|
|
119
|
+
label: z.ZodString;
|
|
120
|
+
type: z.ZodEnum<{
|
|
121
|
+
number: "number";
|
|
122
|
+
boolean: "boolean";
|
|
123
|
+
text: "text";
|
|
124
|
+
select: "select";
|
|
125
|
+
}>;
|
|
126
|
+
options: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
127
|
+
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString, z.ZodNumber]>>;
|
|
128
|
+
requires: z.ZodOptional<z.ZodString>;
|
|
129
|
+
}, z.core.$strict>>>;
|
|
130
|
+
price: z.ZodOptional<z.ZodObject<{
|
|
131
|
+
setup: z.ZodOptional<z.ZodNumber>;
|
|
132
|
+
monthly: z.ZodOptional<z.ZodNumber>;
|
|
133
|
+
usage: z.ZodOptional<z.ZodString>;
|
|
134
|
+
currency: z.ZodLiteral<"JPY">;
|
|
135
|
+
}, z.core.$strict>>;
|
|
136
|
+
}, z.core.$strip>;
|
|
137
|
+
/** 依存の宣言の問題(path は値の場所) */
|
|
138
|
+
export type AppDependencyProblem = Readonly<{
|
|
139
|
+
path: string;
|
|
140
|
+
code: 'invalid' | 'too_many' | 'duplicate' | 'reserved';
|
|
141
|
+
}>;
|
|
142
|
+
/**
|
|
143
|
+
* 依存の宣言の検査(マニフェストだけで決まるもの。依存先のマニフェストを見る検査は dependencyTargetProblems)
|
|
144
|
+
* - 同じアプリ・ポート・コレクションの名前・設定の key の2回の宣言
|
|
145
|
+
* - アプリのフィールドの key が予約の key か `x_` で始まる
|
|
146
|
+
* - 設定の requires が任意の依存にない
|
|
147
|
+
*/
|
|
148
|
+
export declare function appDependencyProblems(input: unknown): AppDependencyProblem[];
|
|
149
|
+
/** 依存先の登録簿の行とマニフェスト(登録のときの検査が引く) */
|
|
150
|
+
export type DependencyTarget = Readonly<{
|
|
151
|
+
kind: string;
|
|
152
|
+
manifest: AppDependencyManifest | null;
|
|
153
|
+
}>;
|
|
154
|
+
/**
|
|
155
|
+
* 依存先を見る検査(登録と新しいバージョンの公開のとき)
|
|
156
|
+
* - 自分への依存、登録簿にない依存先、`site`・`theme` への依存
|
|
157
|
+
* - `expose`・`defaults` の key が依存先の最新のバージョンの設定にない
|
|
158
|
+
*/
|
|
159
|
+
export declare function dependencyTargetProblems(manifest: AppDependencyManifest, self: string | null, targets: ReadonlyMap<string, DependencyTarget>): AppDependencyProblem[];
|
|
160
|
+
/** マニフェストの世代(major を書かない旧いマニフェストは1) */
|
|
161
|
+
export declare const appMajorOf: (manifest: AppDependencyManifest) => number;
|
|
162
|
+
/**
|
|
163
|
+
* アプリのコレクションの名前から導入先のコレクションの id(M3 の installation_collections までの結び付き)
|
|
164
|
+
* - 名前空間を持つアプリだけがコレクションを持てる(登録簿の名前空間は一意で再利用されない)
|
|
165
|
+
*/
|
|
166
|
+
export declare const appCollectionIdOf: (namespace: string, name: string) => string;
|
|
167
|
+
/** 版の互換の外れ(path は値の場所、change はコレクションの互換のない変更) */
|
|
168
|
+
export type IncompatibleChange = Readonly<{
|
|
169
|
+
path: string;
|
|
170
|
+
change?: SchemaChange;
|
|
171
|
+
}>;
|
|
172
|
+
/**
|
|
173
|
+
* 同じ世代の中の互換の外れ(登録簿が新しいバージョンの登録で断る。前と新しいバージョンのマニフェストだけで判定)
|
|
174
|
+
* - 世代を下げる、コレクションのマニフェストで決まる forbidden、設定の key の削除と型の変更、provides の削除、requires の世代の引き上げ
|
|
175
|
+
* - 世代を上げた版でも、コレクションの forbidden は許さない(アプリの中のデータの移しの口がまだない)
|
|
176
|
+
*/
|
|
177
|
+
export declare function incompatibleChanges(prev: AppDependencyManifest, next: AppDependencyManifest): IncompatibleChange[];
|
|
178
|
+
/** 値段の能力の要素(従量の文は短い digest にする) */
|
|
179
|
+
export declare function priceCapabilityOf(price: AppPrice): string;
|
|
180
|
+
/** 依存の宣言の能力の要素(apps.ts の capabilitySetOf が足す) */
|
|
181
|
+
export declare function dependencyCapabilitiesOf(manifest: AppDependencyManifest): string[];
|
|
182
|
+
/** 計画のノードが入った理由(requested は導入先が選んだ、requiredBy はそのアプリが必須で依存するため) */
|
|
183
|
+
export type PlanReason = Readonly<{
|
|
184
|
+
requested: true;
|
|
185
|
+
} | {
|
|
186
|
+
requiredBy: readonly string[];
|
|
187
|
+
}>;
|
|
188
|
+
/** 計画のノード(1つのアプリ) */
|
|
189
|
+
export type PlanNode = Readonly<{
|
|
190
|
+
appId: string;
|
|
191
|
+
label: string;
|
|
192
|
+
version: number;
|
|
193
|
+
major: number;
|
|
194
|
+
action: 'install' | 'upgrade' | 'keep';
|
|
195
|
+
reason: PlanReason;
|
|
196
|
+
/** 増える能力(install は全部、upgrade は前の同意にない分、keep は空) */
|
|
197
|
+
capabilities: readonly string[];
|
|
198
|
+
/** コレクションのスキーマの変更(M3 でインストールがコレクションを作るときに埋める) */
|
|
199
|
+
schemaChanges: readonly SchemaChange[];
|
|
200
|
+
/** マニフェストの名前 → スラッグ(ぶつかれば候補、導入先が画面で直せる) */
|
|
201
|
+
slugs: Readonly<Record<string, string>>;
|
|
202
|
+
/** マニフェストの名前 → 結ぶ既存のコレクションの id(既存のコレクションを使う、M3) */
|
|
203
|
+
adopt: Readonly<Record<string, string>>;
|
|
204
|
+
/** 一緒に入れるときに当てる設定(依存元の defaults) */
|
|
205
|
+
defaults: Readonly<Record<string, AppSettingValue>>;
|
|
206
|
+
price: AppPrice | null;
|
|
207
|
+
priceChange?: Readonly<{
|
|
208
|
+
from: AppPrice | null;
|
|
209
|
+
to: AppPrice | null;
|
|
210
|
+
}>;
|
|
211
|
+
}>;
|
|
212
|
+
/** インストールの計画(同意はこの計画の ID と digest を送り返す。ID は適用を重ねても1回にする鍵) */
|
|
213
|
+
export type InstallPlan = Readonly<{
|
|
214
|
+
id: string;
|
|
215
|
+
/** 依存の先が前 */
|
|
216
|
+
nodes: readonly PlanNode[];
|
|
217
|
+
/** 計画のアプリが使うポート → 提供するアプリ(入っているものと計画の中のもの) */
|
|
218
|
+
providers: Readonly<Record<string, readonly string[]>>;
|
|
219
|
+
total: Readonly<{
|
|
220
|
+
setup: number;
|
|
221
|
+
monthly: number;
|
|
222
|
+
firstYear: number;
|
|
223
|
+
usage: readonly string[];
|
|
224
|
+
}>;
|
|
225
|
+
digest: string;
|
|
226
|
+
}>;
|
|
227
|
+
/** 計画を作れない理由(全部を集めて見せる) */
|
|
228
|
+
export type PlanConflict = Readonly<{
|
|
229
|
+
kind: 'major';
|
|
230
|
+
app: string;
|
|
231
|
+
wants: readonly Readonly<{
|
|
232
|
+
by: string;
|
|
233
|
+
major: number;
|
|
234
|
+
}>[];
|
|
235
|
+
}> | Readonly<{
|
|
236
|
+
kind: 'min_version';
|
|
237
|
+
app: string;
|
|
238
|
+
by: string;
|
|
239
|
+
minVersion: number;
|
|
240
|
+
latest: number;
|
|
241
|
+
}> | Readonly<{
|
|
242
|
+
kind: 'not_installable' | 'missing';
|
|
243
|
+
app: string;
|
|
244
|
+
by: string;
|
|
245
|
+
}> | Readonly<{
|
|
246
|
+
kind: 'cycle';
|
|
247
|
+
path: readonly string[];
|
|
248
|
+
}> | Readonly<{
|
|
249
|
+
kind: 'no_provider';
|
|
250
|
+
port: string;
|
|
251
|
+
by: string;
|
|
252
|
+
}> | Readonly<{
|
|
253
|
+
kind: 'slots';
|
|
254
|
+
app: string;
|
|
255
|
+
}> | Readonly<{
|
|
256
|
+
kind: 'slug';
|
|
257
|
+
app: string;
|
|
258
|
+
name: string;
|
|
259
|
+
slug: string;
|
|
260
|
+
}> | Readonly<{
|
|
261
|
+
kind: 'too_large';
|
|
262
|
+
nodes: number;
|
|
263
|
+
}>;
|
|
264
|
+
/** 計画の合計(install のノードだけ。keep は導入済みで追加なし) */
|
|
265
|
+
export declare function planTotalOf(nodes: readonly PlanNode[]): InstallPlan['total'];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ParamsArg, type ParamValue } from '../../i18n/src/index.js';
|
|
2
|
+
/** アプリの問題(message は英語の文) */
|
|
3
|
+
export type AppProblem<C extends string = string> = Readonly<{
|
|
4
|
+
code: C;
|
|
5
|
+
params?: Readonly<Record<string, ParamValue>>;
|
|
6
|
+
message: string;
|
|
7
|
+
}>;
|
|
8
|
+
/** 問題の表から、問題を作る関数(差し込みの不足は型の誤り) */
|
|
9
|
+
export declare function appProblems<M extends Readonly<Record<string, string>>>(tables: Readonly<{
|
|
10
|
+
ja: M;
|
|
11
|
+
en: Readonly<Record<keyof M, string>>;
|
|
12
|
+
}>): {
|
|
13
|
+
problem: <K extends keyof M & string>(code: K, ...params: ParamsArg<M[K]>) => AppProblem<keyof M & string>;
|
|
14
|
+
/** zod の message のように文字列しか運べない所の既定の形(fromText で問題に戻す) */
|
|
15
|
+
text: <K extends keyof M & string>(code: K, ...params: ParamsArg<M[K]>) => string;
|
|
16
|
+
/** 既定の形の文の問題(表の外の文は message だけ) */
|
|
17
|
+
fromText: (text: string) => Readonly<{
|
|
18
|
+
code?: keyof M & string;
|
|
19
|
+
params?: Readonly<Record<string, ParamValue>>;
|
|
20
|
+
message: string;
|
|
21
|
+
}>;
|
|
22
|
+
};
|