@shivaedev/identity 0.31.2 → 0.32.1

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.
Files changed (74) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +19 -4
  3. package/dist/AccountPreferences.d.ts +52 -0
  4. package/dist/AccountPreferences.d.ts.map +1 -0
  5. package/dist/AccountPreferences.js +37 -0
  6. package/dist/AccountPreferences.js.map +1 -0
  7. package/dist/Sessions.d.ts +40 -0
  8. package/dist/Sessions.d.ts.map +1 -0
  9. package/dist/Sessions.js +30 -0
  10. package/dist/Sessions.js.map +1 -0
  11. package/dist/accountPreferenceValues.d.ts +9 -0
  12. package/dist/accountPreferenceValues.d.ts.map +1 -0
  13. package/dist/accountPreferenceValues.js +10 -0
  14. package/dist/accountPreferenceValues.js.map +1 -0
  15. package/dist/generated/AccountPreferences.d.ts +58 -0
  16. package/dist/generated/AccountPreferences.d.ts.map +1 -0
  17. package/dist/generated/AccountPreferences.js +28 -0
  18. package/dist/generated/AccountPreferences.js.map +1 -0
  19. package/dist/generated/Sessions.d.ts +76 -0
  20. package/dist/generated/Sessions.d.ts.map +1 -0
  21. package/dist/generated/Sessions.js +26 -0
  22. package/dist/generated/Sessions.js.map +1 -0
  23. package/dist/server/account-preferences/Rows.js +1 -1
  24. package/dist/server/account-preferences/Rows.js.map +1 -1
  25. package/dist/server/account-preferences/get.d.ts +3 -7
  26. package/dist/server/account-preferences/get.d.ts.map +1 -1
  27. package/dist/server/account-preferences/get.js +2 -1
  28. package/dist/server/account-preferences/get.js.map +1 -1
  29. package/dist/server/account-preferences/service.d.ts +3 -7
  30. package/dist/server/account-preferences/service.d.ts.map +1 -1
  31. package/dist/server/better-auth/adapters/accountPreferenceOptions.js +1 -1
  32. package/dist/server/better-auth/adapters/accountPreferenceOptions.js.map +1 -1
  33. package/dist/server/better-auth/sessionAdministration.d.ts +3 -18
  34. package/dist/server/better-auth/sessionAdministration.d.ts.map +1 -1
  35. package/dist/server/better-auth/sessionAdministration.js +3 -2
  36. package/dist/server/better-auth/sessionAdministration.js.map +1 -1
  37. package/dist/signedInSessions.d.ts +29 -0
  38. package/dist/signedInSessions.d.ts.map +1 -0
  39. package/dist/signedInSessions.js +16 -0
  40. package/dist/signedInSessions.js.map +1 -0
  41. package/package.json +14 -12
  42. package/src/AccountPreferences.ts +40 -0
  43. package/src/Sessions.ts +32 -0
  44. package/src/accountPreferenceValues.ts +14 -0
  45. package/src/generated/AccountPreferences.ts +33 -0
  46. package/src/generated/README.md +1 -0
  47. package/src/generated/Sessions.ts +31 -0
  48. package/src/server/account-preferences/Rows.ts +1 -1
  49. package/src/server/account-preferences/capture.ts +1 -1
  50. package/src/server/account-preferences/get.ts +5 -2
  51. package/src/server/account-preferences/set.ts +1 -1
  52. package/src/server/better-auth/adapters/accountPreferenceOptions.ts +1 -1
  53. package/src/server/better-auth/sessionAdministration.ts +3 -2
  54. package/src/signedInSessions.ts +23 -0
  55. package/dist/accountPreferences.d.ts +0 -106
  56. package/dist/accountPreferences.d.ts.map +0 -1
  57. package/dist/accountPreferences.js +0 -37
  58. package/dist/accountPreferences.js.map +0 -1
  59. package/dist/server/accountPreferencesHandlers.d.ts +0 -2
  60. package/dist/server/accountPreferencesHandlers.d.ts.map +0 -1
  61. package/dist/server/accountPreferencesHandlers.js +0 -19
  62. package/dist/server/accountPreferencesHandlers.js.map +0 -1
  63. package/dist/server/better-auth/sessionsHandlers.d.ts +0 -2
  64. package/dist/server/better-auth/sessionsHandlers.d.ts.map +0 -1
  65. package/dist/server/better-auth/sessionsHandlers.js +0 -7
  66. package/dist/server/better-auth/sessionsHandlers.js.map +0 -1
  67. package/dist/sessions.d.ts +0 -150
  68. package/dist/sessions.d.ts.map +0 -1
  69. package/dist/sessions.js +0 -39
  70. package/dist/sessions.js.map +0 -1
  71. package/src/accountPreferences.ts +0 -42
  72. package/src/server/accountPreferencesHandlers.ts +0 -22
  73. package/src/server/better-auth/sessionsHandlers.ts +0 -7
  74. package/src/sessions.ts +0 -42
