Skip to content

Commit 445183c

Browse files
authored
Merge pull request #2 from InsForge/docs/pre-release
Docs, Apache-2.0 license, and 7→2 package consolidation (publish-ready)
2 parents dff2d92 + bd949d9 commit 445183c

161 files changed

Lines changed: 1428 additions & 420 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yaml

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ on:
77
pull_request:
88

99
jobs:
10-
# The workspace now contains a Flutter package (packages/insforge), so the
10+
# The workspace contains a Flutter package (packages/insforge_flutter), so the
1111
# whole workspace must be resolved with the Flutter toolchain (which bundles
12-
# Dart). The pure-Dart feature packages are still tested with `dart test`.
12+
# Dart). The pure-Dart `insforge` package is tested with `dart test`.
1313
analyze-and-test:
1414
runs-on: ubuntu-latest
1515
steps:
@@ -21,27 +21,14 @@ jobs:
2121
run: flutter pub get
2222
- name: Analyze
2323
run: dart analyze .
24-
- name: Test insforge_core
25-
working-directory: packages/insforge_core
26-
run: dart test
27-
- name: Test insforge_auth
28-
working-directory: packages/insforge_auth
29-
run: dart test
30-
- name: Test insforge_database
31-
working-directory: packages/insforge_database
32-
run: dart test
33-
- name: Test insforge_storage
34-
working-directory: packages/insforge_storage
35-
run: dart test
36-
- name: Test insforge_functions
37-
working-directory: packages/insforge_functions
38-
run: dart test
39-
- name: Test insforge_ai
40-
working-directory: packages/insforge_ai
41-
run: dart test
42-
- name: Analyze insforge (umbrella)
24+
- name: Check version is in sync (both packages + version.dart)
25+
run: dart run tool/set_version.dart --check
26+
- name: Test insforge (pure Dart)
4327
working-directory: packages/insforge
28+
run: dart test
29+
- name: Analyze insforge_flutter
30+
working-directory: packages/insforge_flutter
4431
run: flutter analyze
45-
- name: Test insforge (umbrella)
46-
working-directory: packages/insforge
32+
- name: Test insforge_flutter
33+
working-directory: packages/insforge_flutter
4734
run: flutter test

