Skip to content

Commit 3f69c3c

Browse files
Copilothotlong
andcommitted
Implement protocol consolidation: webhooks, auth, and sync layering
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent eb1aa37 commit 3f69c3c

File tree

11 files changed

+879
-314
lines changed

11 files changed

+879
-314
lines changed

packages/spec/docs/SYNC_ARCHITECTURE.md

Lines changed: 479 additions & 0 deletions
Large diffs are not rendered by default.

packages/spec/src/auth/config.test.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ import {
1818
DatabaseAdapterSchema,
1919
DatabaseMappingSchema,
2020
AuthPluginConfigSchema,
21-
AuthConfigSchema,
21+
ApplicationAuthConfigSchema,
2222
StandardAuthProviderSchema,
23-
type AuthConfig,
23+
type ApplicationAuthConfig,
2424
type StandardAuthProvider,
2525
type OAuthProvider,
2626
type DatabaseMapping,
@@ -472,7 +472,7 @@ describe('EnterpriseAuthConfigSchema', () => {
472472
},
473473
};
474474

475-
expect(() => EnterpriseAuthConfigSchema.parse(config)).not.toThrow();
475+
expect(() => EnterpriseApplicationAuthConfigSchema.parse(config)).not.toThrow();
476476
});
477477

478478
it('should accept partial enterprise config', () => {
@@ -485,12 +485,12 @@ describe('EnterpriseAuthConfigSchema', () => {
485485
},
486486
};
487487

488-
expect(() => EnterpriseAuthConfigSchema.parse(config)).not.toThrow();
488+
expect(() => EnterpriseApplicationAuthConfigSchema.parse(config)).not.toThrow();
489489
});
490490

491491
it('should accept empty enterprise config', () => {
492492
const config = {};
493-
expect(() => EnterpriseAuthConfigSchema.parse(config)).not.toThrow();
493+
expect(() => EnterpriseApplicationAuthConfigSchema.parse(config)).not.toThrow();
494494
});
495495
});
496496

@@ -648,7 +648,7 @@ describe('AuthPluginConfigSchema', () => {
648648
});
649649
});
650650