@@ -1,19 +0,0 @@
1
- import { Effect } from "effect";
2
- import { AccountPreferences } from "#accountPreferences.ts";
3
- import { AccountPreferencesStore } from "#server/account-preferences/service.ts";
4
- import { Subject } from "#subject.ts";
5
- export const accountPreferencesHandlers = AccountPreferences.application.toLayer({
6
- "identity.accountPreferences.capture": (values) => Effect.gen(function* () {
7
- const { id } = yield* Subject;
8
- return yield* (yield* AccountPreferencesStore).capture(id, values);
9
- }),
10
- "identity.accountPreferences.get": () => Effect.gen(function* () {
11
- const { id } = yield* Subject;
12
- return yield* (yield* AccountPreferencesStore).get(id);
13
- }),
14
- "identity.accountPreferences.set": (values) => Effect.gen(function* () {
15
- const { id } = yield* Subject;
16
- return yield* (yield* AccountPreferencesStore).set(id, values);
17
- }),
18
- });
19
- //# sourceMappingURL=accountPreferencesHandlers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"accountPreferencesHandlers.js","sourceRoot":"","sources":["../../src/server/accountPreferencesHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,MAAM,CAAC,MAAM,0BAA0B,GAAG,kBAAkB,CAAC,WAAW,CAAC,OAAO,CAAC;IAChF,qCAAqC,EAAE,CAAC,MAAM,EAAE,EAAE,CACjD,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACnB,MAAM,EAAE,EAAE,EAAE,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC;QAC9B,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,uBAAuB,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IACpE,CAAC,CAAC;IACH,iCAAiC,EAAE,GAAG,EAAE,CACvC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACnB,MAAM,EAAE,EAAE,EAAE,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC;QAC9B,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,uBAAuB,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACxD,CAAC,CAAC;IACH,iCAAiC,EAAE,CAAC,MAAM,EAAE,EAAE,CAC7C,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACnB,MAAM,EAAE,EAAE,EAAE,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC;QAC9B,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,uBAAuB,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAChE,CAAC,CAAC;CACH,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare const sessionsHandlers: import("effect/Layer").Layer<import("effect/rpc/Rpc").Handler<"identity.sessions.list"> | import("effect/rpc/Rpc").Handler<"identity.sessions.revoke">, never, import("effect/sql/SqlClient").SqlClient>;
2
- //# sourceMappingURL=sessionsHandlers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sessionsHandlers.d.ts","sourceRoot":"","sources":["../../../src/server/better-auth/sessionsHandlers.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB,0MAG3B,CAAC"}
@@ -1,7 +0,0 @@
1
- import { listSessions, revokeSession } from "#server/better-auth/sessionAdministration.ts";
2
- import { Sessions } from "#sessions.ts";
3
- export const sessionsHandlers = Sessions.application.toLayer({
4
- "identity.sessions.list": listSessions,
5
- "identity.sessions.revoke": ({ id }) => revokeSession(id),
6
- });
7
- //# sourceMappingURL=sessionsHandlers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sessionsHandlers.js","sourceRoot":"","sources":["../../../src/server/better-auth/sessionsHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAC3F,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC;IAC5D,wBAAwB,EAAE,YAAY;IACtC,0BAA0B,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC;CACzD,CAAC,CAAC"}
@@ -1,150 +0,0 @@
1
- import { Effect, Schema } from "effect";
2
- import { AuthUnavailable, Forbidden, NotFound } from "@shivaedev/errors/taxonomy.ts";
3
- import { SessionsPermission } from "#sessionPermissions.ts";
4
- export declare const SignedInSession: Schema.Struct<{
5
- readonly expiresAt: Schema.DateTimeUtcFromDate;
6
- readonly id: Schema.String;
7
- readonly lastActivityAt: Schema.DateTimeUtcFromDate;
8
- readonly startedAt: Schema.DateTimeUtcFromDate;
9
- readonly user: Schema.Struct<{
10
- readonly email: Schema.String;
11
- readonly id: Schema.String;
12
- readonly name: Schema.String;
13
- }>;
14
- }>;
15
- export declare const SessionCursor: Schema.Struct<{
16
- readonly id: Schema.String;
17
- readonly lastActivityAt: Schema.DateTimeUtcFromString;
18
- }>;
19
- export declare const SessionListInput: Schema.Struct<{
20
- readonly cursor: Schema.optionalKey<Schema.Struct<{
21
- readonly id: Schema.String;
22
- readonly lastActivityAt: Schema.DateTimeUtcFromString;
23
- }>>;
24
- readonly limit: Schema.Number;
25
- }>;
26
- export declare const SessionList: Schema.Struct<{
27
- readonly next: Schema.OptionFromNullOr<Schema.Struct<{
28
- readonly id: Schema.String;
29
- readonly lastActivityAt: Schema.DateTimeUtcFromString;
30
- }>>;
31
- readonly sessions: Schema.$Array<Schema.Struct<{
32
- readonly expiresAt: Schema.DateTimeUtcFromDate;
33
- readonly id: Schema.String;
34
- readonly lastActivityAt: Schema.DateTimeUtcFromDate;
35
- readonly startedAt: Schema.DateTimeUtcFromDate;
36
- readonly user: Schema.Struct<{
37
- readonly email: Schema.String;
38
- readonly id: Schema.String;
39
- readonly name: Schema.String;
40
- }>;
41
- }>>;
42
- }>;
43
- export declare const Sessions: import("@shivaedev/contract/contract.ts").Contract<"identity.sessions", readonly [NoInfer<import("@shivaedev/contract/operation.ts").Query<"list", Schema.Struct<{
44
- readonly cursor: Schema.optionalKey<Schema.Struct<{
45
- readonly id: Schema.String;
46
- readonly lastActivityAt: Schema.DateTimeUtcFromString;
47
- }>>;
48
- readonly limit: Schema.Number;
49
- }>, Schema.Struct<{
50
- readonly next: Schema.OptionFromNullOr<Schema.Struct<{
51
- readonly id: Schema.String;
52
- readonly lastActivityAt: Schema.DateTimeUtcFromString;
53
- }>>;
54
- readonly sessions: Schema.$Array<Schema.Struct<{
55
- readonly expiresAt: Schema.DateTimeUtcFromDate;
56
- readonly id: Schema.String;
57
- readonly lastActivityAt: Schema.DateTimeUtcFromDate;
58
- readonly startedAt: Schema.DateTimeUtcFromDate;
59
- readonly user: Schema.Struct<{
60
- readonly email: Schema.String;
61
- readonly id: Schema.String;
62
- readonly name: Schema.String;
63
- }>;
64
- }>>;
65
- }>, {
66
- readonly AuthUnavailable: typeof AuthUnavailable;
67
- readonly Forbidden: typeof Forbidden;
68
- }, never>>], readonly [NoInfer<import("@shivaedev/contract/operation.ts").Command<"revoke", Schema.Struct<{
69
- id: Schema.String;
70
- }>, Schema.Void, {
71
- readonly AuthUnavailable: typeof AuthUnavailable;
72
- readonly Forbidden: typeof Forbidden;
73
- readonly NotFound: typeof NotFound;
74
- }>>], import("effect/rpc/Rpc").Rpc<"identity.sessions.revoke", Schema.Struct<{
75
- id: Schema.String;
76
- }>, Schema.Void, Schema.Union<readonly (typeof NotFound | typeof Forbidden | typeof AuthUnavailable)[]>, typeof SessionsPermission, never> | import("effect/rpc/Rpc").Rpc<"identity.sessions.$changes", Schema.Struct<{
77
- queries: Schema.$Array<Schema.Union<readonly Schema.Struct<{
78
- query: Schema.Literal<"list">;
79
- payload: Schema.Struct<{
80
- readonly cursor: Schema.optionalKey<Schema.Struct<{
81
- readonly id: Schema.String;
82
- readonly lastActivityAt: Schema.DateTimeUtcFromString;
83
- }>>;
84
- readonly limit: Schema.Number;
85
- }>;
86
- }>[]>>;
87
- }>, import("effect/rpc/RpcSchema").Stream<Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, ...(Schema.Struct<{
88
- readonly _tag: Schema.Literal<"Unchanged">;
89
- readonly queryIndex: Schema.Number;
90
- }> | Schema.Struct<{
91
- _tag: Schema.Literal<"Result">;
92
- query: Schema.Literal<"list">;
93
- queryIndex: Schema.Number;
94
- value: Schema.Struct<{
95
- readonly next: Schema.OptionFromNullOr<Schema.Struct<{
96
- readonly id: Schema.String;
97
- readonly lastActivityAt: Schema.DateTimeUtcFromString;
98
- }>>;
99
- readonly sessions: Schema.$Array<Schema.Struct<{
100
- readonly expiresAt: Schema.DateTimeUtcFromDate;
101
- readonly id: Schema.String;
102
- readonly lastActivityAt: Schema.DateTimeUtcFromDate;
103
- readonly startedAt: Schema.DateTimeUtcFromDate;
104
- readonly user: Schema.Struct<{
105
- readonly email: Schema.String;
106
- readonly id: Schema.String;
107
- readonly name: Schema.String;
108
- }>;
109
- }>>;
110
- }>;
111
- }>)[]]>, Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, typeof import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired, ...Schema.Union<readonly (typeof Forbidden | typeof AuthUnavailable)[]>[]]>>, Schema.Never, typeof SessionsPermission | (import("effect/Context").Reference<<A, E, R>(effect: Effect.Effect<A, E, R>, request: {
112
- readonly rpc: import("effect/rpc/Rpc").Any;
113
- readonly payload: unknown;
114
- }) => Effect.Effect<A, E | import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy | import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied | import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired | import("effect/Types").unhandled, R>> & {
115
- "~effect/rpc/RpcMiddleware": "~effect/rpc/RpcMiddleware";
116
- "~ClientError": never;
117
- error: Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, typeof import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired]>;
118
- requiredForClient: false;
119
- }), never> | import("effect/rpc/Rpc").Rpc<"identity.sessions.list", Schema.Struct<{
120
- readonly cursor: Schema.optionalKey<Schema.Struct<{
121
- readonly id: Schema.String;
122
- readonly lastActivityAt: Schema.DateTimeUtcFromString;
123
- }>>;
124
- readonly limit: Schema.Number;
125
- }>, Schema.Struct<{
126
- readonly next: Schema.OptionFromNullOr<Schema.Struct<{
127
- readonly id: Schema.String;
128
- readonly lastActivityAt: Schema.DateTimeUtcFromString;
129
- }>>;
130
- readonly sessions: Schema.$Array<Schema.Struct<{
131
- readonly expiresAt: Schema.DateTimeUtcFromDate;
132
- readonly id: Schema.String;
133
- readonly lastActivityAt: Schema.DateTimeUtcFromDate;
134
- readonly startedAt: Schema.DateTimeUtcFromDate;
135
- readonly user: Schema.Struct<{
136
- readonly email: Schema.String;
137
- readonly id: Schema.String;
138
- readonly name: Schema.String;
139
- }>;
140
- }>>;
141
- }>, Schema.Union<readonly [Schema.Union<readonly (typeof Forbidden | typeof AuthUnavailable)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof SessionsPermission | (import("effect/Context").Reference<<A, E, R>(effect: Effect.Effect<A, E, R>, request: {
142
- readonly rpc: import("effect/rpc/Rpc").Any;
143
- readonly payload: unknown;
144
- }) => Effect.Effect<A, E | import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy | import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied | import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired | import("effect/Types").unhandled, R>> & {
145
- "~effect/rpc/RpcMiddleware": "~effect/rpc/RpcMiddleware";
146
- "~ClientError": never;
147
- error: Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, typeof import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired]>;
148
- requiredForClient: false;
149
- }), never>, readonly [], undefined>;
150
- //# sourceMappingURL=sessions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../src/sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIxC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAI5D,eAAO,MAAM,eAAe;;;;;;;;;;EAM1B,CAAC;AAEH,eAAO,MAAM,aAAa;;;EAAqF,CAAC;AAChH,eAAO,MAAM,gBAAgB;;;;;;EAG3B,CAAC;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;EAA2G,CAAC;AAEpI,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mCAiBY,CAAC"}
package/dist/sessions.js DELETED
@@ -1,39 +0,0 @@
1
- import { Effect, Schema } from "effect";
2
- import { collection } from "@shivaedev/changes/keys.ts";
3
- import { contract } from "@shivaedev/contract/contract.ts";
4
- import { command, query } from "@shivaedev/contract/operation.ts";
5
- import { AuthUnavailable, Forbidden, NotFound } from "@shivaedev/errors/taxonomy.ts";
6
- import { SessionsPermission } from "#sessionPermissions.ts";
7
- const sessions = collection("identity.sessions", Schema.String);
8
- export const SignedInSession = Schema.Struct({
9
- expiresAt: Schema.DateTimeUtcFromDate,
10
- id: Schema.String,
11
- lastActivityAt: Schema.DateTimeUtcFromDate,
12
- startedAt: Schema.DateTimeUtcFromDate,
13
- user: Schema.Struct({ email: Schema.String, id: Schema.String, name: Schema.String }),
14
- });
15
- export const SessionCursor = Schema.Struct({ id: Schema.String, lastActivityAt: Schema.DateTimeUtcFromString });
16
- export const SessionListInput = Schema.Struct({
17
- cursor: Schema.optionalKey(SessionCursor),
18
- limit: Schema.Number.check(Schema.isInt(), Schema.isBetween({ maximum: 100, minimum: 1 })),
19
- });
20
- export const SessionList = Schema.Struct({ next: Schema.OptionFromNullOr(SessionCursor), sessions: Schema.Array(SignedInSession) });
21
- export const Sessions = contract("identity.sessions", {
22
- commands: [
23
- command("revoke", {
24
- invalidates: () => [sessions.list],
25
- payload: { id: Schema.String },
26
- rejections: { AuthUnavailable, Forbidden, NotFound },
27
- }),
28
- ],
29
- queries: [
30
- query("list", {
31
- payload: SessionListInput.fields,
32
- readPolicy: () => Effect.succeed(true),
33
- reads: () => [sessions.list],
34
- rejections: { AuthUnavailable, Forbidden },
35
- success: SessionList,
36
- }),
37
- ],
38
- }).middleware(SessionsPermission);
39
- //# sourceMappingURL=sessions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sessions.js","sourceRoot":"","sources":["../src/sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,MAAM,QAAQ,GAAG,UAAU,CAAC,mBAAmB,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;AAEhE,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5C,SAAS,EAAE,MAAM,CAAC,mBAAmB;IACrC,EAAE,EAAE,MAAM,CAAC,MAAM;IACjB,cAAc,EAAE,MAAM,CAAC,mBAAmB;IAC1C,SAAS,EAAE,MAAM,CAAC,mBAAmB;IACrC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;CACrF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,CAAC,qBAAqB,EAAE,CAAC,CAAC;AAChH,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7C,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC;IACzC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;CAC1F,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,gBAAgB,CAAC,aAAa,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;AAEpI,MAAM,CAAC,MAAM,QAAQ,GAAG,QAAQ,CAAC,mBAAmB,EAAE;IACrD,QAAQ,EAAE;QACT,OAAO,CAAC,QAAQ,EAAE;YACjB,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;YAClC,OAAO,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE;YAC9B,UAAU,EAAE,EAAE,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE;SACpD,CAAC;KACF;IACD,OAAO,EAAE;QACR,KAAK,CAAC,MAAM,EAAE;YACb,OAAO,EAAE,gBAAgB,CAAC,MAAM;YAChC,UAAU,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;YACtC,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;YAC5B,UAAU,EAAE,EAAE,eAAe,EAAE,SAAS,EAAE;YAC1C,OAAO,EAAE,WAAW;SACpB,CAAC;KACF;CACD,CAAC,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC"}
@@ -1,42 +0,0 @@
1
- import { DateTime, Effect, Option, Schema } from "effect";
2
- import { collection } from "@shivaedev/changes/keys.ts";
3
- import { contract } from "@shivaedev/contract/contract.ts";
4
- import { command, query } from "@shivaedev/contract/operation.ts";
5
- import { AuthUnavailable } from "@shivaedev/errors/taxonomy.ts";
6
- import { selfSubject } from "#subject.ts";
7
-
8
- export const AccountTimezone = Schema.String.check(
9
- Schema.makeFilter((value) => Option.isSome(DateTime.zoneMakeNamed(value)), { expected: "an IANA timezone" }),
10
- );
11
-
12
- export const AccountPreferenceValues = Schema.Struct({
13
- locale: Schema.NonEmptyString,
14
- timezone: AccountTimezone,
15
- units: Schema.Literals(["metric", "imperial"]),
16
- });
17
-
18
- export const accountPreferenceKeys = collection("identity.accountPreferences", Schema.String);
19
-
20
- export const AccountPreferences = contract("identity.accountPreferences", {
21
- commands: [
22
- command("capture", {
23
- invalidates: () => [accountPreferenceKeys.list],
24
- payload: AccountPreferenceValues.fields,
25
- rejections: { AuthUnavailable },
26
- }),
27
- command("set", {
28
- invalidates: () => [accountPreferenceKeys.list],
29
- payload: AccountPreferenceValues.fields,
30
- rejections: { AuthUnavailable },
31
- }),
32
- ],
33
- queries: [
34
- query("get", {
35
- readPolicy: () => Effect.succeed(true),
36
- reads: () => [accountPreferenceKeys.list],
37
- rejections: { AuthUnavailable },
38
- success: AccountPreferenceValues,
39
- }),
40
- ],
41
- subject: selfSubject,
42
- });
@@ -1,22 +0,0 @@
1
- import { Effect } from "effect";
2
- import { AccountPreferences } from "#accountPreferences.ts";
3
- import { AccountPreferencesStore } from "#server/account-preferences/service.ts";
4
- import { Subject } from "#subject.ts";
5
-
6
- export const accountPreferencesHandlers = AccountPreferences.application.toLayer({
7
- "identity.accountPreferences.capture": (values) =>
8
- Effect.gen(function* () {
9
- const { id } = yield* Subject;
10
- return yield* (yield* AccountPreferencesStore).capture(id, values);
11
- }),
12
- "identity.accountPreferences.get": () =>
13
- Effect.gen(function* () {
14
- const { id } = yield* Subject;
15
- return yield* (yield* AccountPreferencesStore).get(id);
16
- }),
17
- "identity.accountPreferences.set": (values) =>
18
- Effect.gen(function* () {
19
- const { id } = yield* Subject;
20
- return yield* (yield* AccountPreferencesStore).set(id, values);
21
- }),
22
- });
@@ -1,7 +0,0 @@
1
- import { listSessions, revokeSession } from "#server/better-auth/sessionAdministration.ts";
2
- import { Sessions } from "#sessions.ts";
3
-
4
- export const sessionsHandlers = Sessions.application.toLayer({
5
- "identity.sessions.list": listSessions,
6
- "identity.sessions.revoke": ({ id }) => revokeSession(id),
7
- });
package/src/sessions.ts DELETED
@@ -1,42 +0,0 @@
1
- import { Effect, Schema } from "effect";
2
- import { collection } from "@shivaedev/changes/keys.ts";
3
- import { contract } from "@shivaedev/contract/contract.ts";
4
- import { command, query } from "@shivaedev/contract/operation.ts";
5
- import { AuthUnavailable, Forbidden, NotFound } from "@shivaedev/errors/taxonomy.ts";
6
- import { SessionsPermission } from "#sessionPermissions.ts";
7
-
8
- const sessions = collection("identity.sessions", Schema.String);
9
-
10
- export const SignedInSession = Schema.Struct({
11
- expiresAt: Schema.DateTimeUtcFromDate,
12
- id: Schema.String,
13
- lastActivityAt: Schema.DateTimeUtcFromDate,
14
- startedAt: Schema.DateTimeUtcFromDate,
15
- user: Schema.Struct({ email: Schema.String, id: Schema.String, name: Schema.String }),
16
- });
17
-
18
- export const SessionCursor = Schema.Struct({ id: Schema.String, lastActivityAt: Schema.DateTimeUtcFromString });
19
- export const SessionListInput = Schema.Struct({
20
- cursor: Schema.optionalKey(SessionCursor),
21
- limit: Schema.Number.check(Schema.isInt(), Schema.isBetween({ maximum: 100, minimum: 1 })),
22
- });
23
- export const SessionList = Schema.Struct({ next: Schema.OptionFromNullOr(SessionCursor), sessions: Schema.Array(SignedInSession) });
24
-
25
- export const Sessions = contract("identity.sessions", {
26
- commands: [
27
- command("revoke", {
28
- invalidates: () => [sessions.list],
29
- payload: { id: Schema.String },
30
- rejections: { AuthUnavailable, Forbidden, NotFound },
31
- }),
32
- ],
33
- queries: [
34
- query("list", {
35
- payload: SessionListInput.fields,
36
- readPolicy: () => Effect.succeed(true),
37
- reads: () => [sessions.list],
38
- rejections: { AuthUnavailable, Forbidden },
39
- success: SessionList,
40
- }),
41
- ],
42
- }).middleware(SessionsPermission);