@tunasand/sdk 0.0.0-stage → 0.6.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 +106 -0
- package/README.md +506 -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 +348 -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-BcyRbv_i.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/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 +14 -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,318 @@
|
|
|
1
|
+
import type { EmbedPlacement } from './embeds.js';
|
|
2
|
+
/** メッセージの名前の頭(外に見える識別子、改名はここだけ) */
|
|
3
|
+
export declare const BRIDGE_NAMESPACE = "tunasand.bridge";
|
|
4
|
+
/** 規約の版 */
|
|
5
|
+
export declare const BRIDGE_VERSION = 1;
|
|
6
|
+
/**
|
|
7
|
+
* 画面のトークン(アカウントの資格、Shopify のセッションのトークンと同じ形の JWT、設計は docs/app-screens.md の「アカウントの資格」)
|
|
8
|
+
* - 署名は HS256 で、鍵はクライアントの秘密(インストールにつなぐまでは外の画面の登録の鍵)。アプリのサーバーは手元で検証でき、API は呼べない
|
|
9
|
+
* - iss はプロジェクトの管理画面のオリジン(https://<dest>)で、製品名の定数を持たない。skewSec は検証の時計のずれの許容(秒)
|
|
10
|
+
*/
|
|
11
|
+
export declare const SESSION_TOKEN: {
|
|
12
|
+
readonly ttlSec: 60;
|
|
13
|
+
readonly skewSec: 10;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* 画面のトークンのクレーム(aud はクライアントの ID、sub は見ている人の ID、dest はプロジェクトのホスト名、時刻は秒)
|
|
17
|
+
* - iss: 画面を開いた環境の CMS の URL(https://<dest> と、live 以外は環境を選ぶ頭 /env/<…>)。トークンの交換は iss の下のエンドポイントへ送る
|
|
18
|
+
* - env: 発行した環境の ID(交換はその環境でだけ通る)
|
|
19
|
+
* - prf: コアだけが作れる証明。アプリは検証に使わない(トークンの交換でコアが照合し、登録の鍵で自作した JWT を拒む)
|
|
20
|
+
*/
|
|
21
|
+
export type SessionTokenClaims = Readonly<{
|
|
22
|
+
iss: string;
|
|
23
|
+
aud: string;
|
|
24
|
+
sub: string;
|
|
25
|
+
dest: string;
|
|
26
|
+
env: string;
|
|
27
|
+
iat: number;
|
|
28
|
+
nbf: number;
|
|
29
|
+
exp: number;
|
|
30
|
+
jti: string;
|
|
31
|
+
prf: string;
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* 署名を確認した JWT のクレームが画面のトークンとして合うか、合えばクレーム
|
|
35
|
+
* - 発行者が https://<dest> かその下の /env/<…>、宛先 clientId、環境、期間、寿命。時計のずれは skewSec 秒まで
|
|
36
|
+
*/
|
|
37
|
+
export declare function sessionTokenClaimsOf(claims: Readonly<Record<string, unknown>>, clientId: string, nowSec: number): SessionTokenClaims | null;
|
|
38
|
+
/** 高さの範囲(px、host が丸める) */
|
|
39
|
+
export declare const BRIDGE_HEIGHT: {
|
|
40
|
+
readonly min: 80;
|
|
41
|
+
readonly max: 4000;
|
|
42
|
+
};
|
|
43
|
+
/** 知らせの回数の上限(iframe ごと、windowMs の間に max 件まで) */
|
|
44
|
+
export declare const BRIDGE_TOAST_LIMIT: {
|
|
45
|
+
readonly max: 3;
|
|
46
|
+
readonly windowMs: 10000;
|
|
47
|
+
};
|
|
48
|
+
/** 知らせと確認の文言の長さの上限 */
|
|
49
|
+
export declare const BRIDGE_TEXT_MAX = 200;
|
|
50
|
+
/** 深いリンクのパスの長さの上限 */
|
|
51
|
+
export declare const EMBED_PATH_MAX = 512;
|
|
52
|
+
/** API の依頼(サーバーのないアプリ)のメソッド */
|
|
53
|
+
export declare const BRIDGE_API_METHODS: readonly ["GET", "POST", "PUT", "PATCH", "DELETE"];
|
|
54
|
+
/** API の依頼のメソッド */
|
|
55
|
+
export type BridgeApiMethod = (typeof BRIDGE_API_METHODS)[number];
|
|
56
|
+
/**
|
|
57
|
+
* API の依頼のパスか(管理の API の /api/ の下だけ、長さは EMBED_PATH_MAX まで)
|
|
58
|
+
* - 親や同じ階層への移動、二重のスラッシュ、バックスラッシュ、符号化した区切り、制御文字、空白、シャープを含まない
|
|
59
|
+
*/
|
|
60
|
+
export declare const isBridgeApiPath: (v: unknown) => v is string;
|
|
61
|
+
/**
|
|
62
|
+
* 見た目のトークンの名前(実験的)
|
|
63
|
+
* - 管理画面の見た目の作り直しで名前と値が変わる。版で固定しないので、アプリは値がないときの既定を持つ
|
|
64
|
+
* - アプリの側では applyTheme が CSS の変数 --theme-<名前> として当てる
|
|
65
|
+
*/
|
|
66
|
+
export declare const BRIDGE_THEME_TOKENS: readonly ["accent", "text", "muted", "surface", "border", "radius", "font-family", "font-size"];
|
|
67
|
+
/** 見た目のトークンの名前 */
|
|
68
|
+
export type BridgeThemeToken = (typeof BRIDGE_THEME_TOKENS)[number];
|
|
69
|
+
/** アプリの側の CSS の変数の頭 */
|
|
70
|
+
export declare const BRIDGE_THEME_VAR_PREFIX = "--theme-";
|
|
71
|
+
/** 見た目(scheme は明暗、tokens は名前と CSS の値で、ない名前もある) */
|
|
72
|
+
export type BridgeTheme = Readonly<{
|
|
73
|
+
scheme: 'light' | 'dark';
|
|
74
|
+
tokens: Readonly<Partial<Record<BridgeThemeToken, string>>>;
|
|
75
|
+
}>;
|
|
76
|
+
/**
|
|
77
|
+
* 文脈(表示の補助で、信頼の根拠にしない。サーバーへの要求には ctx を付け、サーバーが鍵で開く)
|
|
78
|
+
* - embed: 登録の ID と表示名(インストールの後はインストール)
|
|
79
|
+
* - type・id: パネルと項目の入力のコレクションとレコード(新規のレコードは id が null)、メニューのページとアプリの設定は null
|
|
80
|
+
* - field: 項目の入力の項目の key(ほかの置き場所にはない)
|
|
81
|
+
* - path: メニューのページ、アプリの設定、ダイアログの登録の URL の下のパス(先頭の / なし、なければ空)
|
|
82
|
+
* - dialog: ダイアログとして開いたときの開いた側の値(ダイアログでなければ null)
|
|
83
|
+
* - account: 見ている人の ID とロール(名前とメールは渡さない)
|
|
84
|
+
* - ctx・ctxNext: 署名つきの文脈(URL のクエリ ctx・ctx_next と同じ値、取り直しは event の context)
|
|
85
|
+
*/
|
|
86
|
+
export type BridgeContext = Readonly<{
|
|
87
|
+
version: number;
|
|
88
|
+
project: string;
|
|
89
|
+
embed: Readonly<{
|
|
90
|
+
id: string;
|
|
91
|
+
label: string;
|
|
92
|
+
}>;
|
|
93
|
+
placement: EmbedPlacement;
|
|
94
|
+
collection: string | null;
|
|
95
|
+
id: string | null;
|
|
96
|
+
field?: string;
|
|
97
|
+
path: string;
|
|
98
|
+
account: Readonly<{
|
|
99
|
+
id: string;
|
|
100
|
+
role: string;
|
|
101
|
+
}>;
|
|
102
|
+
locale: string;
|
|
103
|
+
theme: BridgeTheme;
|
|
104
|
+
dialog: Readonly<{
|
|
105
|
+
data: unknown;
|
|
106
|
+
}> | null;
|
|
107
|
+
ctx: string;
|
|
108
|
+
ctxNext: string | null;
|
|
109
|
+
}>;
|
|
110
|
+
/** ダイアログの大きさ */
|
|
111
|
+
export declare const BRIDGE_DIALOG_SIZES: readonly ["small", "medium", "large", "full"];
|
|
112
|
+
/** ダイアログの大きさ */
|
|
113
|
+
export type BridgeDialogSize = (typeof BRIDGE_DIALOG_SIZES)[number];
|
|
114
|
+
/** 確認と外のページの回数の上限(iframe ごと、windowMs の間に max 回まで) */
|
|
115
|
+
export declare const BRIDGE_PROMPT_LIMIT: {
|
|
116
|
+
readonly max: 3;
|
|
117
|
+
readonly windowMs: 10000;
|
|
118
|
+
};
|
|
119
|
+
/** ダイアログを開く回数の上限(iframe ごと、windowMs の間に max 回まで)と、人が閉じた後に開き直せるまでの時間 */
|
|
120
|
+
export declare const BRIDGE_DIALOG_LIMIT: {
|
|
121
|
+
readonly max: 5;
|
|
122
|
+
readonly windowMs: 60000;
|
|
123
|
+
readonly reopenAfterMs: 3000;
|
|
124
|
+
};
|
|
125
|
+
/** ダイアログに渡す値と返す値の大きさの上限(JSON の文字数) */
|
|
126
|
+
export declare const BRIDGE_DATA_MAX = 16384;
|
|
127
|
+
/** 管理画面の中の行き先(URL の文字列では頼まない) */
|
|
128
|
+
export type BridgeTarget = Readonly<{
|
|
129
|
+
kind: 'list';
|
|
130
|
+
collection: string;
|
|
131
|
+
}> | Readonly<{
|
|
132
|
+
kind: 'record';
|
|
133
|
+
collection: string;
|
|
134
|
+
id: string | null;
|
|
135
|
+
}> | Readonly<{
|
|
136
|
+
kind: 'page';
|
|
137
|
+
embed: string;
|
|
138
|
+
path?: string;
|
|
139
|
+
}>;
|
|
140
|
+
/** 知らせの種類 */
|
|
141
|
+
export type BridgeToastTone = 'ok' | 'error';
|
|
142
|
+
/** アプリ → host の依頼(payload ごと、戻り値は BridgeResults) */
|
|
143
|
+
export type BridgeRequests = {
|
|
144
|
+
/** 高さ(px) */
|
|
145
|
+
resize: Readonly<{
|
|
146
|
+
height: number;
|
|
147
|
+
}>;
|
|
148
|
+
/** 管理画面の中の遷移 */
|
|
149
|
+
navigate: Readonly<{
|
|
150
|
+
to: BridgeTarget;
|
|
151
|
+
}>;
|
|
152
|
+
/** メニューのページとアプリの設定の中の遷移を管理画面の URL に写す(再読み込みと共有で同じ場所が開く) */
|
|
153
|
+
history: Readonly<{
|
|
154
|
+
path: string;
|
|
155
|
+
}>;
|
|
156
|
+
/** 知らせ(host のトースト、頭にアプリ名) */
|
|
157
|
+
toast: Readonly<{
|
|
158
|
+
text: string;
|
|
159
|
+
tone?: BridgeToastTone;
|
|
160
|
+
}>;
|
|
161
|
+
/** 確認のダイアログ(host が描く、destructive は削除などの取り返せない操作) */
|
|
162
|
+
confirm: Readonly<{
|
|
163
|
+
message: string;
|
|
164
|
+
destructive?: boolean;
|
|
165
|
+
}>;
|
|
166
|
+
/** 外のページを新しいタブで開く(host が行き先のドメインを出して確認する) */
|
|
167
|
+
open: Readonly<{
|
|
168
|
+
url: string;
|
|
169
|
+
}>;
|
|
170
|
+
/** 編集中のレコードの値の変更(パネルはコレクションの項目だけ、項目の入力はその項目だけを反映) */
|
|
171
|
+
setValues: Readonly<{
|
|
172
|
+
values: Readonly<Record<string, unknown>>;
|
|
173
|
+
}>;
|
|
174
|
+
/** 署名つきの文脈の取り直し */
|
|
175
|
+
refreshContext: Readonly<Record<string, never>>;
|
|
176
|
+
/** 同じ登録の画面をダイアログで開く(枠と閉じるボタンは host が描く、ダイアログの中からは開けない) */
|
|
177
|
+
openDialog: Readonly<{
|
|
178
|
+
path?: string;
|
|
179
|
+
size?: BridgeDialogSize;
|
|
180
|
+
data?: unknown;
|
|
181
|
+
}>;
|
|
182
|
+
/** ダイアログを閉じて、開いた側へ値を返す(ダイアログの中だけ) */
|
|
183
|
+
closeDialog: Readonly<{
|
|
184
|
+
result?: unknown;
|
|
185
|
+
}>;
|
|
186
|
+
/** 顧客の ID の表示名(EMBED_DISPLAY_NAMES_MAX 件まで。見ている人 ∩ アプリの能力 `op:@customers:read_display_name` が許すときだけ返る) */
|
|
187
|
+
displayNames: Readonly<{
|
|
188
|
+
ids: readonly string[];
|
|
189
|
+
}>;
|
|
190
|
+
/** 画面のトークン(寿命は SESSION_TOKEN.ttlSec 秒。アプリのサーバーへの要求ごとに Authorization に付ける) */
|
|
191
|
+
sessionToken: Readonly<Record<string, never>>;
|
|
192
|
+
/** 管理の API の依頼(サーバーのないアプリ)。host が人 ∩ インストールの能力の主体で実行する(host の側では絞らない) */
|
|
193
|
+
request: Readonly<{
|
|
194
|
+
method: BridgeApiMethod;
|
|
195
|
+
path: string;
|
|
196
|
+
body?: unknown;
|
|
197
|
+
}>;
|
|
198
|
+
};
|
|
199
|
+
/** 依頼の戻り値 */
|
|
200
|
+
export type BridgeResults = {
|
|
201
|
+
resize: null;
|
|
202
|
+
navigate: null;
|
|
203
|
+
history: null;
|
|
204
|
+
toast: null;
|
|
205
|
+
confirm: Readonly<{
|
|
206
|
+
confirmed: boolean;
|
|
207
|
+
}>;
|
|
208
|
+
open: Readonly<{
|
|
209
|
+
opened: boolean;
|
|
210
|
+
}>;
|
|
211
|
+
setValues: Readonly<{
|
|
212
|
+
applied: readonly string[];
|
|
213
|
+
}>;
|
|
214
|
+
refreshContext: Readonly<{
|
|
215
|
+
ctx: string;
|
|
216
|
+
ctxNext: string | null;
|
|
217
|
+
}>;
|
|
218
|
+
/** 閉じたときの値(人が閉じたときは null) */
|
|
219
|
+
openDialog: Readonly<{
|
|
220
|
+
result: unknown;
|
|
221
|
+
}>;
|
|
222
|
+
closeDialog: null;
|
|
223
|
+
/** 顧客の ID から表示名(許されないときは空、プロフィールのない顧客は入らない) */
|
|
224
|
+
displayNames: Readonly<{
|
|
225
|
+
names: Readonly<Record<string, string>>;
|
|
226
|
+
}>;
|
|
227
|
+
sessionToken: Readonly<{
|
|
228
|
+
token: string;
|
|
229
|
+
}>;
|
|
230
|
+
/** API の応答の状態の符号と本文(JSON でなければ null) */
|
|
231
|
+
request: Readonly<{
|
|
232
|
+
status: number;
|
|
233
|
+
body: unknown;
|
|
234
|
+
}>;
|
|
235
|
+
};
|
|
236
|
+
/** 依頼の種類 */
|
|
237
|
+
export type BridgeRequestKind = keyof BridgeRequests;
|
|
238
|
+
/** 依頼の種類の一覧 */
|
|
239
|
+
export declare const BRIDGE_REQUESTS: readonly ["resize", "navigate", "history", "toast", "confirm", "open", "setValues", "refreshContext", "openDialog", "closeDialog", "displayNames", "sessionToken", "request"];
|
|
240
|
+
/** host → アプリの知らせ(data ごと) */
|
|
241
|
+
export type BridgeEvents = {
|
|
242
|
+
/** 編集中のレコードの値(パネルはコレクションの項目、項目の入力はその項目だけ。握手と値の変更のたび) */
|
|
243
|
+
values: Readonly<{
|
|
244
|
+
values: Readonly<Record<string, unknown>>;
|
|
245
|
+
}>;
|
|
246
|
+
/** 新しい署名つきの文脈(開いている間の取り直し) */
|
|
247
|
+
context: Readonly<{
|
|
248
|
+
ctx: string;
|
|
249
|
+
ctxNext: string | null;
|
|
250
|
+
}>;
|
|
251
|
+
/** 見た目の変更 */
|
|
252
|
+
theme: BridgeTheme;
|
|
253
|
+
/** 管理画面の側の遷移(戻るなど)で、メニューのページとアプリの設定の下のパスが変わった */
|
|
254
|
+
route: Readonly<{
|
|
255
|
+
path: string;
|
|
256
|
+
}>;
|
|
257
|
+
};
|
|
258
|
+
/** 知らせの種類 */
|
|
259
|
+
export type BridgeEventName = keyof BridgeEvents;
|
|
260
|
+
/** 依頼の失敗の理由 */
|
|
261
|
+
export declare const BRIDGE_ERRORS: readonly ["unsupported", "invalid", "forbidden", "rate_limited", "failed"];
|
|
262
|
+
/** 依頼の失敗の理由 */
|
|
263
|
+
export type BridgeError = (typeof BRIDGE_ERRORS)[number];
|
|
264
|
+
/** 握手(window.postMessage): アプリ → host */
|
|
265
|
+
export type BridgeHello = Readonly<{
|
|
266
|
+
ns: typeof BRIDGE_NAMESPACE;
|
|
267
|
+
v: number;
|
|
268
|
+
kind: 'hello';
|
|
269
|
+
nonce: string;
|
|
270
|
+
}>;
|
|
271
|
+
/** 握手(window.postMessage、ports[0] にポート): host → アプリ */
|
|
272
|
+
export type BridgeInit = Readonly<{
|
|
273
|
+
ns: typeof BRIDGE_NAMESPACE;
|
|
274
|
+
v: number;
|
|
275
|
+
kind: 'init';
|
|
276
|
+
nonce: string;
|
|
277
|
+
context: BridgeContext;
|
|
278
|
+
}>;
|
|
279
|
+
/** 試みの nonce の形(16〜128字の英数字と - _) */
|
|
280
|
+
export declare const isBridgeNonce: (v: unknown) => v is string;
|
|
281
|
+
/** ポートの上の依頼 */
|
|
282
|
+
export type BridgeRequestMessage<K extends BridgeRequestKind = BridgeRequestKind> = Readonly<{
|
|
283
|
+
ns: typeof BRIDGE_NAMESPACE;
|
|
284
|
+
v: number;
|
|
285
|
+
id: number;
|
|
286
|
+
kind: K;
|
|
287
|
+
payload: BridgeRequests[K];
|
|
288
|
+
}>;
|
|
289
|
+
/** ポートの上の返事 */
|
|
290
|
+
export type BridgeResponseMessage = Readonly<{
|
|
291
|
+
ns: typeof BRIDGE_NAMESPACE;
|
|
292
|
+
v: number;
|
|
293
|
+
id: number;
|
|
294
|
+
ok: true;
|
|
295
|
+
result: unknown;
|
|
296
|
+
}> | Readonly<{
|
|
297
|
+
ns: typeof BRIDGE_NAMESPACE;
|
|
298
|
+
v: number;
|
|
299
|
+
id: number;
|
|
300
|
+
ok: false;
|
|
301
|
+
error: BridgeError;
|
|
302
|
+
message?: string;
|
|
303
|
+
}>;
|
|
304
|
+
/** ポートの上の知らせ */
|
|
305
|
+
export type BridgeEventMessage<E extends BridgeEventName = BridgeEventName> = Readonly<{
|
|
306
|
+
ns: typeof BRIDGE_NAMESPACE;
|
|
307
|
+
v: number;
|
|
308
|
+
kind: 'event';
|
|
309
|
+
name: E;
|
|
310
|
+
data: BridgeEvents[E];
|
|
311
|
+
}>;
|
|
312
|
+
/** 名前の頭と版を持つ値か */
|
|
313
|
+
export declare const isBridgeMessage: (data: unknown) => data is Readonly<{
|
|
314
|
+
ns: string;
|
|
315
|
+
v: number;
|
|
316
|
+
}>;
|
|
317
|
+
/** 深いリンクのパスとして正しいか(空は登録の URL そのもの) */
|
|
318
|
+
export declare function isEmbedPath(path: string): boolean;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/** 同意のチャネル */
|
|
2
|
+
export declare const CONSENT_CHANNELS: readonly ["email", "line", "sms"];
|
|
3
|
+
/** 同意のチャネル */
|
|
4
|
+
export type ConsentChannel = (typeof CONSENT_CHANNELS)[number];
|
|
5
|
+
/** 固定の目的(service は取引と手続きの連絡、marketing は宣伝) */
|
|
6
|
+
export declare const CONSENT_FIXED_PURPOSES: readonly ["service", "marketing"];
|
|
7
|
+
/** プロジェクトが宣言する目的の key の形 */
|
|
8
|
+
export declare const CONSENT_PURPOSE_KEY: RegExp;
|
|
9
|
+
/** 宣言できる目的の数の上限 */
|
|
10
|
+
export declare const CONSENT_PURPOSES_MAX = 20;
|
|
11
|
+
/** プロジェクトが宣言する目的(key と表示名) */
|
|
12
|
+
export type ConsentPurpose = Readonly<{
|
|
13
|
+
key: string;
|
|
14
|
+
label: string;
|
|
15
|
+
}>;
|
|
16
|
+
/** 同意の状態 */
|
|
17
|
+
export declare const CONSENT_STATES: readonly ["granted", "withdrawn"];
|
|
18
|
+
/** 同意の状態 */
|
|
19
|
+
export type ConsentState = (typeof CONSENT_STATES)[number];
|
|
20
|
+
/** 同意の取り方 */
|
|
21
|
+
export declare const CONSENT_METHODS: readonly ["form", "import", "staff", "line_follow", "api"];
|
|
22
|
+
/** 同意の取り方 */
|
|
23
|
+
export type ConsentMethod = (typeof CONSENT_METHODS)[number];
|
|
24
|
+
/** 抑止に勝つ本人の同意の取り方 */
|
|
25
|
+
export declare const RECONSENT_METHODS: readonly ConsentMethod[];
|
|
26
|
+
/** 同意と抑止の記録の出どころの種類(installation はインストール、api_key は配信 API の鍵と内側の呼び出し、account はアカウント、customer は人の代わり) */
|
|
27
|
+
export declare const CONSENT_SOURCE_KINDS: readonly ["installation", "api_key", "account", "customer"];
|
|
28
|
+
/** 同意の記録の出どころの種類 */
|
|
29
|
+
export type ConsentSourceKind = (typeof CONSENT_SOURCE_KINDS)[number];
|
|
30
|
+
/** 出どころの種類ごとに選べる取り方 */
|
|
31
|
+
export declare const CONSENT_METHODS_OF: Readonly<Record<ConsentSourceKind, readonly ConsentMethod[]>>;
|
|
32
|
+
/** 同意の記録(人 × チャネル × 目的の今の値、version は記録するたびに1上がる、verified は本人の証明つき) */
|
|
33
|
+
export type ConsentRecord = Readonly<{
|
|
34
|
+
channel: ConsentChannel;
|
|
35
|
+
purpose: string;
|
|
36
|
+
state: ConsentState;
|
|
37
|
+
method: ConsentMethod;
|
|
38
|
+
sourceKind: ConsentSourceKind;
|
|
39
|
+
sourceId: string;
|
|
40
|
+
verified: boolean;
|
|
41
|
+
recordedAt: string;
|
|
42
|
+
version: number;
|
|
43
|
+
}>;
|
|
44
|
+
/** 人の同意の一覧(blocked はチャネルごとのブロックの印、今は line だけ) */
|
|
45
|
+
export type CustomerConsents = Readonly<{
|
|
46
|
+
consents: readonly ConsentRecord[];
|
|
47
|
+
blocked: readonly ConsentChannel[];
|
|
48
|
+
}>;
|
|
49
|
+
/** 顧客の API の同意の記録(公開の JSON は snake_case、値は ConsentRecord と同じ) */
|
|
50
|
+
export type CustomerApiConsent = Readonly<{
|
|
51
|
+
channel: ConsentChannel;
|
|
52
|
+
purpose: string;
|
|
53
|
+
state: ConsentState;
|
|
54
|
+
method: ConsentMethod;
|
|
55
|
+
source_kind: ConsentSourceKind;
|
|
56
|
+
source_id: string;
|
|
57
|
+
verified: boolean;
|
|
58
|
+
recorded_at: string;
|
|
59
|
+
version: number;
|
|
60
|
+
}>;
|
|
61
|
+
/** 同意の記録を顧客の API の形に */
|
|
62
|
+
export declare const consentWire: (r: ConsentRecord) => CustomerApiConsent;
|
|
63
|
+
/** 顧客の API の同意の一覧(POST /customers/consents:query) */
|
|
64
|
+
export type CustomerApiConsents = Readonly<{
|
|
65
|
+
consents: readonly CustomerApiConsent[];
|
|
66
|
+
blocked: readonly ConsentChannel[];
|
|
67
|
+
}>;
|
|
68
|
+
/** 顧客の API の同意の記録の結果(POST /customers/consents、replayed は重複を除くキーの再送で記録しなかった) */
|
|
69
|
+
export type CustomerApiConsentResult = Readonly<{
|
|
70
|
+
consent: CustomerApiConsent;
|
|
71
|
+
replayed: boolean;
|
|
72
|
+
}>;
|
|
73
|
+
/** 抑止の一覧のすべての目的(記録の purpose) */
|
|
74
|
+
export declare const SUPPRESS_ALL_PURPOSES = "*";
|
|
75
|
+
/** 目的が使えるか(固定の目的か、宣言した目的) */
|
|
76
|
+
export declare const isConsentPurpose: (purpose: string, declared: readonly ConsentPurpose[]) => boolean;
|
|
77
|
+
/** 宛先の正規化(email は小文字、sms は E.164 の + と数字だけ、line は userId のまま。形が違えば null) */
|
|
78
|
+
export declare function normalizeAddress(channel: ConsentChannel, address: string): string | null;
|
|
79
|
+
/**
|
|
80
|
+
* 送れるかの判定の材料
|
|
81
|
+
* - consent: 人 × チャネル × 目的の記録(なければ undefined)、blocked: チャネルのブロック
|
|
82
|
+
* - suppressedAt: 宛先が抑止の一覧にあれば記録の時刻(目的が合う記録の最も新しいもの)、なければ null
|
|
83
|
+
* - sameAddress: 同意の記録の宛先が確認の宛先と同じか
|
|
84
|
+
* - closed: 人が退会か消えた
|
|
85
|
+
*/
|
|
86
|
+
export type ConsentFacts = Readonly<{
|
|
87
|
+
purpose: string;
|
|
88
|
+
consent: Pick<ConsentRecord, 'state' | 'method' | 'recordedAt' | 'verified'> | undefined;
|
|
89
|
+
blocked: boolean;
|
|
90
|
+
suppressedAt: string | null;
|
|
91
|
+
sameAddress: boolean;
|
|
92
|
+
closed: boolean;
|
|
93
|
+
}>;
|
|
94
|
+
/** 抑止に勝つ再同意か(本人の証明つきの form か line_follow の granted で、抑止より後、同じ宛先) */
|
|
95
|
+
export declare const reconsents: (f: ConsentFacts) => boolean;
|
|
96
|
+
/** 送れるか(ブロック、退会、取り消しは拒む。抑止は本人の証明つきの新しい再同意だけが勝つ。記録なしは service だけ送れる) */
|
|
97
|
+
export declare function consentAllows(f: ConsentFacts): boolean;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { CUSTOMER_EVENTS } from './customers.js';
|
|
2
|
+
type Range = Readonly<{
|
|
3
|
+
min: number;
|
|
4
|
+
max: number;
|
|
5
|
+
}>;
|
|
6
|
+
/** 顧客の設定の問題の文(値の範囲は customers.ts の上限から) */
|
|
7
|
+
export declare const customersSettingsIssues: (v: Readonly<{
|
|
8
|
+
graceSec: Range;
|
|
9
|
+
closedRetentionDays: Range;
|
|
10
|
+
providersMax: number;
|
|
11
|
+
consentPurposesMax: number;
|
|
12
|
+
invitePlaceholder: string;
|
|
13
|
+
algorithms: readonly string[];
|
|
14
|
+
}>) => {
|
|
15
|
+
readonly shape: "顧客の設定の形が不正";
|
|
16
|
+
readonly enabled: "有効は真偽";
|
|
17
|
+
readonly profileCollection: "プロフィールのコレクションはコレクションの id";
|
|
18
|
+
readonly graceSec: `\u7336\u4E88\u306F${number}\u304B\u3089${number}\u306E\u6574\u6570\uFF08\u79D2\uFF09`;
|
|
19
|
+
readonly closedRetentionDays: `\u9000\u4F1A\u306E\u4FDD\u6301\u306F${number}\u304B\u3089${number}\u306E\u6574\u6570\uFF08\u65E5\uFF09`;
|
|
20
|
+
readonly inviteUrl: `\u62DB\u5F85\u306E\u30EA\u30F3\u30AF\u306F ${string} \u3092\u542B\u3080 https \u306E URL`;
|
|
21
|
+
readonly providers: `\u767A\u884C\u8005\u306F${number}\u4EF6\u307E\u3067`;
|
|
22
|
+
readonly consentPurposes: `\u540C\u610F\u306E\u76EE\u7684\u306F${number}\u4EF6\u307E\u3067\u3067\u3001key \u306F\u82F1\u5C0F\u6587\u5B57\u3067\u59CB\u307E\u308B\u82F1\u5C0F\u6587\u5B57\u30FB\u6570\u5B57\u30FB_ \u306E32\u6587\u5B57\u307E\u3067\uFF08service \u3068 marketing \u3068\u91CD\u306A\u3089\u306A\u3044\uFF09\u3001\u8868\u793A\u540D\u306F\u7A7A\u3067\u306A\u3044\u6587\u5B57`;
|
|
23
|
+
readonly providerId: "発行者の id は英小文字・数字・ハイフンで、設定の中で一意";
|
|
24
|
+
readonly providerText: "発行者の表示名、iss、aud は空でない文字";
|
|
25
|
+
readonly issuer: "発行者の iss は https の URL";
|
|
26
|
+
readonly algorithms: `\u7F72\u540D\u306E\u65B9\u5F0F\u306F ${string} \u304B\u30891\u3064\u4EE5\u4E0A`;
|
|
27
|
+
readonly jwksHttps: "公開鍵の取得先は https の URL";
|
|
28
|
+
readonly jwksIp: "公開鍵の取得先のホストに IP アドレスは使えない";
|
|
29
|
+
readonly jwksOwn: "公開鍵の取得先に Tunasand のドメインは使えない";
|
|
30
|
+
};
|
|
31
|
+
/** 顧客のイベントの表示名(Webhook の選択肢) */
|
|
32
|
+
export declare const CUSTOMER_EVENT_LABELS: Readonly<Record<(typeof CUSTOMER_EVENTS)[keyof typeof CUSTOMER_EVENTS], string>>;
|
|
33
|
+
export {};
|