Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ import { Model } from 'effect/unstable/schema';
import { Firestore } from 'effect-firebase';

class AuthorModel extends Model.Class<AuthorModel>('AuthorModel')({
id: Model.Generated(AuthorId), // generic helpers from Effect's Model
id: Model.GeneratedByDb(AuthorId), // generic helpers from Effect's Model
createdAt: Firestore.DateTimeInsert, // Firestore-specific helpers from effect-firebase
updatedAt: Firestore.DateTimeUpdate,
author: Firestore.Reference(AuthorId, 'authors'),
Expand All @@ -110,7 +110,7 @@ Generic field helpers that no longer need the `effect-firebase` import:
| Field helper | Now from |
| ---------------------- | ------------------------ |
| `Model.Class` | `effect/unstable/schema` |
| `Model.Generated` | `effect/unstable/schema` |
| `Model.GeneratedByDb` | `effect/unstable/schema` |
| `Model.GeneratedByApp` | `effect/unstable/schema` |
| `Model.Sensitive` | `effect/unstable/schema` |
| `Model.FieldOption` | `effect/unstable/schema` |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const PostId = Schema.String.pipe(Schema.brand('PostId'));
const AuthorId = Schema.String.pipe(Schema.brand('AuthorId'));

class PostModel extends Model.Class<PostModel>('PostModel')({
id: Model.Generated(PostId),
id: Model.GeneratedByDb(PostId),
createdAt: Model.DateTimeInsert,
updatedAt: Model.DateTimeUpdate,
author: Model.Reference(AuthorId, 'authors'),
Expand Down
4 changes: 2 additions & 2 deletions example/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"dependencies": {
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"effect": "^4.0.0-beta.43",
"@effect/platform-browser": "^4.0.0-beta.43",
"effect": "^4.0.0-beta.70",
"@effect/platform-browser": "^4.0.0-beta.70",
"firebase": "^12.8.0",
"tailwind-merge": "^3.4.0",
"react": "19.2.4",
Expand Down
2 changes: 1 addition & 1 deletion example/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"packageManager": "pnpm@10.25.0",
"dependencies": {
"effect": "^4.0.0-beta.43",
"effect": "^4.0.0-beta.70",
"firebase-admin": "^13.6.0",
"@google-cloud/functions-framework": "^5.0.0",
"@effect-firebase/admin": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion example/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"!**/*.tsbuildinfo"
],
"dependencies": {
"effect": "^4.0.0-beta.43",
"effect": "^4.0.0-beta.70",
"tslib": "^2.3.0"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion example/shared/src/models/author.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const AuthorId = Schema.String.pipe(Schema.brand('AuthorId'));
export const AuthorRef = Firestore.Reference(AuthorId, 'authors');

export class AuthorModel extends Model.Class<AuthorModel>('AuthorModel')({
id: Model.Generated(AuthorId),
id: Model.GeneratedByDb(AuthorId),
createdAt: Firestore.DateTimeInsert,
updatedAt: Firestore.DateTimeUpdate,
name: Schema.String,
Expand Down
2 changes: 1 addition & 1 deletion example/shared/src/models/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const PostId = Schema.String.pipe(Schema.brand('PostId'));
export const PostRef = Firestore.Reference(PostId, 'posts');

export class PostModel extends Model.Class<PostModel>('PostModel')({
id: Model.Generated(PostId),
id: Model.GeneratedByDb(PostId),
createdAt: Firestore.DateTimeInsert,
updatedAt: Firestore.DateTimeUpdate,
author: AuthorRef,
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
"private": true,
"dependencies": {
"@google-cloud/functions-framework": "^5.0.2",
"effect": "^4.0.0-beta.43",
"effect": "^4.0.0-beta.70",
"firebase": "^12.10.0",
"firebase-admin": "^13.7.0",
"firebase-functions": "^7.1.0",
"react": "19.2.4",
"react-dom": "19.2.4"
},
"devDependencies": {
"@effect/platform-browser": "^4.0.0-beta.43",
"@effect/vitest": "^4.0.0-beta.43",
"@effect/platform-browser": "^4.0.0-beta.70",
"@effect/vitest": "^4.0.0-beta.70",
"@eslint/js": "^9.8.0",
"@nx/esbuild": "22.5.4",
"@nx/eslint": "22.5.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
"tslib": "^2.3.0"
},
"devDependencies": {
"effect": "^4.0.0-beta.43",
"effect": "^4.0.0-beta.70",
"effect-firebase": "workspace:*",
"firebase": "^12.10.0",
"firebase-admin": "^13.7.0",
"firebase-functions": "^7.1.0",
"express": "4.21.2"
},
"peerDependencies": {
"effect": "^4.0.0-beta.43",
"effect": "^4.0.0-beta.70",
"effect-firebase": "workspace:*",
"firebase-admin": "^13.0.0",
"firebase-functions": "^7.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
"tslib": "^2.3.0"
},
"devDependencies": {
"effect": "^4.0.0-beta.43",
"effect": "^4.0.0-beta.70",
"effect-firebase": "workspace:*",
"firebase": "^12.9.0"
},
"peerDependencies": {
"effect": "^4.0.0-beta.43",
"effect": "^4.0.0-beta.70",
"effect-firebase": "workspace:*",
"firebase": "^12.0.0"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/effect-firebase/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { Model } from 'effect-firebase';
const PostId = Schema.String.pipe(Schema.brand('PostId'));

class PostModel extends Model.Class<PostModel>('PostModel')({
id: Model.Generated(PostId), // excluded from add, required in update
id: Model.GeneratedByDb(PostId), // excluded from add and update
createdAt: Model.DateTimeInsert, // set on create, excluded from update
updatedAt: Model.DateTimeUpdate, // set on every write
author: Model.Reference(AuthorId, 'authors'), // stored as DocumentReference
Expand All @@ -36,7 +36,7 @@ Built-in field helpers:

| Helper | Behaviour |
| ------------------------------------------- | --------------------------------------------------------------------- |
| `Model.Generated(schema)` | Auto-generated (e.g. IDs). Excluded from `add`, required in `update`. |
| `Model.GeneratedByDb(schema)` | Auto-generated (e.g. IDs). Excluded from `add` and `update`. |
| `Model.DateTimeInsert` | Server timestamp on create. Excluded from `update`. |
| `Model.DateTimeUpdate` | Server timestamp on every write. |
| `Model.Reference(id, collection)` | Branded ID in app, `DocumentReference` in Firestore. |
Expand Down
4 changes: 2 additions & 2 deletions packages/effect-firebase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
"tslib": "^2.3.0"
},
"devDependencies": {
"effect": "^4.0.0-beta.43"
"effect": "^4.0.0-beta.70"
},
"peerDependencies": {
"effect": "^4.0.0-beta.43"
"effect": "^4.0.0-beta.70"
},
"publishConfig": {
"access": "public",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('Model.DateTime', () => {
const PostId = Schema.String.pipe(Schema.brand('PostId'));

class TestModel extends Model.Class<TestModel>('TestModel')({
id: Model.Generated(PostId),
id: Model.GeneratedByDb(PostId),
createdAt: DateTime,
}) {}

Expand Down Expand Up @@ -81,7 +81,7 @@ describe('Model.DateTime', () => {
const encode = Schema.encodeSync(TestModel.json);
const dt = EffectDateTime.makeUnsafe(1705315800123);
const result = encode({
id: 'post-1',
id: PostId.make('post-1'),
createdAt: dt,
});

Expand All @@ -95,7 +95,7 @@ describe('Model.DateTimeInsert', () => {
const PostId = Schema.String.pipe(Schema.brand('PostId'));

class TestModel extends Model.Class<TestModel>('TestModel')({
id: Model.Generated(PostId),
id: Model.GeneratedByDb(PostId),
createdAt: DateTimeInsert,
}) {}

Expand Down Expand Up @@ -157,7 +157,7 @@ describe('Model.DateTimeUpdate', () => {
const PostId = Schema.String.pipe(Schema.brand('PostId'));

class TestModel extends Model.Class<TestModel>('TestModel')({
id: Model.Generated(PostId),
id: Model.GeneratedByDb(PostId),
updatedAt: DateTimeUpdate,
}) {}

Expand Down Expand Up @@ -189,7 +189,6 @@ describe('Model.DateTimeUpdate', () => {
it('should include updatedAt field', () => {
const decode = Schema.decodeUnknownSync(TestModel.update);
const result = decode({
id: 'post-1',
updatedAt: Timestamp.fromMillis(1705315800000),
});

Expand All @@ -199,7 +198,6 @@ describe('Model.DateTimeUpdate', () => {
it('should encode undefined to ServerTimestamp', () => {
const encode = Schema.encodeSync(TestModel.update);
const result = encode({
id: 'post-1' as typeof PostId.Type,
updatedAt: undefined,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('Model.AnyIdReference', () => {
const PostId = Schema.String.pipe(Schema.brand('PostId'));

class TestModel extends Model.Class<TestModel>('TestModel')({
id: Model.Generated(PostId),
id: Model.GeneratedByDb(PostId),
authorId: AnyIdReference,
}) {}

Expand Down Expand Up @@ -75,7 +75,7 @@ describe('Model.AnyPathReference', () => {
const PostId = Schema.String.pipe(Schema.brand('PostId'));

class TestModel extends Model.Class<TestModel>('TestModel')({
id: Model.Generated(PostId),
id: Model.GeneratedByDb(PostId),
authorPath: AnyPathReference,
}) {}

Expand Down Expand Up @@ -135,7 +135,7 @@ describe('Model.Reference', () => {
const AuthorId = Schema.String.pipe(Schema.brand('AuthorId'));

class TestModel extends Model.Class<TestModel>('TestModel')({
id: Model.Generated(PostId),
id: Model.GeneratedByDb(PostId),
author: Reference(AuthorId, 'authors'),
}) {}

Expand Down Expand Up @@ -173,7 +173,6 @@ describe('Model.Reference', () => {
const encode = Schema.encodeSync(TestModel.update);
const authorId = 'author-456' as typeof AuthorId.Type;
const result = encode({
id: 'post-1' as typeof PostId.Type,
author: authorId,
});

Expand Down Expand Up @@ -210,7 +209,7 @@ describe('Model.Reference', () => {
const CommentId = Schema.String.pipe(Schema.brand('CommentId'));

class CommentModel extends Model.Class<CommentModel>('CommentModel')({
id: Model.Generated(CommentId),
id: Model.GeneratedByDb(CommentId),
replyTo: Reference(CommentId, 'posts/post-1/comments'),
}) {}

Expand All @@ -233,7 +232,7 @@ describe('Model.ReferenceAsInstance', () => {
const AuthorId = Schema.String.pipe(Schema.brand('AuthorId'));

class TestModel extends Model.Class<TestModel>('TestModel')({
id: Model.Generated(PostId),
id: Model.GeneratedByDb(PostId),
author: ReferenceAsInstance(AuthorId, 'authors'),
}) {}

Expand Down Expand Up @@ -280,7 +279,6 @@ describe('Model.ReferenceAsInstance', () => {
path: 'authors/author-456',
});
const result = encode({
id: 'post-1' as typeof PostId.Type,
author: authorRef,
});

Expand Down Expand Up @@ -340,7 +338,7 @@ describe('Model.ReferencePath', () => {
const PostId = Schema.String.pipe(Schema.brand('PostId'));

class TestModel extends Model.Class<TestModel>('TestModel')({
id: Model.Generated(PostId),
id: Model.GeneratedByDb(PostId),
authorPath: ReferencePath('authors'),
}) {}

Expand Down Expand Up @@ -411,7 +409,7 @@ describe('Model.ReferenceOptional', () => {
const AuthorId = Schema.String.pipe(Schema.brand('AuthorId'));

class TestModel extends Model.Class<TestModel>('TestModel')({
id: Model.Generated(PostId),
id: Model.GeneratedByDb(PostId),
author: ReferenceOptional(AuthorId, 'authors'),
}) {}

Expand Down
6 changes: 3 additions & 3 deletions packages/effect-firebase/src/lib/firestore/model/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const AnyPathReference = Model.Field({
* const AuthorId = Schema.String.pipe(Schema.brand('AuthorId'));
*
* class PostModel extends Model.Class<PostModel>('PostModel')({
* id: Model.Generated(PostId),
* id: Model.GeneratedByDb(PostId),
* // App gets AuthorId, DB stores DocumentReference
* author: Model.Reference(AuthorId, 'authors'),
* }) {}
Expand Down Expand Up @@ -107,7 +107,7 @@ export const Reference = <Id extends StringBasedSchema>(
* const AuthorId = Schema.String.pipe(Schema.brand('AuthorId'));
*
* class PostModel extends Model.Class<PostModel>('PostModel')({
* id: Model.Generated(PostId),
* id: Model.GeneratedByDb(PostId),
* // App gets DocumentReference, JSON is AuthorId
* author: Model.ReferenceAsInstance(AuthorId, 'authors'),
* }) {}
Expand Down Expand Up @@ -162,7 +162,7 @@ export const ReferenceAsInstance = <Id extends StringBasedSchema>(
* import { Model } from 'effect-firebase';
*
* class PostModel extends Model.Class<PostModel>('PostModel')({
* id: Model.Generated(PostId),
* id: Model.GeneratedByDb(PostId),
* // Reference - JSON will be the full path string
* authorPath: Model.ReferencePath('authors'),
* }) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { Snapshot } from '../snapshot.js';
const PostId = Schema.String.pipe(Schema.brand('PostId'));

class PostModel extends Model.Class<PostModel>('PostModel')({
id: Model.Generated(PostId),
id: Model.GeneratedByDb(PostId),
title: Schema.String,
}) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type RepositoryQuery<S> = ReadonlyArray<QueryConstraint> & {

export type Repository<
S extends Model.Any,
Id extends keyof S['Type'] & keyof S['update']['Type'] & keyof S['fields'],
Id extends keyof S['Type'] & keyof S['fields'],
IdSchema extends S['fields'][Id] extends Schema.String
? S['fields'][Id]
: never
Expand Down Expand Up @@ -203,7 +203,7 @@ export type Repository<
*/
export const makeRepository = <
S extends Model.Any,
Id extends keyof S['Type'] & keyof S['update']['Type'] & keyof S['fields'],
Id extends keyof S['Type'] & keyof S['fields'],
IdSchema extends S['fields'][Id] extends Schema.String
? S['fields'][Id]
: never
Expand Down
4 changes: 2 additions & 2 deletions packages/mock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
"tslib": "^2.3.0"
},
"devDependencies": {
"effect": "^4.0.0-beta.43",
"effect": "^4.0.0-beta.70",
"effect-firebase": "workspace:*"
},
"peerDependencies": {
"effect": "^4.0.0-beta.43",
"effect": "^4.0.0-beta.70",
"effect-firebase": "workspace:*"
},
"publishConfig": {
Expand Down
3 changes: 0 additions & 3 deletions packages/mock/src/lib/firestore/firestore-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ export const MockFirestoreService = (
deleteRecursive: () => {
throw new Error('MockFirestoreService.deleteRecursive not implemented.');
},
deleteRecursive: () => {
throw new Error('MockFirestoreService.deleteRecursive not implemented.');
},
query: () => {
throw new Error('MockFirestoreService.query not implemented.');
},
Expand Down
Loading
Loading