@tunasand/sdk 0.11.0 → 0.12.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 +16 -0
- package/README.md +6 -4
- package/dist/analytics.js +113 -50
- package/dist/app.js +98 -9
- package/dist/{apps-DIxAWBSZ.js → apps-BysPfMuR.js} +102 -12
- package/dist/{bridge-Dv4NxGZ7.js → bridge-C2Bl-OAF.js} +1 -2
- package/dist/bridge.js +1 -1
- package/dist/cli.js +2 -2
- package/dist/{collection-nUz1RetA.js → collection-26aglrg6.js} +20 -2
- package/dist/delivery.js +1 -1
- package/dist/{embeds-B-Dbn64k.js → embeds-DY6O5TrJ.js} +2 -2
- package/dist/end-users.js +29 -25
- package/dist/{errorLabels-aT2bnMsO.js → errorLabels-BK1NJ6Wz.js} +21 -5
- package/dist/i18n.js +2 -2
- package/dist/integrations.js +2 -2
- package/dist/{ja-CrY_72Tn.js → ja-B3lAaOhZ.js} +13 -11
- package/dist/{workflow-CUpl6hO_.js → paymentPort-p1jV44Zz.js} +57 -2
- package/dist/{schema-Dcg1ajnW.js → schema-Bs_BUUNv.js} +35 -7
- package/dist/schema.js +4 -4
- package/dist/types/access/src/handoff.d.ts +1 -1
- package/dist/types/access/src/oidc.d.ts +2 -0
- package/dist/types/contract/src/api/define.d.ts +165 -0
- package/dist/types/contract/src/app.d.ts +22 -7
- package/dist/types/contract/src/appChannels.d.ts +65 -27
- package/dist/types/contract/src/appDependencies.d.ts +22 -2
- package/dist/types/contract/src/appInbound.d.ts +26 -1
- package/dist/types/contract/src/appSecrets.d.ts +18 -0
- package/dist/types/contract/src/appServer.d.ts +57 -7
- package/dist/types/contract/src/apps.d.ts +15 -6
- package/dist/types/contract/src/auditActions.d.ts +2 -2
- package/dist/types/contract/src/auditLabels.d.ts +10 -1
- package/dist/types/contract/src/authorize.d.ts +1 -1
- package/dist/types/contract/src/bridge.d.ts +1 -1
- package/dist/types/contract/src/consents.d.ts +1 -6
- package/dist/types/contract/src/embeds.d.ts +11 -9
- package/dist/types/contract/src/endUsers.d.ts +3 -0
- package/dist/types/contract/src/errorLabels.d.ts +4 -1
- package/dist/types/contract/src/errorLabelsEn.d.ts +4 -1
- package/dist/types/contract/src/errors.d.ts +2 -2
- package/dist/types/contract/src/eventTraces.d.ts +0 -2
- package/dist/types/contract/src/hostingRpc.d.ts +21 -2
- package/dist/types/contract/src/import.d.ts +3 -3
- package/dist/types/contract/src/index.d.ts +16 -13
- package/dist/types/contract/src/issueLabels.d.ts +11 -3
- package/dist/types/contract/src/issueLabelsEn.d.ts +4 -0
- package/dist/types/contract/src/manage.d.ts +5 -0
- package/dist/types/contract/src/notices.d.ts +2 -3
- package/dist/types/contract/src/operationEffects.d.ts +39 -0
- package/dist/types/contract/src/operatorOperations.d.ts +104 -47
- package/dist/types/contract/src/paymentPort.d.ts +129 -0
- package/dist/types/contract/src/readPages.d.ts +92 -0
- package/dist/types/contract/src/roles.d.ts +2 -2
- package/dist/types/contract/src/settingProblems.d.ts +18 -1
- package/dist/types/contract/src/workflow.d.ts +5 -2
- package/dist/types/contract/src/workspaceItems.d.ts +3 -1
- package/dist/types/contract/src/workspacePaths.d.ts +1 -1
- package/dist/types/schema/src/collection.d.ts +4 -0
- package/dist/types/schema/src/file.d.ts +2 -0
- package/dist/types/schema/src/index.d.ts +3 -2
- package/dist/types/schema/src/indexes.d.ts +11 -0
- package/dist/types/schema/src/labels/en.d.ts +2 -0
- package/dist/types/schema/src/labels/ja.d.ts +13 -11
- package/dist/types/schema/src/problems.d.ts +13 -11
- package/dist/types/sdk/src/app.d.ts +11 -8
- package/dist/types/sdk/src/end-users.d.ts +12 -15
- package/dist/types/sdk/src/schema.d.ts +1 -1
- package/dist/{types-DkO2N7u2.js → types-CYnY-63C.js} +1 -1
- package/dist/types.js +1 -1
- package/dist/{typesSource-VJIxtN9b.js → typesSource-BTA9-rcB.js} +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as APP_MANIFEST_KEYS } from "./apps-
|
|
1
|
+
import { n as APP_MANIFEST_KEYS } from "./apps-BysPfMuR.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
// ../contract/src/import.ts
|
|
4
4
|
/** 1回のリクエストで取り込む件数の上限(画像の取得の時間と、本文の大きさの上限 JSON_BODY_MAX のため) */
|
|
@@ -145,4 +145,59 @@ function recordStateOf(row) {
|
|
|
145
145
|
}
|
|
146
146
|
/** 公開中か予約の状態か */
|
|
147
147
|
const isLiveState = (state) => state === "published" || state === "scheduled";
|
|
148
|
-
|
|
148
|
+
// ../contract/src/paymentPort.ts
|
|
149
|
+
/** ポートの id */
|
|
150
|
+
const PAYMENT_PORT = "tunasand:payment@1";
|
|
151
|
+
/** 価格の種類(one_time: 買い切り、recurring: 継続) */
|
|
152
|
+
const PRICE_KINDS = ["one_time", "recurring"];
|
|
153
|
+
/** 継続の周期 */
|
|
154
|
+
const PRICE_INTERVALS = ["month", "year"];
|
|
155
|
+
/** 通貨(ISO 4217の小文字。金額は通貨の最小の単位の整数) */
|
|
156
|
+
const PRICE_CURRENCIES = ["jpy", "usd"];
|
|
157
|
+
/** 購入の状態 */
|
|
158
|
+
const PURCHASE_STATUSES = ["paid", "refunded"];
|
|
159
|
+
/** 購読の状態(外部の決済のサービスの購読の状態の語) */
|
|
160
|
+
const SUBSCRIPTION_STATUSES = [
|
|
161
|
+
"incomplete",
|
|
162
|
+
"incomplete_expired",
|
|
163
|
+
"trialing",
|
|
164
|
+
"active",
|
|
165
|
+
"past_due",
|
|
166
|
+
"unpaid",
|
|
167
|
+
"paused",
|
|
168
|
+
"canceled"
|
|
169
|
+
];
|
|
170
|
+
/** 上限(名前の字数、金額、外部の ID とイベントの ID の字数、URL の字数、冪等キーの字数) */
|
|
171
|
+
const PAYMENT_LIMITS = {
|
|
172
|
+
nameMaxChars: 200,
|
|
173
|
+
amountMax: 99999999,
|
|
174
|
+
refMaxChars: 255,
|
|
175
|
+
urlMaxChars: 2e3,
|
|
176
|
+
idempotencyKeyMaxChars: 128
|
|
177
|
+
};
|
|
178
|
+
/** 価格の lookup_key(`<オファーの ID>.<価格の ID>`。価格は作った後に金額と周期を変えない) */
|
|
179
|
+
const priceLookupKeyOf = (offerId, priceId) => `${offerId}.${priceId}`;
|
|
180
|
+
z.string().max(PAYMENT_LIMITS.urlMaxChars).regex(/^https:\/\/\S+$/);
|
|
181
|
+
const ref = z.string().min(1).max(PAYMENT_LIMITS.refMaxChars);
|
|
182
|
+
const instant = z.iso.datetime({ offset: true });
|
|
183
|
+
/** 反映の共通の項目(eventId は外部のサービスのイベントの ID、observedAt はプロバイダーが外部の状態を取得した時刻) */
|
|
184
|
+
const reflectionBase = z.strictObject({
|
|
185
|
+
eventId: ref,
|
|
186
|
+
channelId: ref,
|
|
187
|
+
providerRef: ref,
|
|
188
|
+
offerId: ref,
|
|
189
|
+
priceId: ref,
|
|
190
|
+
endUserId: ref,
|
|
191
|
+
observedAt: instant
|
|
192
|
+
});
|
|
193
|
+
reflectionBase.extend({
|
|
194
|
+
status: z.enum(PURCHASE_STATUSES),
|
|
195
|
+
amount: z.number().int().min(0).max(PAYMENT_LIMITS.amountMax),
|
|
196
|
+
currency: z.enum(PRICE_CURRENCIES)
|
|
197
|
+
});
|
|
198
|
+
reflectionBase.extend({
|
|
199
|
+
status: z.enum(SUBSCRIPTION_STATUSES),
|
|
200
|
+
currentPeriodEnd: instant,
|
|
201
|
+
cancelAtPeriodEnd: z.boolean()
|
|
202
|
+
});
|
|
203
|
+
export { cyclicCollections as _, PRICE_KINDS as a, priceLookupKeyOf as c, NOTICES_PORT as d, manifestDocumentOf as f, ORIGIN_REF as g, IMPORT_ITEMS_MAX as h, PRICE_INTERVALS as i, isLiveState as l, IMPORT_EVENTS as m, PAYMENT_PORT as n, PURCHASE_STATUSES as o, END_USER_REF as p, PRICE_CURRENCIES as r, SUBSCRIPTION_STATUSES as s, PAYMENT_LIMITS as t, recordStateOf as u, importIdOf as v, importItemOfRow as y };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as CORE_COMPONENTS, t as declaredComponentsSchema } from "./declared-CE4a61qb.js";
|
|
2
2
|
import { f as problemText, l as problemFactory } from "./ja-axQPxMJ-.js";
|
|
3
|
-
import { n as SCHEMA_PROBLEM_MESSAGES } from "./ja-
|
|
4
|
-
import { A as
|
|
3
|
+
import { n as SCHEMA_PROBLEM_MESSAGES } from "./ja-B3lAaOhZ.js";
|
|
4
|
+
import { A as isSurveyShape, C as isInputField, D as isSequenceField, M as narrower, O as isSingleton, R as isFilesCollection, a as PII_CLASSES, b as initialValueOf, c as STATUS_CATEGORIES, d as cascadeDepths, f as cascadeTargetsOf, g as endUserFieldsOf, h as declaredAudienceOf, i as ON_DELETE, j as isUuidShape, l as acceptsRole, n as END_USER_FIELD_TYPE, o as SELF_OPS, r as FIELD_ROLES, s as SLUG_MODES, t as AUDIENCES, u as audienceOf, v as fieldPiiOf, w as isListCollection, y as hasPublication } from "./collection-26aglrg6.js";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
// ../schema/src/problems.ts
|
|
7
7
|
/** コンテンツスキーマの検査の問題を作る */
|
|
@@ -481,6 +481,31 @@ const missingCapabilities = (schema) => schema.collections.flatMap((collection)
|
|
|
481
481
|
...n,
|
|
482
482
|
collection
|
|
483
483
|
})));
|
|
484
|
+
// ../schema/src/indexes.ts
|
|
485
|
+
/** 1つのコレクションの索引の上限(仕組みの列と外部キーの列を除く。docs/specs/limits.md の「一覧と索引の上限」) */
|
|
486
|
+
const COLLECTION_INDEX_LIMITS = { indexesMax: 8 };
|
|
487
|
+
const INDEXABLE_TYPES = /* @__PURE__ */ new Set([
|
|
488
|
+
"text",
|
|
489
|
+
"select",
|
|
490
|
+
"status",
|
|
491
|
+
"boolean",
|
|
492
|
+
"number",
|
|
493
|
+
"date",
|
|
494
|
+
"datetime"
|
|
495
|
+
]);
|
|
496
|
+
/** 索引を宣言できるフィールドか */
|
|
497
|
+
const isIndexableField = (collection, f) => isListCollection(collection) && INDEXABLE_TYPES.has(f.type) && !("multiple" in f && f.multiple) && fieldPiiOf(collection, f) !== "sensitive";
|
|
498
|
+
/** 索引の宣言の誤り(宣言できないフィールドの true と、宣言の true の上限の超過。スキーマの保存で拒む) */
|
|
499
|
+
function indexProblems(collection) {
|
|
500
|
+
const declared = collection.fields.filter((f) => f.index === true);
|
|
501
|
+
return [...declared.filter((f) => !isIndexableField(collection, f)).map((f) => schemaProblemText("index_field_invalid", {
|
|
502
|
+
collection: collection.slug,
|
|
503
|
+
field: f.key
|
|
504
|
+
})), ...declared.length > COLLECTION_INDEX_LIMITS.indexesMax ? [schemaProblemText("indexes_too_many", {
|
|
505
|
+
collection: collection.slug,
|
|
506
|
+
max: COLLECTION_INDEX_LIMITS.indexesMax
|
|
507
|
+
})] : []];
|
|
508
|
+
}
|
|
484
509
|
// ../schema/src/fieldIds.ts
|
|
485
510
|
/** 内部の id の形(UUID v7 の正規の文字列) */
|
|
486
511
|
const FIELD_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
@@ -521,7 +546,8 @@ const base = {
|
|
|
521
546
|
pending_until: fieldKey.optional(),
|
|
522
547
|
computed: computed.optional(),
|
|
523
548
|
managed: z.enum(MANAGED_FIELDS).optional(),
|
|
524
|
-
pii: z.enum(PII_CLASSES).optional()
|
|
549
|
+
pii: z.enum(PII_CLASSES).optional(),
|
|
550
|
+
index: z.boolean().optional()
|
|
525
551
|
};
|
|
526
552
|
const frame = z.object({
|
|
527
553
|
when: condition.optional(),
|
|
@@ -744,7 +770,7 @@ const conditionsValid = (fields) => fields.every((f) => conditionValid(f.when, f
|
|
|
744
770
|
const nestedRules = (fields) => fields.flatMap((f) => (f.fields ?? []).flatMap((c) => [...c.derive || c.fixed_by ? [`${f.key}.${c.key}`] : [], ...nestedRules([c]).map((k) => `${f.key}.${k}`)]));
|
|
745
771
|
/**
|
|
746
772
|
* システムの値と同じ名前で、項目の key に使用できない名前(API・配信が項目の値を上書きするため)
|
|
747
|
-
* - すべてのコレクション: レコードの ID とスラッグ・作成と更新の日時・作成者、ワークスペースの一覧で参照する行の数 uses
|
|
773
|
+
* - すべてのコレクション: レコードの ID とスラッグ・作成と更新の日時・作成者、ワークスペースの一覧で参照する行の数 uses、一覧の持ち主の絞り込み owned
|
|
748
774
|
* - 公開の管理があるコレクション: 公開の機能の値
|
|
749
775
|
* - 対象外: API・配信の値に出ない列 type、導入先の設定で決まるアカウントの email・account_role
|
|
750
776
|
*/
|
|
@@ -754,7 +780,8 @@ const RESERVED = [
|
|
|
754
780
|
"created_at",
|
|
755
781
|
"created_by",
|
|
756
782
|
"updated_at",
|
|
757
|
-
"uses"
|
|
783
|
+
"uses",
|
|
784
|
+
"owned"
|
|
758
785
|
];
|
|
759
786
|
const RESERVED_EDITORIAL = [
|
|
760
787
|
"status",
|
|
@@ -1152,7 +1179,8 @@ const contentType = z.object({
|
|
|
1152
1179
|
...selfOpsProblems(asCollection),
|
|
1153
1180
|
...selfWritableProblems(asCollection),
|
|
1154
1181
|
...formProblems(asCollection),
|
|
1155
|
-
...kindProblems(asCollection)
|
|
1182
|
+
...kindProblems(asCollection),
|
|
1183
|
+
...indexProblems(asCollection)
|
|
1156
1184
|
];
|
|
1157
1185
|
for (const m of problems) ctx.addIssue({
|
|
1158
1186
|
code: "custom",
|
|
@@ -1264,4 +1292,4 @@ function parseSchema(json) {
|
|
|
1264
1292
|
if (!readable(json)) throw new Error("schema_unreadable");
|
|
1265
1293
|
return json;
|
|
1266
1294
|
}
|
|
1267
|
-
export {
|
|
1295
|
+
export { isIndexableField as a, DECLARED_COLLECTION_KINDS as c, parseSchema as i, schemaProblemText as l, RESERVED_FIELD_KEYS as n, AGGREGATE_BUCKETS as o, fieldDefSchema as r, AGGREGATE_OPS as s, COLLECTION_SLUG_PATTERN as t };
|
package/dist/schema.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { F as roleFieldOf, I as FILES_COLLECTION, N as optionLabelOf, P as optionsOf, b as initialValueOf, k as isStoredCollection, m as collectionOf, w as isListCollection, y as hasPublication } from "./collection-26aglrg6.js";
|
|
2
2
|
import { a as cropRect, c as stillOf, i as coverStart, l as createClock, n as publicPathOf, o as croppedHotspot, r as coverPosition, s as objectPosition, t as pagePathOf, u as isDateOnly } from "./page-yo1cw1kW.js";
|
|
3
|
-
import {
|
|
4
|
-
import { n as typesSourceOf, r as valueFieldsOf } from "./typesSource-
|
|
3
|
+
import { a as isIndexableField, i as parseSchema, l as schemaProblemText } from "./schema-Bs_BUUNv.js";
|
|
4
|
+
import { n as typesSourceOf, r as valueFieldsOf } from "./typesSource-BTA9-rcB.js";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
// ../schema/src/file.ts
|
|
7
7
|
const unit = z.number().min(0).max(1);
|
|
@@ -321,4 +321,4 @@ const DEFAULT_SCREENS = {
|
|
|
321
321
|
// ../contract/src/transfer.ts
|
|
322
322
|
/** スキーマと設定の形式の名前 */
|
|
323
323
|
const CONFIG_FORMAT = "tunasand-config";
|
|
324
|
-
export { CONFIG_FORMAT, DEFAULT_SCHEMA, DEFAULT_SCREENS, FILES_COLLECTION, collectionOf, coverPosition, coverStart, createClock, cropRect, croppedHotspot, dateRoleFieldsOf, fileRefSchema, initialValueOf, isDateOnly, isStoredCollection, mediaSchema, objectPosition, optionLabelOf, optionsOf, pagePathOf, parseSchema, parseScreens, publicPathOf, requiredPrimaryCollectionOf, roleFieldOf, sourceIdsOf, sourcesFieldOf, stillOf, typesSourceOf, valueFieldsOf };
|
|
324
|
+
export { CONFIG_FORMAT, DEFAULT_SCHEMA, DEFAULT_SCREENS, FILES_COLLECTION, collectionOf, coverPosition, coverStart, createClock, cropRect, croppedHotspot, dateRoleFieldsOf, fileRefSchema, initialValueOf, isDateOnly, isIndexableField, isStoredCollection, mediaSchema, objectPosition, optionLabelOf, optionsOf, pagePathOf, parseSchema, parseScreens, publicPathOf, requiredPrimaryCollectionOf, roleFieldOf, sourceIdsOf, sourcesFieldOf, stillOf, typesSourceOf, valueFieldsOf };
|
|
@@ -51,7 +51,7 @@ export type HandoffLoginOptions = Readonly<{
|
|
|
51
51
|
/** console からの引き継ぎのログイン */
|
|
52
52
|
export declare function handoffLogin({ secret, loginUrl, consume, projectOf, basePath, sessionTtlSec, now }: HandoffLoginOptions): LoginAuth;
|
|
53
53
|
/**
|
|
54
|
-
* 2つのログインを順に試す(emailOf は first が null なら second、ほかは first)
|
|
54
|
+
* 2つのログインを順に試す(emailOf と signedInAtOf は first が null なら second、ほかは first)
|
|
55
55
|
* - 用途: 引き継ぎのログインに加えて、運営者のログイン(apps/api の operator.ts)を受け付ける
|
|
56
56
|
*/
|
|
57
57
|
export declare function eitherLogin(first: LoginAuth, second: LoginAuth): LoginAuth;
|
|
@@ -4,6 +4,8 @@ import { type HostSession, type ProjectOfHost, type StartedSession } from './han
|
|
|
4
4
|
export type LoginAuth = {
|
|
5
5
|
/** 前段が要求ごとに確認した本人のメールアドレス(ヘッダーの JWT、手元の開発) */
|
|
6
6
|
emailOf(request: Request): Promise<string | null>;
|
|
7
|
+
/** emailOf のログインの本人の確認の時刻(ミリ秒、示せなければ null) */
|
|
8
|
+
signedInAtOf?(request: Request): Promise<number | null>;
|
|
7
9
|
/** Cookie のセッション(行と取り消しの照合はカーネル) */
|
|
8
10
|
sessionOf?(request: Request): Promise<HostSession | null>;
|
|
9
11
|
/** ログインの入り口の応答(対象外のパスは null) */
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Operation } from '../authorize.js';
|
|
3
|
+
import { type CollectionSize } from '../readPages.js';
|
|
4
|
+
/** 経路の区分(public は外に出す、internal は内部、undecided は未決) */
|
|
5
|
+
export declare const API_KINDS: readonly ["public", "internal", "undecided"];
|
|
6
|
+
export type ApiKind = (typeof API_KINDS)[number];
|
|
7
|
+
/** 経路が受け付ける資格(docs/specs/http-api.md の「資格の種類」) */
|
|
8
|
+
export declare const CREDENTIALS: readonly ["none", "session", "mcp", "account_token", "api_key", "installation", "end_user", "client", "mcp_worker", "preview_ticket", "operator"];
|
|
9
|
+
export type Credential = (typeof CREDENTIALS)[number];
|
|
10
|
+
/** 運営者のサポートのアクセスの範囲(closed は閉じる、area は範囲 admin の許可だけ、open は許可の範囲で開く。宣言なしは closed) */
|
|
11
|
+
export declare const OPERATOR_SCOPES: readonly ["open", "area", "closed"];
|
|
12
|
+
export type OperatorScope = (typeof OPERATOR_SCOPES)[number];
|
|
13
|
+
/** 運営者の許可の範囲の例外(trial は検証用のフラグのプロジェクトで加えて開く、emergency は非常の手順で加えて開く) */
|
|
14
|
+
export declare const OPERATOR_EXCEPTIONS: readonly ["trial", "emergency"];
|
|
15
|
+
export type OperatorException = (typeof OPERATOR_EXCEPTIONS)[number];
|
|
16
|
+
/** ワークスペースの経路の資格の組(人のログイン、MCP、人の代理のアプリ) */
|
|
17
|
+
export declare const PERSON: readonly ["session", "mcp"];
|
|
18
|
+
export declare const DELEGABLE: readonly ["session", "mcp", "account_token"];
|
|
19
|
+
/** 絞り込みの演算(配信の API の読み取りの文法と同じ) */
|
|
20
|
+
export declare const FILTER_OPS: readonly ["eq", "ne", "in", "gte", "lte", "begins", "exists"];
|
|
21
|
+
export type FilterOp = (typeof FILTER_OPS)[number];
|
|
22
|
+
/**
|
|
23
|
+
* 一覧の索引(索引の列は eq・order・id の順。昇順と降順で同じ索引)
|
|
24
|
+
* - table: 表(コレクションの表は c_<collection> の形)
|
|
25
|
+
* - eq: 先頭の等価の条件の列(一覧の宣言の filters で eq を許す列。in は索引の後の条件に限る)
|
|
26
|
+
* - order: 並べ替えのキー(1つ。最後に id を加える)
|
|
27
|
+
* - where: 部分索引の条件(ゴミ箱を持つ表は deleted_at IS NULL)
|
|
28
|
+
*/
|
|
29
|
+
export type ListIndex = Readonly<{
|
|
30
|
+
name: string;
|
|
31
|
+
table: string;
|
|
32
|
+
eq?: readonly string[];
|
|
33
|
+
order: string;
|
|
34
|
+
where?: string;
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* 一覧の宣言
|
|
38
|
+
* - keys: fixed はこの宣言のキーだけ、collection は加えて索引を宣言したフィールド(コンテンツスキーマの index、索引のないフィールドの絞り込みは走査の上限で打ち切る)
|
|
39
|
+
* - indexes: 並べ替えのキーごとの索引。並べ替えは1つのキーと id だけで、キーは indexes の order か bounded のどれか
|
|
40
|
+
* - bounded: 行の数に上限のある一覧(規模の上限の定数 COLLECTION_SIZE_LIMITS のある設定の表、コードとアプリの宣言)
|
|
41
|
+
* keys は並べ替えのキー、size は上限の定数のキー。索引を持たず、全行を読んで並べる
|
|
42
|
+
* - ordered: 1件の資源の値の配列の順の一覧(参照の項目、出典)。並べ替えは値の順(position)だけで、ページの分だけを読む
|
|
43
|
+
* - defaultOrder: 既定の並べ替え(先頭の - は降順)
|
|
44
|
+
* - filters: 絞り込みのキーと許す演算(索引の eq にない条件は索引の後の条件で、走査の上限で打ち切る)
|
|
45
|
+
* - omit: 一覧の既定の項目から除く項目(大きい値)。collection の一覧はリッチテキストを除く
|
|
46
|
+
* - limit: 既定と最大(省略は読み取りの共通の定数)
|
|
47
|
+
* - showDeleted: ゴミ箱の資源を含める指定を受けるか(並べ替えは -deleted_at に固定)
|
|
48
|
+
* - key: 行を一意に決める列(並べ替えのキーの後に加える列。省略は id。id を持たない複合の主キーの表は主キーの列で、ids の指定を受けない)
|
|
49
|
+
*/
|
|
50
|
+
export type ListSpec = Readonly<{
|
|
51
|
+
keys: 'fixed' | 'collection';
|
|
52
|
+
indexes: readonly ListIndex[];
|
|
53
|
+
bounded?: Readonly<{
|
|
54
|
+
keys: readonly string[];
|
|
55
|
+
size: CollectionSize;
|
|
56
|
+
}>;
|
|
57
|
+
ordered?: true;
|
|
58
|
+
defaultOrder: string;
|
|
59
|
+
filters: Readonly<Record<string, readonly FilterOp[]>>;
|
|
60
|
+
omit?: readonly string[];
|
|
61
|
+
limit?: Readonly<{
|
|
62
|
+
default: number;
|
|
63
|
+
max: number;
|
|
64
|
+
}>;
|
|
65
|
+
showDeleted?: boolean;
|
|
66
|
+
key?: readonly string[];
|
|
67
|
+
}>;
|
|
68
|
+
/** 行の数に上限のある一覧の宣言(order は並べ替えのキー、先頭の - は降順の既定。size は上限の定数のキーで、1ページで上限までの全件を返す) */
|
|
69
|
+
export declare const boundedList: (defaultOrder: string, size: CollectionSize) => ListSpec;
|
|
70
|
+
/**
|
|
71
|
+
* アプリのコレクションをレコードの口のページ(作成の新しい順、続きは口のカーソル)で読むアプリの経路の一覧の宣言
|
|
72
|
+
* - collection はマニフェストのコレクションの名前。索引の表は c_{<名前>}(インストールで決まるコレクションの表)
|
|
73
|
+
* - filters はレコードの口の where に渡す絞り込み(索引の後の条件で、走査の上限で打ち切る)
|
|
74
|
+
*/
|
|
75
|
+
export declare const appRecordList: (collection: string, filters?: ListSpec["filters"]) => ListSpec;
|
|
76
|
+
/** 1件の資源の値の配列の順の一覧の宣言 */
|
|
77
|
+
export declare const orderedList: ListSpec;
|
|
78
|
+
/** 一覧の並べ替えのキー(索引の order、bounded、配列の順の position) */
|
|
79
|
+
export declare const listOrderKeys: (spec: ListSpec) => ReadonlySet<string>;
|
|
80
|
+
/** 条件つきの取得の方式(etag は固定の費用で読み込み済みの版と主体から作る etag と304) */
|
|
81
|
+
export type CacheSpec = 'etag';
|
|
82
|
+
type ObjectSchema = z.ZodObject<z.ZodRawShape>;
|
|
83
|
+
/** 1つの経路の宣言 */
|
|
84
|
+
export type ApiRoute = Readonly<{
|
|
85
|
+
/** all は forward の経路とログインの入口だけ。put は形を変える前の経路だけ(対応表の段3で廃止) */
|
|
86
|
+
method: 'get' | 'post' | 'put' | 'patch' | 'delete' | 'all';
|
|
87
|
+
/** 文書の形のパス({name}、独自の操作は {id}:verb か集合の :verb) */
|
|
88
|
+
path: `/${string}`;
|
|
89
|
+
/** パスの残りを処理に委ねる経路(ログインの入口、プロジェクトの API の中継。パスの末尾は {rest}) */
|
|
90
|
+
forward?: true;
|
|
91
|
+
/** ルーターに登録せず、ルーターの前の処理が扱う経路(配信の API の入口、外部のサービスからの受信、公開鍵) */
|
|
92
|
+
outsideRouter?: true;
|
|
93
|
+
/** 操作の宣言を実行するだけの経路(判定は操作だけなので、委任の付与だけの人にも開く) */
|
|
94
|
+
operationOnly?: true;
|
|
95
|
+
kind: ApiKind;
|
|
96
|
+
credentials: readonly Credential[];
|
|
97
|
+
/** 運営者のサポートのアクセスの範囲(credentials に session を含む経路だけ) */
|
|
98
|
+
operator?: OperatorScope;
|
|
99
|
+
operatorAlso?: OperatorException;
|
|
100
|
+
/** 判定に使う読み取りの宣言か書き込みの操作の ID(認証のない経路は null) */
|
|
101
|
+
operation: string | null;
|
|
102
|
+
/**
|
|
103
|
+
* 能力の資格(api_key、installation)の主体に要る判定の関数の操作(エンドユーザーの API は対象 @end_users、配信の API はパスのコレクション)
|
|
104
|
+
* credentials に api_key を含む経路は必須。宣言した資格のそれぞれがこの操作を持てることを試験で検査する
|
|
105
|
+
*/
|
|
106
|
+
needs?: Operation;
|
|
107
|
+
/** OpenAPI の summary(英語の1文) */
|
|
108
|
+
summary: string;
|
|
109
|
+
request?: Readonly<{
|
|
110
|
+
params?: ObjectSchema;
|
|
111
|
+
query?: ObjectSchema;
|
|
112
|
+
body?: z.ZodType;
|
|
113
|
+
}>;
|
|
114
|
+
/** also: もう1つの成功の状態(既存の資源を返す作成の200、物理の削除や読めない書き手への204、承認の依頼になった保存の201)。本文は status と同じ形 */
|
|
115
|
+
response: Readonly<{
|
|
116
|
+
status: 200 | 201 | 204;
|
|
117
|
+
also?: 200 | 201 | 204;
|
|
118
|
+
body?: z.ZodType;
|
|
119
|
+
}>;
|
|
120
|
+
list?: ListSpec;
|
|
121
|
+
/** 件数の経路が絞り込みを借りる一覧のキー(同じ領域) */
|
|
122
|
+
countOf?: string;
|
|
123
|
+
cache?: CacheSpec;
|
|
124
|
+
/**
|
|
125
|
+
* 外部の標準の形に従う経路(作成の201と`:verb`の規則の外。docs/specs/http-api.md の「詳細、作成、更新、削除」)
|
|
126
|
+
* - oauth: トークンのエンドポイント(RFC 6749、RFC 8693)、login: ログインと同意の流れ、inbound: 外部のサービスからの受信
|
|
127
|
+
*/
|
|
128
|
+
protocol?: ApiProtocol;
|
|
129
|
+
}>;
|
|
130
|
+
/** 外部の標準の形に従う経路の種類 */
|
|
131
|
+
export declare const API_PROTOCOLS: readonly ["oauth", "login", "inbound"];
|
|
132
|
+
export type ApiProtocol = (typeof API_PROTOCOLS)[number];
|
|
133
|
+
/** 領域の経路の宣言(キーは領域の中で一意、OpenAPI の operationId は `<領域>_<キー>`(AI のツールの名前の文字に合わせる)) */
|
|
134
|
+
export type ApiArea = Readonly<{
|
|
135
|
+
area: string;
|
|
136
|
+
routes: Readonly<Record<string, ApiRoute>>;
|
|
137
|
+
}>;
|
|
138
|
+
export declare const defineArea: <const R extends Record<string, ApiRoute>>(area: string, routes: R) => Readonly<{
|
|
139
|
+
area: string;
|
|
140
|
+
routes: R;
|
|
141
|
+
}>;
|
|
142
|
+
/** パスのパラメーター(すべて文字列) */
|
|
143
|
+
export declare const pathParams: <K extends string>(...names: K[]) => z.ZodObject<Record<K, z.ZodString> extends infer T ? { -readonly [P in keyof T]: T[P]; } : never, z.core.$strip>;
|
|
144
|
+
/** 一覧の応答(data はページの資源、next_cursor は続きがない場合だけ null) */
|
|
145
|
+
export declare const pageOf: <T extends z.ZodType>(item: T) => z.ZodObject<{
|
|
146
|
+
data: z.ZodArray<T>;
|
|
147
|
+
next_cursor: z.ZodNullable<z.ZodString>;
|
|
148
|
+
}, z.core.$strip>;
|
|
149
|
+
/** 絞り込みつきの件数の応答(capped は件数の上限で打ち切った印) */
|
|
150
|
+
export declare const COUNT: z.ZodObject<{
|
|
151
|
+
count: z.ZodInt;
|
|
152
|
+
capped: z.ZodBoolean;
|
|
153
|
+
}, z.core.$strip>;
|
|
154
|
+
/** 型を文書に書かないオブジェクト(中身はコンテンツスキーマとアプリの宣言が決める) */
|
|
155
|
+
export declare const OBJECT: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
156
|
+
/** 日時(RFC 3339) */
|
|
157
|
+
export declare const DATETIME: z.ZodISODateTime;
|
|
158
|
+
/** 0以上の整数(JSON Schema に安全な整数の範囲を出さない) */
|
|
159
|
+
export declare const COUNT_INT: z.ZodInt;
|
|
160
|
+
/** レコードの値(項目はコンテンツスキーマ、_meta は値の形の文書のレコードのメタ情報で、fields の選択では省く) */
|
|
161
|
+
export declare const RECORD: z.ZodObject<{
|
|
162
|
+
id: z.ZodString;
|
|
163
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
164
|
+
}, z.core.$loose>;
|
|
165
|
+
export {};
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
+
import type { ApiRoute, DELEGABLE, ListSpec, PERSON } from './api/define.js';
|
|
1
2
|
import type { AppScope } from './appServer.js';
|
|
2
3
|
import type { SettingsArea } from './settings.js';
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
/**
|
|
5
|
+
* アプリの経路が受け付ける資格(マスタの PERSON か DELEGABLE の組)
|
|
6
|
+
* - DELEGABLE は委任された主体(人の代理のアプリと MCP の接続)にも開き、PERSON の経路は委任された主体を判定で拒む
|
|
7
|
+
*/
|
|
8
|
+
export type AppRouteCredentials = typeof PERSON | typeof DELEGABLE;
|
|
9
|
+
/**
|
|
10
|
+
* 経路の領域(主体の種類で通った呼び出しを、さらに領域の権限で絞る。広げない)
|
|
11
|
+
* - settings:<領域>・admin: 設定の領域と管理の領域の変更の権限
|
|
12
|
+
* - project: プロジェクトの値の読み取り(GET だけ)。MCP の接続はロール ∩ MCP の上限 ∩ 接続の段階でどこかを読めるときだけ
|
|
13
|
+
*/
|
|
14
|
+
export type AppRouteArea = `settings:${SettingsArea}` | 'admin' | 'project';
|
|
7
15
|
/** アプリの経路のメソッド */
|
|
8
|
-
export type AppRouteMethod = 'GET' | 'POST' | '
|
|
16
|
+
export type AppRouteMethod = 'GET' | 'POST' | 'PATCH' | 'DELETE';
|
|
9
17
|
/** 管理の API を呼ぶクライアント(path は /api から、呼んだ人の資格のまま) */
|
|
10
18
|
export type CmsClient = Readonly<{
|
|
11
19
|
fetch(path: `/api/${string}`, init?: RequestInit): Promise<Response>;
|
|
@@ -26,12 +34,19 @@ export type AppContext = Readonly<{
|
|
|
26
34
|
}>;
|
|
27
35
|
/** アプリの経路の管理の API のパス(アプリの経路は /api/apps/<名前空間> の下) */
|
|
28
36
|
export declare const appRoutePathOf: (namespace: string, path: `/${string}`) => `/${string}`;
|
|
29
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* アプリの経路(path はアプリの名前空間 /api/apps/<名前空間> からの経路、`:<名前>` は1つの区間。組み立ての後は appRoutePathOf のパス)
|
|
39
|
+
* - credentials・summary・response・list はマスタの経路の宣言と同じ意味
|
|
40
|
+
* - list: 応答は { data, next_cursor }。アプリのコレクションを読む一覧の索引の表は c_{<マニフェストのコレクションの名前>}、索引の名前は i_c_{<名前>}_<列>
|
|
41
|
+
*/
|
|
30
42
|
export type AppRoute = Readonly<{
|
|
31
43
|
method: AppRouteMethod;
|
|
32
44
|
path: `/${string}`;
|
|
33
|
-
|
|
45
|
+
credentials: AppRouteCredentials;
|
|
34
46
|
area?: AppRouteArea;
|
|
47
|
+
summary: string;
|
|
48
|
+
response: ApiRoute['response'];
|
|
49
|
+
list?: ListSpec;
|
|
35
50
|
handle: (request: Request, ctx: AppContext) => Promise<Response>;
|
|
36
51
|
}>;
|
|
37
52
|
/** 外への読み込みの宛先の宣言に URL が当たるか(宣言は https のオリジン、ホスト名の先頭の `*.` は1つ以上の区間。https だけ、ポートの指定なし) */
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { AppSettingDef, AppSettingValue } from './appDependencies.js';
|
|
2
2
|
import { type AppIdentityDeclaration } from './appIdentities.js';
|
|
3
3
|
import { type AppInboundDeclaration } from './appInbound.js';
|
|
4
|
-
import { type AppHmacCheck, type AppSecretDeclaration
|
|
4
|
+
import { type AppHmacCheck, type AppSecretDeclaration } from './appSecrets.js';
|
|
5
5
|
import type { AppPortResult, AppScope } from './appServer.js';
|
|
6
|
-
/**
|
|
7
|
-
export declare const CHANNEL_CAPABILITIES: readonly ["send", "receive"];
|
|
6
|
+
/** チャネルの能力(送信、受信、決済) */
|
|
7
|
+
export declare const CHANNEL_CAPABILITIES: readonly ["send", "receive", "payment"];
|
|
8
8
|
export type ChannelCapability = (typeof CHANNEL_CAPABILITIES)[number];
|
|
9
9
|
/** チャネルのアドレスの形(registered_domain: プロジェクトの登録したドメインの上のローカル部) */
|
|
10
10
|
export declare const CHANNEL_ADDRESS_KINDS: readonly ["registered_domain"];
|
|
@@ -13,17 +13,29 @@ export type ChannelAddressKind = (typeof CHANNEL_ADDRESS_KINDS)[number];
|
|
|
13
13
|
export declare const CHANNEL_KIND: RegExp;
|
|
14
14
|
/** チャネルの設定の型(コレクションの選択はチャネルの設定にしない) */
|
|
15
15
|
export declare const CHANNEL_SETTING_TYPES: readonly ["boolean", "text", "number", "select"];
|
|
16
|
-
/**
|
|
16
|
+
/** 宣言の上限(種類の数、見出しの字数、種類ごとの設定の数、設定の形の正規表現の字数) */
|
|
17
17
|
export declare const APP_CHANNEL_KIND_LIMITS: {
|
|
18
18
|
readonly kindsMax: 10;
|
|
19
19
|
readonly labelMaxChars: 80;
|
|
20
20
|
readonly settingsMax: 30;
|
|
21
|
+
readonly patternMaxChars: 500;
|
|
21
22
|
};
|
|
22
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* チャネルの設定の宣言
|
|
25
|
+
* - pattern: text の値(前後の空白を除いた値)の全体が一致する正規表現の本体(Unicode のフラグ。アンカーはコアが付ける)
|
|
26
|
+
* チャネルの値の検査はコアがこの宣言だけで行い、アプリは読んだ値を解釈するだけにする
|
|
27
|
+
*/
|
|
28
|
+
export type AppChannelSettingDef = AppSettingDef & Readonly<{
|
|
29
|
+
pattern?: string;
|
|
30
|
+
}>;
|
|
31
|
+
/** 設定の形の正規表現(宣言の pattern の全体の一致。誤った宣言は null) */
|
|
32
|
+
export declare function channelSettingPattern(pattern: string): RegExp | null;
|
|
33
|
+
/** チャネルの値の上限(名前の字数、文字の設定の値の字数、アドレスのローカル部の字数、外部のキーの字数) */
|
|
23
34
|
export declare const APP_CHANNEL_LIMITS: {
|
|
24
35
|
readonly nameMaxChars: 80;
|
|
25
36
|
readonly textSettingMaxChars: 2000;
|
|
26
37
|
readonly localMaxChars: 64;
|
|
38
|
+
readonly externalKeyMaxChars: 255;
|
|
27
39
|
};
|
|
28
40
|
/**
|
|
29
41
|
* マニフェストのチャネルの種類の宣言(channel_kinds の要素)
|
|
@@ -31,21 +43,30 @@ export declare const APP_CHANNEL_LIMITS: {
|
|
|
31
43
|
* - address: アドレスを持つ種類だけ(形は CHANNEL_ADDRESS_KINDS)
|
|
32
44
|
* - settings、secrets: チャネルごとの設定と秘密値(形はアプリの settings と secrets と同じ)
|
|
33
45
|
* - inbound: 外のサービスから受ける経路(受信の能力が要る)、identities: 本人の証明の発行者
|
|
46
|
+
* - external_key: 種類のチャネルが外部のサービスのアカウントのキーをモード(CHANNEL_MODES)ごとに持つ
|
|
47
|
+
* (1つ以上が要り、種類とモードの中でインスタンスの全体で一意)
|
|
48
|
+
* 1つの URL に全アカウントの分が届く送り手の受信を、このキーでチャネルに振り分ける(アプリの単位の受信、appInbound.ts)
|
|
34
49
|
*/
|
|
35
50
|
export type AppChannelKind = Readonly<{
|
|
36
51
|
kind: string;
|
|
37
52
|
label: string;
|
|
38
53
|
capabilities: readonly ChannelCapability[];
|
|
39
54
|
address?: ChannelAddressKind;
|
|
40
|
-
settings?: readonly
|
|
55
|
+
settings?: readonly AppChannelSettingDef[];
|
|
41
56
|
secrets?: readonly AppSecretDeclaration[];
|
|
42
57
|
inbound?: readonly AppInboundDeclaration[];
|
|
43
58
|
identities?: readonly AppIdentityDeclaration[];
|
|
59
|
+
external_key?: true;
|
|
44
60
|
}>;
|
|
45
61
|
/** マニフェストの channel_kinds の誤りの箇所(マニフェストの道) */
|
|
46
62
|
export declare function appChannelKindsProblems(kinds: unknown): string[];
|
|
47
63
|
/** マニフェストの channel_kinds の種類の宣言(なければ null) */
|
|
48
64
|
export declare const channelKindOf: (kinds: readonly AppChannelKind[] | undefined, kind: string) => AppChannelKind | null;
|
|
65
|
+
/** 外部のアカウントのモード(live は本番のアカウント、sandbox は live 以外の環境が繋ぐサンドボックスのアカウント) */
|
|
66
|
+
export declare const CHANNEL_MODES: readonly ["live", "sandbox"];
|
|
67
|
+
export type ChannelMode = (typeof CHANNEL_MODES)[number];
|
|
68
|
+
/** モードごとの外部のアカウントのキー */
|
|
69
|
+
export type ChannelExternalKeys = Readonly<Partial<Record<ChannelMode, string>>>;
|
|
49
70
|
/** チャネルのアドレス(ローカル部とドメインは小文字) */
|
|
50
71
|
export type ChannelAddress = Readonly<{
|
|
51
72
|
local: string;
|
|
@@ -56,6 +77,7 @@ export type ChannelAddress = Readonly<{
|
|
|
56
77
|
* - capabilities: このチャネルで使う能力(種類の宣言の能力の部分集合)
|
|
57
78
|
* - isDefault: プロジェクトのこの種類の既定のチャネル(送る側がチャネルを指定しないときに使う。種類ごとに1つまで)
|
|
58
79
|
* - settings: チャネルの設定の値(種類の宣言の settings のキーだけ。未入力のキーは含めない)
|
|
80
|
+
* - externalKeys: モードごとの外部のサービスのアカウントのキー(external_key の種類だけ、ほかは空)
|
|
59
81
|
*/
|
|
60
82
|
export type AppChannel = Readonly<{
|
|
61
83
|
id: string;
|
|
@@ -65,50 +87,66 @@ export type AppChannel = Readonly<{
|
|
|
65
87
|
address: ChannelAddress | null;
|
|
66
88
|
isDefault: boolean;
|
|
67
89
|
settings: Readonly<Record<string, AppSettingValue>>;
|
|
90
|
+
externalKeys: ChannelExternalKeys;
|
|
68
91
|
}>;
|
|
69
92
|
/**
|
|
70
|
-
*
|
|
71
|
-
* -
|
|
93
|
+
* チャネルの作成の本文(コアの POST /api/channels)
|
|
94
|
+
* - kind: マニフェストの channel_kinds の種類。installationId は、同じ種類を宣言したインストールが複数あるときだけ要る
|
|
95
|
+
* - capabilities: 種類の宣言の能力の部分集合(省略は種類の全部の能力)
|
|
72
96
|
* - address: registered_domain の種類では必須で、プロジェクトの検証済みのドメインの上のアドレス。ほかの種類は渡さない
|
|
73
|
-
* - settings: 種類の宣言の settings
|
|
97
|
+
* - settings: 種類の宣言の settings のキーと型と pattern に合う値だけ(空の文字は未入力)
|
|
98
|
+
* - 外部のキー(external_key の種類)は渡さない。運営者が運営者の API で登録する
|
|
74
99
|
*/
|
|
75
|
-
export type
|
|
100
|
+
export type ChannelCreateBody = Readonly<{
|
|
101
|
+
kind: string;
|
|
102
|
+
installationId?: string;
|
|
76
103
|
name: string;
|
|
77
|
-
capabilities
|
|
104
|
+
capabilities?: readonly ChannelCapability[];
|
|
78
105
|
address?: ChannelAddress;
|
|
79
|
-
isDefault
|
|
80
|
-
settings
|
|
106
|
+
isDefault?: boolean;
|
|
107
|
+
settings?: Readonly<Record<string, AppSettingValue>>;
|
|
108
|
+
}>;
|
|
109
|
+
/** チャネルの更新の本文(JSON Merge Patch。settings の null はその設定を消す) */
|
|
110
|
+
export type ChannelPatch = Readonly<{
|
|
111
|
+
name?: string;
|
|
112
|
+
capabilities?: readonly ChannelCapability[];
|
|
113
|
+
address?: ChannelAddress;
|
|
114
|
+
isDefault?: boolean;
|
|
115
|
+
settings?: Readonly<Record<string, AppSettingValue | null>>;
|
|
116
|
+
}>;
|
|
117
|
+
/** チャネルの秘密値の状態(値と末尾は返さない) */
|
|
118
|
+
export type ChannelSecretStatus = Readonly<{
|
|
119
|
+
key: string;
|
|
120
|
+
label: string;
|
|
121
|
+
configured: boolean;
|
|
122
|
+
updatedAt: string | null;
|
|
123
|
+
}>;
|
|
124
|
+
/** コアのチャネルの経路の資源(secrets は種類の宣言の順の秘密値の状態) */
|
|
125
|
+
export type ChannelView = AppChannel & Readonly<{
|
|
126
|
+
secrets: readonly ChannelSecretStatus[];
|
|
81
127
|
}>;
|
|
82
128
|
/**
|
|
83
129
|
* チャネルの口(マニフェストの channel_kinds で宣言した種類の、このアプリのインストールに結んだチャネルだけ)
|
|
84
130
|
* - list: プロジェクトのチャネル(止めたチャネルは含めない)、get: 1つ(ほかのアプリのチャネルと止めたチャネルは null)
|
|
85
131
|
* - channelId がこのインストールに結んだ宣言の種類のチャネルでなければ not_found(target は channel)
|
|
86
132
|
* - verifyHmac、configured: チャネルのこの環境の秘密値(種類の宣言の secrets のキーだけ。ほかは app_secret_undeclared の UsageError)
|
|
133
|
+
* - configuredOf: 結んだすべてのチャネルの秘密値の有無を1回で読む(チャネルの ID ごと)
|
|
134
|
+
* キーを宣言しない種類のチャネルは false、どの種類も宣言しないキーは app_secret_undeclared
|
|
87
135
|
* - egress: マニフェストの outbound の宣言に当たる外への要求で、auth にチャネルのこの環境の秘密値を載せる
|
|
88
|
-
* - create、update、remove、secrets、setSecret、deleteSecret: 経路を呼んだ人の操作(主体のない文脈は forbidden)
|
|
89
|
-
* チャネルの作成、変更、削除は設定の領域 integrations の権限、秘密値の入力と削除はそれに加えて連携の秘密値の管理の権限が要り、委任できない
|
|
90
|
-
* 作成と変更と削除はプロジェクトの全部の環境に効き、レジストリを書ける環境だけで行う(ほかは not_live)
|
|
91
|
-
* 値の誤りは invalid_input と issues、アドレスがほかのチャネルにあれば in_use、宣言のない種類は app_channel_undeclared の UsageError
|
|
92
|
-
* remove はチャネルを止め、この環境のチャネルの秘密値を消す(ほかの環境の秘密値は定期の処理が消す)
|
|
93
|
-
* secrets と setSecret は値を返さず、末尾だけを返す
|
|
94
136
|
* - inboundUrl: 種類の inbound の name の、このチャネルの受信の URL(外のサービスの管理画面に貼る値)
|
|
95
137
|
* 配信 API の公開の基点がない配置は null、宣言のない name は app_channel_undeclared の UsageError
|
|
138
|
+
* - inboundUrlsOf: 結んだすべてのチャネルの受信の URL(チャネルの ID ごと、name を宣言しない種類のチャネルは含めない。基点がない配置は null)
|
|
139
|
+
* チャネルの作成、変更、削除と秘密値の入力はコアの経路(/api/channels)で行い、口には置かない
|
|
96
140
|
*/
|
|
97
141
|
export type AppChannelsPort = Readonly<{
|
|
98
142
|
list: (scope: AppScope) => Promise<readonly AppChannel[]>;
|
|
99
143
|
get: (scope: AppScope, channelId: string) => Promise<AppChannel | null>;
|
|
100
144
|
verifyHmac: (scope: AppScope, channelId: string, key: string, check: AppHmacCheck) => Promise<AppPortResult<boolean>>;
|
|
101
145
|
configured: (scope: AppScope, channelId: string, key: string) => Promise<AppPortResult<boolean>>;
|
|
146
|
+
configuredOf: (scope: AppScope, key: string) => Promise<AppPortResult<Readonly<Record<string, boolean>>>>;
|
|
102
147
|
egress: (scope: AppScope, channelId: string, input: string | URL, init?: RequestInit) => Promise<AppPortResult<Response>>;
|
|
103
|
-
create: (scope: AppScope, kind: string, input: AppChannelInput) => Promise<AppPortResult<AppChannel>>;
|
|
104
|
-
update: (scope: AppScope, channelId: string, input: AppChannelInput) => Promise<AppPortResult<AppChannel>>;
|
|
105
|
-
remove: (scope: AppScope, channelId: string) => Promise<AppPortResult<void>>;
|
|
106
|
-
secrets: (scope: AppScope, channelId: string) => Promise<AppPortResult<readonly AppSecretState[]>>;
|
|
107
|
-
setSecret: (scope: AppScope, channelId: string, key: string, value: string) => Promise<AppPortResult<Readonly<{
|
|
108
|
-
tail: string | null;
|
|
109
|
-
}>>>;
|
|
110
|
-
deleteSecret: (scope: AppScope, channelId: string, key: string) => Promise<AppPortResult<void>>;
|
|
111
148
|
inboundUrl: (scope: AppScope, channelId: string, name: string) => Promise<AppPortResult<string | null>>;
|
|
149
|
+
inboundUrlsOf: (scope: AppScope, name: string) => Promise<AppPortResult<Readonly<Record<string, string>> | null>>;
|
|
112
150
|
}>;
|
|
113
151
|
/** 種類の宣言の秘密値のキー(outbound の auth が指せるキー) */
|
|
114
152
|
export declare const channelSecretKeysOf: (kinds: unknown) => string[];
|
|
@@ -64,19 +64,28 @@ Pick<Collection, 'kind' | 'time' | 'dimensions' | 'subject' | 'bucket' | 'measur
|
|
|
64
64
|
/**
|
|
65
65
|
* アプリの設定(key はドットで区切ると節の中の項目)
|
|
66
66
|
* - type の collection: 導入先のコレクションの id、空文字は選択なし。collections: コレクションの id の一覧
|
|
67
|
-
* channels: プロジェクトのチャネルの id
|
|
67
|
+
* channels: プロジェクトのチャネルの id の一覧(空は全部のチャネル)、accounts: プロジェクトのアカウントの id の一覧
|
|
68
|
+
* repeater: 繰り返しフィールド(各行は fields のキーと文字列の値の組、順序を保持。default は定義できない)
|
|
68
69
|
* - requires: 設定を使うのに要る任意の依存のアプリの id、min・unit: number の下限と単位
|
|
69
70
|
*/
|
|
70
71
|
export type AppSettingDef = Readonly<{
|
|
71
72
|
key: string;
|
|
72
73
|
label: string;
|
|
73
|
-
type: 'boolean' | 'text' | 'number' | 'select' | 'collection' | 'collections' | 'channels';
|
|
74
|
+
type: 'boolean' | 'text' | 'number' | 'select' | 'collection' | 'collections' | 'channels' | 'accounts' | 'repeater';
|
|
74
75
|
options?: readonly string[];
|
|
76
|
+
fields?: readonly AppSettingRowField[];
|
|
75
77
|
default?: AppSettingValue;
|
|
76
78
|
requires?: string;
|
|
77
79
|
min?: number;
|
|
78
80
|
unit?: string;
|
|
79
81
|
}>;
|
|
82
|
+
/** 繰り返しフィールド(repeater)の各行のフィールド(long_text は複数行、required は行ごとに必須) */
|
|
83
|
+
export type AppSettingRowField = Readonly<{
|
|
84
|
+
key: string;
|
|
85
|
+
label: string;
|
|
86
|
+
type: 'text' | 'long_text';
|
|
87
|
+
required?: boolean;
|
|
88
|
+
}>;
|
|
80
89
|
/** 値段(円、usage は従量の説明の文) */
|
|
81
90
|
export type AppPrice = Readonly<{
|
|
82
91
|
setup?: number;
|
|
@@ -180,9 +189,20 @@ export declare const appDependencyManifestSchema: z.ZodObject<{
|
|
|
180
189
|
select: "select";
|
|
181
190
|
collection: "collection";
|
|
182
191
|
collections: "collections";
|
|
192
|
+
accounts: "accounts";
|
|
183
193
|
channels: "channels";
|
|
194
|
+
repeater: "repeater";
|
|
184
195
|
}>;
|
|
185
196
|
options: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
197
|
+
fields: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
198
|
+
key: z.ZodString;
|
|
199
|
+
label: z.ZodString;
|
|
200
|
+
type: z.ZodEnum<{
|
|
201
|
+
text: "text";
|
|
202
|
+
long_text: "long_text";
|
|
203
|
+
}>;
|
|
204
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
205
|
+
}, z.core.$strict>>>;
|
|
186
206
|
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString, z.ZodNumber, z.ZodArray<z.ZodString>]>>;
|
|
187
207
|
requires: z.ZodOptional<z.ZodString>;
|
|
188
208
|
min: z.ZodOptional<z.ZodNumber>;
|