@appgrowstack/app-contract 0.0.0-stage → 0.1.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 +5 -0
- package/LICENSE +21 -0
- package/README.md +50 -2
- package/dist/access.d.ts +746 -0
- package/dist/access.js +144 -0
- package/dist/audience.d.ts +34 -0
- package/dist/audience.js +44 -0
- package/dist/creatives.d.ts +313 -0
- package/dist/creatives.js +301 -0
- package/dist/d1.d.ts +4791 -0
- package/dist/d1.js +1227 -0
- package/dist/events.d.ts +16 -0
- package/dist/events.js +27 -0
- package/dist/generated/schema.d.ts +17173 -0
- package/dist/generated/schema.js +4 -0
- package/dist/http.d.ts +3362 -0
- package/dist/http.js +349 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +16 -0
- package/dist/ledger.d.ts +16 -0
- package/dist/ledger.js +21 -0
- package/dist/prices.d.ts +25 -0
- package/dist/prices.js +41 -0
- package/dist/registry.d.ts +7 -0
- package/dist/registry.js +8 -0
- package/dist/revenuecat.d.ts +5 -0
- package/dist/revenuecat.js +43 -0
- package/dist/reviews.d.ts +10 -0
- package/dist/reviews.js +11 -0
- package/dist/rpc.d.ts +929 -0
- package/dist/rpc.js +111 -0
- package/dist/sessions.d.ts +34 -0
- package/dist/sessions.js +78 -0
- package/dist/touch.d.ts +28 -0
- package/dist/touch.js +49 -0
- package/package.json +34 -4
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReservedProjectId } from "./generated/schema.js";
|
|
2
|
+
/**
|
|
3
|
+
* プロジェクトの id にできない名前。console の組織の画面のパス(/:org/approvals・/:org/search など)とプロジェクトの id(/:org/:project)が
|
|
4
|
+
* 同じ階層に並ぶので、core はこの名前のプロジェクトを作らない(POST /v1/registry/projects が 400 invalid で断る・docs/design/console.md 3.1節)
|
|
5
|
+
*/
|
|
6
|
+
export declare const RESERVED_PROJECT_IDS: readonly ["approvals", "search", "audit", "settings", "login", "logout", "static", "new", "api", "portfolio", "findings", "hypotheses", "templates", "references"];
|
|
7
|
+
export declare function isReservedProjectId(id: string): id is ReservedProjectId;
|
package/dist/registry.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* プロジェクトの id にできない名前。console の組織の画面のパス(/:org/approvals・/:org/search など)とプロジェクトの id(/:org/:project)が
|
|
3
|
+
* 同じ階層に並ぶので、core はこの名前のプロジェクトを作らない(POST /v1/registry/projects が 400 invalid で断る・docs/design/console.md 3.1節)
|
|
4
|
+
*/
|
|
5
|
+
export const RESERVED_PROJECT_IDS = ["approvals", "search", "audit", "settings", "login", "logout", "static", "new", "api", "portfolio", "findings", "hypotheses", "templates", "references"];
|
|
6
|
+
export function isReservedProjectId(id) {
|
|
7
|
+
return RESERVED_PROJECT_IDS.includes(id);
|
|
8
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SubscriptionInput } from "./generated/schema.js";
|
|
2
|
+
/** 匿名でない id を app_user_id → aliases → original_app_user_id → transferred_to の順に選ぶ */
|
|
3
|
+
export declare function revenueCatUid(event: Record<string, unknown>): string | null;
|
|
4
|
+
/** webhook の本文({ event: {…} })から。足りなければ null(匿名だけの人も null) */
|
|
5
|
+
export declare function subscriptionInputOf(project: string, body: unknown): SubscriptionInput | null;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const ANONYMOUS_PREFIX = "$RCAnonymousID:";
|
|
2
|
+
const UID = /^[A-Za-z0-9._-]{1,128}$/;
|
|
3
|
+
const text = (v) => (typeof v === "string" && v.length > 0 && v.length <= 200 ? v : null);
|
|
4
|
+
const texts = (v) => (Array.isArray(v) ? v.map(text).filter((s) => s !== null) : []);
|
|
5
|
+
/** 匿名でない id を app_user_id → aliases → original_app_user_id → transferred_to の順に選ぶ */
|
|
6
|
+
export function revenueCatUid(event) {
|
|
7
|
+
const candidates = [text(event["app_user_id"]), ...texts(event["aliases"]), text(event["original_app_user_id"]), ...texts(event["transferred_to"])].filter((s) => s !== null);
|
|
8
|
+
const uid = candidates.find((id) => !id.startsWith(ANONYMOUS_PREFIX)) ?? null;
|
|
9
|
+
return uid !== null && UID.test(uid) ? uid : null;
|
|
10
|
+
}
|
|
11
|
+
/** webhook の本文({ event: {…} })から。足りなければ null(匿名だけの人も null) */
|
|
12
|
+
export function subscriptionInputOf(project, body) {
|
|
13
|
+
const event = body?.event;
|
|
14
|
+
if (typeof event !== "object" || event === null || Array.isArray(event))
|
|
15
|
+
return null;
|
|
16
|
+
const e = event;
|
|
17
|
+
const id = text(e["id"]);
|
|
18
|
+
const type = text(e["type"]);
|
|
19
|
+
const at = typeof e["event_timestamp_ms"] === "number" && Number.isFinite(e["event_timestamp_ms"]) ? Math.floor(e["event_timestamp_ms"]) : null;
|
|
20
|
+
const uid = revenueCatUid(e);
|
|
21
|
+
if (id === null || type === null || type.length > 64 || at === null || uid === null)
|
|
22
|
+
return null;
|
|
23
|
+
const environment = e["environment"] === "PRODUCTION" || e["environment"] === "SANDBOX" ? e["environment"] : null;
|
|
24
|
+
const period = text(e["period_type"]);
|
|
25
|
+
// K8-1: 商品・出ていた Offering・USD の値段・ストア。無い物は書かない(presented_offering_id は null も渡す)
|
|
26
|
+
const product = text(e["product_id"]);
|
|
27
|
+
const store = text(e["store"]);
|
|
28
|
+
const offering = e["presented_offering_id"] === null ? null : text(e["presented_offering_id"]);
|
|
29
|
+
const price = typeof e["price"] === "number" && Number.isFinite(e["price"]) ? e["price"] : null;
|
|
30
|
+
return {
|
|
31
|
+
project,
|
|
32
|
+
actor: { uid },
|
|
33
|
+
id,
|
|
34
|
+
type,
|
|
35
|
+
period_type: period !== null && period.length <= 64 ? period : null,
|
|
36
|
+
environment,
|
|
37
|
+
at,
|
|
38
|
+
...(product === null ? {} : { product_id: product }),
|
|
39
|
+
...("presented_offering_id" in e ? { presented_offering_id: offering } : {}),
|
|
40
|
+
...(price === null ? {} : { price_usd: price }),
|
|
41
|
+
...(store === null || store.length > 40 ? {} : { store }),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ReviewStore } from "./generated/schema.js";
|
|
2
|
+
export declare const REVIEW_STORES: readonly ["app_store", "google_play"];
|
|
3
|
+
/**
|
|
4
|
+
* 返事の字数の上限。JavaScript の文字列の長さ(UTF-16 の単位)で数える(コードポイントより多めに数えるので、ストアの数え方より厳しい側)。
|
|
5
|
+
* Google Play は reviews.reply の replyText が350字まで(https://developers.google.com/android-publisher/reply-to-reviews)。
|
|
6
|
+
* App Store は公式の文書に数が無く、App Store Connect の返事の欄の上限の5970字に合わせる(未確認)
|
|
7
|
+
*/
|
|
8
|
+
export declare const REVIEW_REPLY_LIMITS: Record<ReviewStore, number>;
|
|
9
|
+
/** 返事がストアの上限に入るか */
|
|
10
|
+
export declare function fitsReplyLimit(store: ReviewStore, body: string): boolean;
|
package/dist/reviews.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const REVIEW_STORES = ["app_store", "google_play"];
|
|
2
|
+
/**
|
|
3
|
+
* 返事の字数の上限。JavaScript の文字列の長さ(UTF-16 の単位)で数える(コードポイントより多めに数えるので、ストアの数え方より厳しい側)。
|
|
4
|
+
* Google Play は reviews.reply の replyText が350字まで(https://developers.google.com/android-publisher/reply-to-reviews)。
|
|
5
|
+
* App Store は公式の文書に数が無く、App Store Connect の返事の欄の上限の5970字に合わせる(未確認)
|
|
6
|
+
*/
|
|
7
|
+
export const REVIEW_REPLY_LIMITS = { app_store: 5970, google_play: 350 };
|
|
8
|
+
/** 返事がストアの上限に入るか */
|
|
9
|
+
export function fitsReplyLimit(store, body) {
|
|
10
|
+
return body.trim().length > 0 && body.length <= REVIEW_REPLY_LIMITS[store];
|
|
11
|
+
}
|