@shivaedev/admin 0.8.1 → 0.9.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/README.md CHANGED
@@ -71,6 +71,20 @@ Declare application roles with `@shivaedev/access`, grant the relevant domain pe
71
71
 
72
72
  Pass `registration.group` and `handlers` to the existing application's RPC host on `/rpc`, merging them with its other groups and Layers as needed. The Platform host supplies generated change handlers; registration requires the page's application handlers. Handler Layer errors and service requirements remain inferred. Missing or extra page ids fail at registration; TypeScript also checks each Layer provides the handlers for its page.
73
73
 
74
+ ### Pages owned by modules
75
+
76
+ Each module declares its own registry and calls `registerAdmin` with its own page handlers. The application host combines those registrations:
77
+
78
+ ```ts
79
+ import { mergeAdminRegistrations } from "@shivaedev/admin/server/mergeAdminRegistrations.ts";
80
+
81
+ const admin = mergeAdminRegistrations(foundation.admin, catalog.admin);
82
+ ```
83
+
84
+ Pass `admin.group` and `admin.handlers` to the application's RPC host. The combined registration exposes `pages` for navigation and preserves the handler Layers' errors and service requirements. Duplicate page ids across modules fail at the type level; duplicate paths and RPC tags fail at composition. A module cannot register a page without its handlers.
85
+
86
+ Browser composition uses `mergeAdminRegistries` from `@shivaedev/admin/registry.ts` with the modules' browser-safe registries. A client module can also contribute its registry's `pages` directly to the application's navigation. A feature module adds pages to its own registry and handlers to its own registration; the foundation does not import feature pages.
87
+
74
88
  ### Built-in Jobs page
75
89
 
76
90
  Share each queue's name and payload Schema with the browser declaration. The page exposes only the queues passed to `jobsPage`; a queue registered with the jobs runtime is not automatically available to operators.