651-
describe('AuthConfigSchema', () => {
651+
describe('ApplicationAuthConfigSchema', () => {
652652
it('should accept minimal valid configuration', () => {
653653
const config: AuthConfig = {
654654
name: 'main_auth',
@@ -662,7 +662,7 @@ describe('AuthConfigSchema', () => {
662662
accountLinking: {},
663663
};
664664

665-
expect(() => AuthConfigSchema.parse(config)).not.toThrow();
665+
expect(() => ApplicationAuthConfigSchema.parse(config)).not.toThrow();
666666
});
667667

668668
it('should accept comprehensive configuration', () => {
@@ -747,7 +747,7 @@ describe('AuthConfigSchema', () => {
747747
allowRegistration: true,
748748
};
749749

750-
expect(() => AuthConfigSchema.parse(config)).not.toThrow();
750+
expect(() => ApplicationAuthConfigSchema.parse(config)).not.toThrow();
751751
});
752752

753753
it('should enforce snake_case for name field', () => {
@@ -763,14 +763,14 @@ describe('AuthConfigSchema', () => {
763763
accountLinking: {},
764764
};
765765

766-
expect(() => AuthConfigSchema.parse(invalidConfig)).toThrow();
766+
expect(() => ApplicationAuthConfigSchema.parse(invalidConfig)).toThrow();
767767

768768
const validConfig = {
769769
...invalidConfig,
770770
name: 'main_auth', // snake_case - valid
771771
};
772772

773-
expect(() => AuthConfigSchema.parse(validConfig)).not.toThrow();
773+
expect(() => ApplicationAuthConfigSchema.parse(validConfig)).not.toThrow();
774774
});
775775

776776
it('should require at least one strategy', () => {
@@ -786,7 +786,7 @@ describe('AuthConfigSchema', () => {
786786
accountLinking: {},
787787
};
788788

789-
expect(() => AuthConfigSchema.parse(config)).toThrow();
789+
expect(() => ApplicationAuthConfigSchema.parse(config)).toThrow();
790790
});
791791

792792
it('should require secret to be at least 32 characters', () => {
@@ -802,7 +802,7 @@ describe('AuthConfigSchema', () => {
802802
accountLinking: {},
803803
};
804804

805-
expect(() => AuthConfigSchema.parse(config)).toThrow();
805+
expect(() => ApplicationAuthConfigSchema.parse(config)).toThrow();
806806
});
807807

808808
it('should validate baseUrl is a valid URL', () => {
@@ -818,7 +818,7 @@ describe('AuthConfigSchema', () => {
818818
accountLinking: {},
819819
};
820820

821-
expect(() => AuthConfigSchema.parse(config)).toThrow();
821+
expect(() => ApplicationAuthConfigSchema.parse(config)).toThrow();
822822
});
823823

824824
it('should accept configuration with hooks', () => {
@@ -842,7 +842,7 @@ describe('AuthConfigSchema', () => {
842842
},
843843
};
844844

845-
expect(() => AuthConfigSchema.parse(config)).not.toThrow();
845+
expect(() => ApplicationAuthConfigSchema.parse(config)).not.toThrow();
846846
});
847847

848848
it('should accept configuration with security settings', () => {
@@ -865,7 +865,7 @@ describe('AuthConfigSchema', () => {
865865
},
866866
};
867867

868-
expect(() => AuthConfigSchema.parse(config)).not.toThrow();
868+
expect(() => ApplicationAuthConfigSchema.parse(config)).not.toThrow();
869869
});
870870

871871
it('should accept configuration with email settings', () => {
@@ -889,7 +889,7 @@ describe('AuthConfigSchema', () => {
889889
},
890890
};
891891

892-
expect(() => AuthConfigSchema.parse(config)).not.toThrow();
892+
expect(() => ApplicationAuthConfigSchema.parse(config)).not.toThrow();
893893
});
894894

895895
it('should accept configuration with UI customization', () => {
@@ -911,7 +911,7 @@ describe('AuthConfigSchema', () => {
911911
},
912912
};
913913

914-
expect(() => AuthConfigSchema.parse(config)).not.toThrow();
914+
expect(() => ApplicationAuthConfigSchema.parse(config)).not.toThrow();
915915
});
916916

917917
it('should accept configuration with enterprise authentication', () => {
@@ -941,7 +941,7 @@ describe('AuthConfigSchema', () => {
941941
},
942942
};
943943

944-
expect(() => AuthConfigSchema.parse(config)).not.toThrow();
944+
expect(() => ApplicationAuthConfigSchema.parse(config)).not.toThrow();
945945
});
946946

947947
it('should accept configuration with database field mapping', () => {
@@ -970,7 +970,7 @@ describe('AuthConfigSchema', () => {
970970
},
971971
};
972972

973-
expect(() => AuthConfigSchema.parse(config)).not.toThrow();
973+
expect(() => ApplicationAuthConfigSchema.parse(config)).not.toThrow();
974974
});
975975

976976
it('should accept configuration with better-auth compatible mapping', () => {
@@ -997,7 +997,7 @@ describe('AuthConfigSchema', () => {
997997
},
998998
};
999999

1000-
const result = AuthConfigSchema.parse(config);
1000+
const result = ApplicationAuthConfigSchema.parse(config);
10011001

10021002
// Verify mapping is preserved
10031003
expect(result.mapping?.session?.sessionToken).toBe('token');
@@ -1013,7 +1013,7 @@ describe('AuthConfigSchema', () => {
10131013
secret: 'a'.repeat(32),
10141014
};
10151015

1016-
const result = AuthConfigSchema.parse(config);
1016+
const result = ApplicationAuthConfigSchema.parse(config);
10171017

10181018
expect(result.active).toBe(true);
10191019
expect(result.allowRegistration).toBe(true);
@@ -1039,7 +1039,7 @@ describe('AuthConfigSchema', () => {
10391039
},
10401040
};
10411041

1042-
expect(() => AuthConfigSchema.parse(config)).not.toThrow();
1042+
expect(() => ApplicationAuthConfigSchema.parse(config)).not.toThrow();
10431043
});
10441044

10451045
it('should use default values for organization settings', () => {
@@ -1056,7 +1056,7 @@ describe('AuthConfigSchema', () => {
10561056
organization: {},
10571057
};
10581058

1059-
const result = AuthConfigSchema.parse(config);
1059+
const result = ApplicationAuthConfigSchema.parse(config);
10601060

10611061
expect(result.organization?.enabled).toBe(false);
10621062
expect(result.organization?.allowUserToCreateOrg).toBe(true);
@@ -1080,7 +1080,7 @@ describe('AuthConfigSchema', () => {
10801080
},
10811081
};
10821082

1083-
const result = AuthConfigSchema.parse(config);
1083+
const result = ApplicationAuthConfigSchema.parse(config);
10841084

10851085
expect(result.organization?.enabled).toBe(false);
10861086
});

0 commit comments

Comments
 (0)