CHANGELOG.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Changelog
2+
3+
All notable changes to the InsForge Dart/Flutter SDK are documented here. This
4+
project follows [Semantic Versioning](https://semver.org) and
5+
[Keep a Changelog](https://keepachangelog.com).
6+
7+
## 0.1.0
8+
9+
Initial release.
10+
11+
### Added
12+
13+
- **`insforge` (pure Dart)** — the shared, framework-agnostic SDK:
14+
- `InsforgeHttpClient`: auth-header injection, single-flight 401 token
15+
refresh, typed `InsforgeException` error mapping.
16+
- **Auth**: email/password sign-up & sign-in, code-based email verification,
17+
PKCE OAuth (`getOAuthUrl` / `handleOAuthCallback`), sessions with proactive
18+
refresh, profiles, and a broadcast `onAuthStateChange` stream.
19+
- **Database**: PostgREST-style query builder — filters (including multiple
20+
AND-ed conditions per column), ordering, pagination, `single`/`count`,
21+
`insert`/`update`/`delete`/`upsert`, and RPC.
22+
- **Storage**: buckets and objects — multipart upload, download, list,
23+
delete, public URLs, the upload/download strategy flow, and presigned S3
24+
`uploadLarge`.
25+
- **Functions**: edge-function invocation across all HTTP verbs.
26+
- **AI**: standalone OpenRouter (OpenAI-compatible) client — chat
27+
completions with SSE streaming, embeddings, images, and model listing.
28+
- `SessionStorage` interface + `InMemorySessionStorage`.
29+
- `InsforgeClient` aggregator wiring every module onto one shared transport.
30+
- **`insforge_flutter`** — the Flutter integration layer:
31+
- `SecureSessionStorage` backed by `flutter_secure_storage`.
32+
- `Insforge.initialize(...)` / `Insforge.instance` singleton that restores a
33+
persisted session before the first frame.

CONTRIBUTING.md

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
# Contributing to the InsForge Dart/Flutter SDK
2+
3+
Thanks for helping improve the SDK! This guide covers the repository layout,
4+
local setup, testing, and the conventions we follow.
5+
6+
## Repository layout
7+
8+
This is a [Dart pub workspace](https://dart.dev/tools/pub/workspaces) (a
9+
monorepo resolved together):
10+
11+
```
12+
packages/
13+
insforge/ # pure-Dart SDK (auth, database, storage, functions, ai)
14+
insforge_flutter/ # Flutter layer: SecureSessionStorage + Insforge singleton
15+
integration_tests/ # live, against-a-real-project tests (opt-in via env vars)
16+
samples/
17+
twitter_app/ # full Flutter sample app
18+
```
19+
20+
`insforge_flutter` depends on and re-exports `insforge`.
21+
22+
## Prerequisites
23+
24+
- Flutter ≥ 3.24 (bundles a compatible Dart ≥ 3.5). `flutter --version` and
25+
`dart --version` must both work.
26+
- Because the workspace contains a Flutter package, resolve it with **`flutter
27+
pub get`** (not `dart pub get`) from the repo root.
28+
29+
```bash
30+
flutter pub get
31+
```
32+
33+
## Running the checks
34+
35+
Everything must pass before a change is merged.
36+
37+
```bash
38+
# Static analysis (whole workspace)
39+
dart analyze .
40+
41+
# Pure-Dart unit tests
42+
cd packages/insforge && dart test
43+
44+
# Flutter unit tests
45+
cd packages/insforge_flutter && flutter test
46+
```
47+
48+
Formatting must be clean:
49+
50+
```bash
51+
dart format .
52+
```
53+
54+
The analyzer config (`analysis_options.yaml`) enables stricter lints —
55+
notably `require_trailing_commas`, `prefer_single_quotes`, and
56+
`avoid_print`. CI runs `dart analyze .` plus every package's tests and fails
57+
on any issue.
58+
59+
## Integration tests (live backend)
60+
61+
`integration_tests/` exercises the SDK against a real InsForge project. With no
62+
environment variables set, **every test skips** — so it's safe in normal CI.
63+
To run it, provide a project and a pre-verified account:
64+
65+
```bash
66+
cd integration_tests
67+
INSFORGE_INTEGRATION_BASE_URL=https://<project>.insforge.app \
68+
INSFORGE_INTEGRATION_ANON_KEY=<anon-key> \
69+
INSFORGE_INTEGRATION_TEST_EMAIL=<verified-account-email> \
70+
INSFORGE_INTEGRATION_TEST_PASSWORD=<password> \
71+
INSFORGE_INTEGRATION_API_KEY=<project-api-key> \ # for storage
72+
INSFORGE_INTEGRATION_OPENROUTER_KEY=<openrouter-key> \ # for ai
73+
dart test
74+
```
75+
76+
See `integration_tests/README.md` for the required backend schema (the
77+
`sdk_test` table, a `public` bucket, and a `hello-world` function). Never
78+
commit real keys — keep them in your shell.
79+
80+
## Coding conventions
81+
82+
- **Models** use hand-written `fromJson`/`toJson` (no codegen). Be tolerant of
83+
missing/optional fields the backend may omit.
84+
- **Errors**: throw the typed `InsforgeException` hierarchy; don't return
85+
`{data, error}` tuples.
86+
- **No Flutter in `insforge`**: the `insforge` package must stay pure Dart so it
87+
runs under `dart test`. Anything needing Flutter belongs in
88+
`insforge_flutter`.
89+
- Keep the public API stable; document deviations from the backend contract.
90+
91+
## Commit messages
92+
93+
We use [Conventional Commits](https://www.conventionalcommits.org):
94+
95+
```
96+
feat(database): accumulate multiple filters per column
97+
fix(auth): tolerate signUp response without a user
98+
test(integration): cover the email verification flow
99+
docs(readme): document the AI module
100+
```
101+
102+
Scopes are typically a module name (`auth`, `database`, `storage`,
103+
`functions`, `ai`, `core`) or `sample` / `integration` / `ci`.
104+
105+
## Versioning & releasing
106+
107+
`insforge` and `insforge_flutter` are released **in lockstep** — they always
108+
share the same version number. The version lives in three places that must stay
109+
in sync:
110+
111+
- `packages/insforge/pubspec.yaml``version:`
112+
- `packages/insforge_flutter/pubspec.yaml``version:` **and** its
113+
`insforge: ^<version>` dependency constraint
114+
- `packages/insforge/lib/src/core/version.dart``insforgeSdkVersion`
115+
(a generated constant; the runtime `User-Agent` is `InsForge-Dart/<version>`)
116+
117+
Don't edit these by hand — use the tool, which updates all of them at once:
118+
119+
```bash
120+
dart run tool/set_version.dart 0.2.0 # set the version everywhere
121+
dart run tool/set_version.dart --check # verify they're in sync (CI runs this)
122+
```
123+
124+
`version.dart` is generated; never edit it directly. CI fails if the three drift
125+
apart.
126+
127+
### Release checklist
128+
129+
1. `dart run tool/set_version.dart <new-version>`.
130+
2. Add a `## <new-version>` section to each package's `CHANGELOG.md`.
131+
3. Commit, open a PR, merge to `main`.
132+
4. Tag the release: `git tag v<new-version> && git push --tags`.
133+
5. Publish **in order** (the Flutter package depends on the Dart one):
134+
```bash
135+
cd packages/insforge && dart pub publish # wait until it's live
136+
cd ../insforge_flutter && dart pub publish
137+
```
138+
139+
> Note on 0.x: under SemVer, `^0.1.0` means `>=0.1.0 <0.2.0`. Bumping the minor
140+
> (e.g. `0.1.x → 0.2.0`) is a breaking change, and the tool updates
141+
> `insforge_flutter`'s `insforge: ^…` constraint accordingly so it picks up the
142+
> new core.
143+
144+
## Pull requests
145+
146+
1. Branch off `main`.
147+
2. Make the change with tests; keep `dart analyze .` and all suites green.
148+
3. If a change is driven by real backend behavior, add or update an integration
149+
test that proves it.
150+
4. Update `CHANGELOG.md` under the unreleased/next version.
151+
5. Open a PR describing the change and how you verified it.
152+
153+
By contributing, you agree that your contributions are licensed under the
154+
project's [Apache License 2.0](LICENSE).

0 commit comments

Comments
 (0)