@@ -99,22 +99,7 @@ export declare function jobsPage<const TQueues extends readonly JobsEntry[]>(...
99
99
  JobsPayloadInvalid: typeof import("./schemas.ts").JobsPayloadInvalid;
100
100
  JobsQueueUnregistered: typeof import("./schemas.ts").JobsQueueUnregistered;
101
101
  JobsUnavailable: typeof import("./schemas.ts").JobsUnavailable;
102
- }>>], readonly [], import("effect/rpc/Rpc").Rpc<"admin.jobs.job", Schema.Struct<{
103
- id: Schema.String;
104
- queue: Schema.String;
105
- }>, Schema.OptionFromNullOr<Schema.Union<Schema.Struct<{
106
- readonly attempt: Schema.Number;
107
- readonly completedOn: Schema.OptionFromNullOr<Schema.DateTimeUtcFromString>;
108
- readonly createdOn: Schema.DateTimeUtcFromString;
109
- readonly id: Schema.String;
110
- readonly output: Schema.Unknown;
111
- readonly retryCount: Schema.Number;
112
- readonly retryLimit: Schema.Number;
113
- readonly startedOn: Schema.OptionFromNullOr<Schema.DateTimeUtcFromString>;
114
- readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
115
- readonly data: JobsPayload<TQueues[number]>;
116
- readonly queue: Schema.Literal<string>;
117
- }>[]>>, Schema.Union<readonly [Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.$changes", Schema.Struct<{
102
+ }>>], readonly [], import("effect/rpc/Rpc").Rpc<"admin.jobs.$changes", Schema.Struct<{
118
103
  queries: Schema.$Array<Schema.Union<readonly (Schema.Struct<{
119
104
  query: Schema.Literal<"counts">;
120
105
  payload: Schema.Struct<{
@@ -169,21 +154,7 @@ export declare function jobsPage<const TQueues extends readonly JobsEntry[]>(...
169
154
  readonly failedCount: Schema.Number;
170
155
  readonly queuedCount: Schema.Number;
171
156
  readonly totalCount: Schema.Number;
172
- }>, Schema.Union<readonly [Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.health", Schema.Void, Schema.Struct<{
173
- readonly activeTotal: Schema.Number;
174
- readonly deadLetteredTotal: Schema.Number;
175
- readonly failedTotal: Schema.Number;
176
- readonly jobs: Schema.$Array<Schema.Struct<{
177
- readonly activeCount: Schema.Number;
178
- readonly deadLetteredCount: Schema.Number;
179
- readonly failedCount: Schema.Number;
180
- readonly name: Schema.String;
181
- readonly queuedCount: Schema.Number;
182
- readonly readyCount: Schema.Number;
183
- }>>;
184
- readonly queuedTotal: Schema.Number;
185
- readonly readyTotal: Schema.Number;
186
- }>, Schema.Union<readonly [Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.failed", Schema.Struct<{
157
+ }>, Schema.Union<readonly [Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.deadLettered", Schema.Struct<{
187
158
  cursor: Schema.optionalKey<Schema.String>;
188
159
  limit: Schema.Number;
189
160
  queue: Schema.String;
@@ -200,9 +171,11 @@ export declare function jobsPage<const TQueues extends readonly JobsEntry[]>(...
200
171
  readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
201
172
  readonly data: JobsPayload<TQueues[number]>;
202
173
  readonly queue: Schema.Literal<string>;
174
+ readonly sourceId: Schema.OptionFromNullOr<Schema.String>;
175
+ readonly sourceOutput: Schema.Unknown;
203
176
  }>[]>>;
204
177
  readonly next: Schema.OptionFromNullOr<Schema.String>;
205
- }>, Schema.Union<readonly [Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.deadLettered", Schema.Struct<{
178
+ }>, Schema.Union<readonly [Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.failed", Schema.Struct<{
206
179
  cursor: Schema.optionalKey<Schema.String>;
207
180
  limit: Schema.Number;
208
181
  queue: Schema.String;
@@ -219,11 +192,38 @@ export declare function jobsPage<const TQueues extends readonly JobsEntry[]>(...
219
192
  readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
220
193
  readonly data: JobsPayload<TQueues[number]>;
221
194
  readonly queue: Schema.Literal<string>;
222
- readonly sourceId: Schema.OptionFromNullOr<Schema.String>;
223
- readonly sourceOutput: Schema.Unknown;
224
195
  }>[]>>;
225
196
  readonly next: Schema.OptionFromNullOr<Schema.String>;
226
- }>, Schema.Union<readonly [Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never>, readonly [], undefined>;
197
+ }>, Schema.Union<readonly [Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.health", Schema.Void, Schema.Struct<{
198
+ readonly activeTotal: Schema.Number;
199
+ readonly deadLetteredTotal: Schema.Number;
200
+ readonly failedTotal: Schema.Number;
201
+ readonly jobs: Schema.$Array<Schema.Struct<{
202
+ readonly activeCount: Schema.Number;
203
+ readonly deadLetteredCount: Schema.Number;
204
+ readonly failedCount: Schema.Number;
205
+ readonly name: Schema.String;
206
+ readonly queuedCount: Schema.Number;
207
+ readonly readyCount: Schema.Number;
208
+ }>>;
209
+ readonly queuedTotal: Schema.Number;
210
+ readonly readyTotal: Schema.Number;
211
+ }>, Schema.Union<readonly [Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never> | import("effect/rpc/Rpc").Rpc<"admin.jobs.job", Schema.Struct<{
212
+ id: Schema.String;
213
+ queue: Schema.String;
214
+ }>, Schema.OptionFromNullOr<Schema.Union<Schema.Struct<{
215
+ readonly attempt: Schema.Number;
216
+ readonly completedOn: Schema.OptionFromNullOr<Schema.DateTimeUtcFromString>;
217
+ readonly createdOn: Schema.DateTimeUtcFromString;
218
+ readonly id: Schema.String;
219
+ readonly output: Schema.Unknown;
220
+ readonly retryCount: Schema.Number;
221
+ readonly retryLimit: Schema.Number;
222
+ readonly startedOn: Schema.OptionFromNullOr<Schema.DateTimeUtcFromString>;
223
+ readonly state: Schema.Literals<readonly ["created", "retry", "active", "completed", "cancelled", "failed"]>;
224
+ readonly data: JobsPayload<TQueues[number]>;
225
+ readonly queue: Schema.Literal<string>;
226
+ }>[]>>, Schema.Union<readonly [Schema.Union<readonly (typeof import("./schemas.ts").JobsUnavailable | typeof import("./schemas.ts").JobsPayloadInvalid | typeof import("./schemas.ts").JobsQueueUnregistered)[]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, typeof JobsPermission, never>, readonly [], undefined>;
227
227
  } & {
228
228
  queues: TQueues;
229
229
  };
@@ -4,5 +4,18 @@ export interface AdminRegistry<TPages extends readonly AdminPage[]> {
4
4
  readonly group: RpcGroup.RpcGroup<RpcGroup.Rpcs<TPages[number]["contract"]>>;
5
5
  readonly pages: TPages;
6
6
  }
7
- export declare function adminRegistry<const TPages extends readonly AdminPage[]>(...pages: TPages): AdminRegistry<TPages>;
7
+ export interface AnyAdminRegistry {
8
+ readonly group: RpcGroup.Any;
9
+ readonly pages: readonly AdminPage[];
10
+ }
11
+ export type UniquePageIds<TPages extends readonly AdminPage[], TSeen extends string = never> = TPages extends readonly [
12
+ infer TPage extends AdminPage,
13
+ ...infer TRest extends readonly AdminPage[]
14
+ ] ? TPage["id"] extends TSeen ? never : UniquePageIds<TRest, TSeen | TPage["id"]> : unknown;
15
+ export type RegistryPages<TRegistries extends readonly AnyAdminRegistry[]> = TRegistries extends readonly [
16
+ infer TFirst extends AnyAdminRegistry,
17
+ ...infer TRest extends readonly AnyAdminRegistry[]
18
+ ] ? readonly [...TFirst["pages"], ...RegistryPages<TRest>] : number extends TRegistries["length"] ? readonly TRegistries[number]["pages"][number][] : readonly [];
19
+ export declare function mergeAdminRegistries<const TRegistries extends readonly AnyAdminRegistry[]>(...registries: TRegistries & UniquePageIds<RegistryPages<TRegistries>>): AdminRegistry<RegistryPages<TRegistries>>;
20
+ export declare function adminRegistry<const TPages extends readonly AdminPage[]>(...pages: TPages & UniquePageIds<TPages>): AdminRegistry<TPages>;
8
21
  //# sourceMappingURL=registry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,WAAW,aAAa,CAAC,MAAM,SAAS,SAAS,SAAS,EAAE;IACjE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,M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AS,SAAS;IACzG,MAAM,MAAM,SAAS,gBAAgB;IACrC,GAAG,MAAM,KAAK,SAAS,SAAS,gBAAgB,EAAE;CAClD,GACE,SAAS,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC,GACtD,MAAM,SAAS,WAAW,CAAC,QAAQ,CAAC,GACnC,SAAS,WAAW,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,EAAE,GAC/C,SAAS,EAAE,CAAC;AAEhB,wBAAgB,oBAAoB,CAAC,KAAK,CAAC,WAAW,SAAS,SAAS,gBAAgB,EAAE,EACzF,GAAG,UAAU,EAAE,WAAW,GAAG,aAAa,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,GACpE,aAAa,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC;AAK7C,wBAAgB,aAAa,CAAC,KAAK,CAAC,MAAM,SAAS,SAAS,SAAS,EAAE,EAAE,GAAG,KAAK,EAAE,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,CAkBxI"}
package/dist/registry.js CHANGED
@@ -1,4 +1,7 @@
1
1
  import { RpcGroup } from "effect/rpc";
2
+ export function mergeAdminRegistries(...registries) {
3
+ return adminRegistry(...registries.flatMap((registry) => registry.pages));
4
+ }
2
5
  export function adminRegistry(...pages) {
3
6
  const ids = new Set();
4
7
  const paths = new Set();
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAQtC,MAAM,UAAU,aAAa,CAA4C,GAAG,KAAa;IACxF,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B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AC9B,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,SAAS,MAAM,CAAC,IAAiB,EAAE,KAAa,EAAE,IAAY;QAC7D,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,mBAAmB,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC;QACtD,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;QAChC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACvC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC;YACjD,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;QAC9B,CAAC;IACF,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;AACvF,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { Layer } from "effect";
2
+ import type { Rpc, RpcGroup } from "effect/rpc";
3
+ import { type AdminRegistry, type AnyAdminRegistry, type RegistryPages, type UniquePageIds } from "#registry.ts";
4
+ type Registration = AnyAdminRegistry & {
5
+ readonly handlers: Layer.Layer<never, unknown, unknown>;
6
+ };
7
+ type ModuleHandlers<TModules extends readonly Registration[]> = {
8
+ readonly [TIndex in keyof TModules]: {
9
+ readonly handlers: Layer.Layer<Rpc.ToHandler<RpcGroup.Rpcs<TModules[TIndex]["pages"][number]["contract"]["application"]>>, unknown, unknown>;
10
+ };
11
+ };
12
+ export declare function mergeAdminRegistrations<const TModules extends readonly Registration[]>(...modules: TModules & NoInfer<ModuleHandlers<TModules>> & UniquePageIds<RegistryPages<TModules>>): AdminRegistry<RegistryPages<TModules>> & {
13
+ readonly handlers: Layer.Layer<Layer.Success<TModules[number]["handlers"]>, Layer.Error<TModules[number]["handlers"]>, Layer.Services<TModules[number]["handlers"]>>;
14
+ };
15
+ export {};
16
+ //# sourceMappingURL=mergeAdminRegistrations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergeAdminRegistrations.d.ts","sourceRoot":"","sources":["../../src/server/mergeAdminRegistrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,gBAAgB,EAAwB,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAEvI,KAAK,YAAY,GAAG,gBAAgB,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;CAAE,CAAC;AAEnG,KAAK,cAAc,CAAC,QAAQ,SAAS,SAAS,YAAY,EAAE,IAAI;IAC/D,QAAQ,EAAE,MAAM,IAAI,MAAM,QAAQ,GAAG;QACpC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;KAC7I;CACD,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,KAAK,CAAC,QAAQ,SAAS,SAAS,YAAY,EAAE,EACrF,GAAG,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,GAAG,aAAa,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,GAC/F,aAAa,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,GAAG;IAC3C,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAC7B,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC,EAC3C,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC,EACzC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC,CAC5C,CAAC;CACF,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { Layer } from "effect";
2
+ import { mergeAdminRegistries } from "#registry.ts";
3
+ export function mergeAdminRegistrations(...modules) {
4
+ return {
5
+ ...mergeAdminRegistries(...modules),
6
+ handlers: Layer.mergeAll(Layer.empty, ...modules.map((module) => module.handlers)),
7
+ };
8
+ }
9
+ //# sourceMappingURL=mergeAdminRegistrations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergeAdminRegistrations.js","sourceRoot":"","sources":["../../src/server/mergeAdminRegistrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,OAAO,EAA6C,oBAAoB,EAA0C,MAAM,cAAc,CAAC;AAmBvI,MAAM,UAAU,uBAAuB,CAAC,GAAG,OAAgC;IAC1E,OAAO;QACN,GAAG,oBAAoB,CAAC,GAAG,OAAO,CAAC;QACnC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;KAClF,CAAC;AACH,CAAC"}
@@ -8,6 +8,7 @@ type HandlerLayers<TPages extends readonly AdminPage[]> = {
8
8
  type RegisteredLayers<THandlers> = Extract<THandlers[keyof THandlers], Layer.Any>;
9
9
  export declare function registerAdmin<const TPages extends readonly AdminPage[], THandlers extends HandlerLayers<TPages>>(registry: AdminRegistry<TPages>, handlers: THandlers & Record<Exclude<keyof THandlers, TPages[number]["id"]>, never>): {
10
10
  readonly group: AdminRegistry<TPages>["group"];
11
+ readonly pages: TPages;
11
12
  readonly handlers: Layer.Layer<Layer.Success<RegisteredLayers<THandlers>>, Layer.Error<RegisteredLayers<THandlers>>, Layer.Services<RegisteredLayers<THandlers>>>;
12
13
  };
13
14
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"registerAdmin.d.ts","sourceRoot":"","sources":["../../src/server/registerAdmin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,KAAK,aAAa,CAAC,MAAM,SAAS,SAAS,SAAS,EAAE,IAAI;IACzD,QAAQ,EAAE,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC;CAChJ,CAAC;AAEF,KAAK,gBAAgB,CAAC,SAAS,IAAI,OAAO,CAAC,SAA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,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC;CAChJ,CAAC;AAEF,KAAK,gBAAgB,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,SAAS,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;AAElF,wBAAgB,aAAa,CAAC,KAAK,CAAC,MAAM,SAAS,SAAS,SAAS,EAAE,EAAE,SAAS,SAAS,aAAa,CAAC,MAAM,CAAC,EAC/G,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,EAC/B,QAAQ,EAAE,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,CAAC,GACjF;IACF,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC;IAC/C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAC7B,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,EAC1C,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,EACxC,KAAK,CAAC,QAAQ,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAC3C,CAAC;CACF,CAAC"}
@@ -11,6 +11,6 @@ export function registerAdmin(registry, handlers) {
11
11
  throw new Error(`Unregistered admin handlers: ${id}`);
12
12
  }
13
13
  }
14
- return { group: registry.group, handlers: Layer.mergeAll(Layer.empty, ...Object.values(handlers)) };
14
+ return { group: registry.group, handlers: Layer.mergeAll(Layer.empty, ...Object.values(handlers)), pages: registry.pages };
15
15
  }
16
16
  //# sourceMappingURL=registerAdmin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registerAdmin.js","sourceRoot":"","sources":["../../src/server/registerAdmin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAsB/B,MAAM,UAAU,aAAa,CAC5B,QAA6C,EAC7C,QAAwE;IAExE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3D,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAC;QAClD,CAAC;IACF,CAAC;IACD,KAAK,MAAM,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,gCAAgC,EAAE,EAAE,CAAC,CAAC;QACvD,CAAC;IACF,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;AACrG,CAAC"}
1
+ {"version":3,"file":"registerAdmin.js","sourceRoot":"","sources":["../../src/server/registerAdmin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAuB/B,MAAM,UAAU,aAAa,CAC5B,QAA6C,EAC7C,QAAwE;IAExE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3D,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAC;QAClD,CAAC;IACF,CAAC;IACD,KAAK,MAAM,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,gCAAgC,EAAE,EAAE,CAAC,CAAC;QACvD,CAAC;IACF,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC;AAC5H,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shivaedev/admin",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "description": "Explicit admin page contracts and a protected native Effect RPC registry",
5
5
  "homepage": "https://github.com/ShivaeDev/platform/tree/main/packages/admin#readme",
6
6
  "bugs": {
@@ -41,25 +41,25 @@
41
41
  "README.md"
42
42
  ],
43
43
  "dependencies": {
44
- "@shivaedev/access": "0.1.1",
45
- "@shivaedev/changes": "0.5.0",
46
- "@shivaedev/contract": "0.19.1",
47
- "@shivaedev/errors": "0.1.0",
48
- "@shivaedev/identity": "0.3.1",
49
- "@shivaedev/jobs": "0.22.0",
50
- "@shivaedev/react": "0.21.1",
51
- "@shivaedev/sql": "0.24.0"
44
+ "@shivaedev/access": "0.1.2",
45
+ "@shivaedev/changes": "0.5.1",
46
+ "@shivaedev/contract": "0.21.0",
47
+ "@shivaedev/errors": "0.1.1",
48
+ "@shivaedev/identity": "0.4.0",
49
+ "@shivaedev/jobs": "0.22.1",
50
+ "@shivaedev/react": "0.22.1",
51
+ "@shivaedev/sql": "0.25.0"
52
52
  },
53
53
  "devDependencies": {
54
- "@effect/atom-react": "4.0.5",
55
- "@shivaedev/quality": "0.44.0",
56
- "@shivaedev/server": "0.3.1",
57
- "@shivaedev/test-sql": "0.10.2",
58
- "@shivaedev/test-story": "0.22.0",
54
+ "@effect/atom-react": "4.0.6",
55
+ "@shivaedev/quality": "0.45.0",
56
+ "@shivaedev/server": "0.5.0",
57
+ "@shivaedev/test-sql": "0.11.0",
58
+ "@shivaedev/test-story": "0.24.0",
59
59
  "@types/node": "24.19.2",
60
60
  "@types/react": "19.3.0",
61
61
  "@types/react-dom": "19.3.0",
62
- "effect": "4.0.5",
62
+ "effect": "4.0.6",
63
63
  "happy-dom": "21.0.4",
64
64
  "react": "19.3.1",
65
65
  "react-dom": "19.3.1",
@@ -67,8 +67,8 @@
67
67
  "vitest": "5.0.5"
68
68
  },
69
69
  "peerDependencies": {
70
- "@effect/atom-react": "4.0.5",
71
- "effect": "4.0.5",
70
+ "@effect/atom-react": "4.0.6",
71
+ "effect": "4.0.6",
72
72
  "react": "19.3.1"
73
73
  },
74
74
  "engines": {
package/src/registry.ts CHANGED
@@ -6,7 +6,37 @@ export interface AdminRegistry<TPages extends readonly AdminPage[]> {
6
6
  readonly pages: TPages;
7
7
  }
8
8
 
9
- export function adminRegistry<const TPages extends readonly AdminPage[]>(...pages: TPages): AdminRegistry<TPages> {
9
+ export interface AnyAdminRegistry {
10
+ readonly group: RpcGroup.Any;
11
+ readonly pages: readonly AdminPage[];
12
+ }
13
+
14
+ export type UniquePageIds<TPages extends readonly AdminPage[], TSeen extends string = never> = TPages extends readonly [
15
+ infer TPage extends AdminPage,
16
+ ...infer TRest extends readonly AdminPage[],
17
+ ]
18
+ ? TPage["id"] extends TSeen
19
+ ? never
20
+ : UniquePageIds<TRest, TSeen | TPage["id"]>
21
+ : unknown;
22
+
23
+ export type RegistryPages<TRegistries extends readonly AnyAdminRegistry[]> = TRegistries extends readonly [
24
+ infer TFirst extends AnyAdminRegistry,
25
+ ...infer TRest extends readonly AnyAdminRegistry[],
26
+ ]
27
+ ? readonly [...TFirst["pages"], ...RegistryPages<TRest>]
28
+ : number extends TRegistries["length"]
29
+ ? readonly TRegistries[number]["pages"][number][]
30
+ : readonly [];
31
+
32
+ export function mergeAdminRegistries<const TRegistries extends readonly AnyAdminRegistry[]>(
33
+ ...registries: TRegistries & UniquePageIds<RegistryPages<TRegistries>>
34
+ ): AdminRegistry<RegistryPages<TRegistries>>;
35
+ export function mergeAdminRegistries(...registries: readonly AnyAdminRegistry[]) {
36
+ return adminRegistry(...registries.flatMap((registry) => registry.pages));
37
+ }
38
+
39
+ export function adminRegistry<const TPages extends readonly AdminPage[]>(...pages: TPages & UniquePageIds<TPages>): AdminRegistry<TPages> {
10
40
  const ids = new Set<string>();
11
41
  const paths = new Set<string>();
12
42
  const tags = new Set<string>();
@@ -0,0 +1,27 @@
1
+ import { Layer } from "effect";
2
+ import type { Rpc, RpcGroup } from "effect/rpc";
3
+ import { type AdminRegistry, type AnyAdminRegistry, mergeAdminRegistries, type RegistryPages, type UniquePageIds } from "#registry.ts";
4
+
5
+ type Registration = AnyAdminRegistry & { readonly handlers: Layer.Layer<never, unknown, unknown> };
6
+
7
+ type ModuleHandlers<TModules extends readonly Registration[]> = {
8
+ readonly [TIndex in keyof TModules]: {
9
+ readonly handlers: Layer.Layer<Rpc.ToHandler<RpcGroup.Rpcs<TModules[TIndex]["pages"][number]["contract"]["application"]>>, unknown, unknown>;
10
+ };
11
+ };
12
+
13
+ export function mergeAdminRegistrations<const TModules extends readonly Registration[]>(
14
+ ...modules: TModules & NoInfer<ModuleHandlers<TModules>> & UniquePageIds<RegistryPages<TModules>>
15
+ ): AdminRegistry<RegistryPages<TModules>> & {
16
+ readonly handlers: Layer.Layer<
17
+ Layer.Success<TModules[number]["handlers"]>,
18
+ Layer.Error<TModules[number]["handlers"]>,
19
+ Layer.Services<TModules[number]["handlers"]>
20
+ >;
21
+ };
22
+ export function mergeAdminRegistrations(...modules: readonly Registration[]) {
23
+ return {
24
+ ...mergeAdminRegistries(...modules),
25
+ handlers: Layer.mergeAll(Layer.empty, ...modules.map((module) => module.handlers)),
26
+ };
27
+ }
@@ -14,6 +14,7 @@ export function registerAdmin<const TPages extends readonly AdminPage[], THandle
14
14
  handlers: THandlers & Record<Exclude<keyof THandlers, TPages[number]["id"]>, never>,
15
15
  ): {
16
16
  readonly group: AdminRegistry<TPages>["group"];
17
+ readonly pages: TPages;
17
18
  readonly handlers: Layer.Layer<
18
19
  Layer.Success<RegisteredLayers<THandlers>>,
19
20
  Layer.Error<RegisteredLayers<THandlers>>,
@@ -35,5 +36,5 @@ export function registerAdmin(
35
36
  throw new Error(`Unregistered admin handlers: ${id}`);
36
37
  }
37
38
  }
38
- return { group: registry.group, handlers: Layer.mergeAll(Layer.empty, ...Object.values(handlers)) };
39
+ return { group: registry.group, handlers: Layer.mergeAll(Layer.empty, ...Object.values(handlers)), pages: registry.pages };
39
40
  }