@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
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 NOPROBLEM
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,51 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @appgrowstack/app-contract
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
appgrowstackの約束の型。アプリのWorkerが `APPGROWSTACK`(appgrowstack-coreのService Binding)を呼ぶとき・端末のAPIの本文を作るときに使う。
|
|
4
|
+
|
|
5
|
+
- `schema/` のJSON Schemaから作った型(`TrackInput`・`IdentifyResult`・`CampaignSet` など)
|
|
6
|
+
- `APPGROWSTACK` のRPCの型 `AppGrowStackService` と、bindingの名前(`APPGROWSTACK_BINDING`・`APPGROWSTACK_SERVICE`・`APPGROWSTACK_ENTRYPOINT`)・誤りのcode `RPC_ERROR_CODES` と `AppGrowStackRpcError`・`rpcErrorCode`・`rpcErrorMessage`
|
|
7
|
+
- HTTPのAPIの型(`apiEndpoints`・`coreEndpoints`)・D1の表の定義・出来事の名前・触れた回数の数え方・RevenueCatのwebhookから `subscription` の入力を作る関数
|
|
8
|
+
|
|
9
|
+
入力の形は `schema/` を正とし、coreは受けた値をschemaで確かめる。ここに入れるのは型と、秘密を含まない小さな関数だけ。
|
|
10
|
+
|
|
11
|
+
## 入れる
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install @appgrowstack/app-contract
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```jsonc
|
|
18
|
+
// wrangler.jsonc
|
|
19
|
+
"services": [{ "binding": "APPGROWSTACK", "service": "appgrowstack-core", "entrypoint": "AppGrowStackRpc", "props": { "project": "<プロジェクトの id>" } }]
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import type { AppGrowStackService } from "@appgrowstack/app-contract"
|
|
24
|
+
|
|
25
|
+
type Env = { APPGROWSTACK: AppGrowStackService }
|
|
26
|
+
|
|
27
|
+
const { person_id } = await env.APPGROWSTACK.identify({ project: "reading-memory", actor: { install_id, uid }, at: Date.now() })
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
RPCの誤りは `name` で見分けない(workerdのService Bindingを通ると `name` は `Error` になる)。投げる側は `new AppGrowStackRpcError(code, message)` で `message` の頭に `[<code>] ` を書き、受ける側は `rpcErrorCode(error)` でcodeを読む(`RPC_ERROR_CODES`: `input`・`project`・`retry_later`・`rate_limited`・`forbidden`・`not_found`・`conflict`)。人に見せる文は `rpcErrorMessage(error)`。
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { rpcErrorCode } from "@appgrowstack/app-contract"
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
await env.APPGROWSTACK.subscription(input)
|
|
37
|
+
} catch (error) {
|
|
38
|
+
if (rpcErrorCode(error) === "input") return // 形が合わない。送り直さない
|
|
39
|
+
throw error
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
テストでは `@appgrowstack/app-testing` の偽の `APPGROWSTACK` を使う。
|
|
44
|
+
|
|
45
|
+
## バージョン
|
|
46
|
+
|
|
47
|
+
`package.json` の `version`。型を足しただけなら3つめ、型を変えた・消したときは2つめの数を上げる(1.0.0より前)。変わった中身は `CHANGELOG.md` に書く。公開はapp-growthの `scripts/publish-npm.sh contract <version>`。
|
|
48
|
+
|
|
49
|
+
## 開発
|
|
50
|
+
|
|
51
|
+
app-growthのモノリポの `packages/contract`。`schema/` を直したら `bun run gen && bun test`。
|