@pairz/directory 0.0.1 → 1.0.0-rc.82

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 (68) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +70 -1
  3. package/WORDS.md +198 -0
  4. package/actions/code.d.ts +4 -0
  5. package/actions/code.js +135 -0
  6. package/actions/host.d.ts +3 -0
  7. package/actions/host.js +90 -0
  8. package/actions/invite.d.ts +5 -0
  9. package/actions/invite.js +129 -0
  10. package/actions/org.d.ts +10 -0
  11. package/actions/org.js +273 -0
  12. package/collections/credit-code.d.ts +107 -0
  13. package/collections/credit-code.js +28 -0
  14. package/collections/invite.d.ts +74 -0
  15. package/collections/invite.js +20 -0
  16. package/collections/membership.d.ts +65 -0
  17. package/collections/membership.js +22 -0
  18. package/collections/org-host.d.ts +72 -0
  19. package/collections/org-host.js +45 -0
  20. package/collections/org.d.ts +134 -0
  21. package/collections/org.js +58 -0
  22. package/collections/staff.d.ts +35 -0
  23. package/collections/staff.js +12 -0
  24. package/contract.d.ts +8 -0
  25. package/contract.js +8 -0
  26. package/mod.d.ts +69 -0
  27. package/mod.js +126 -0
  28. package/package.json +63 -3
  29. package/routes/console.d.ts +26 -0
  30. package/routes/console.js +129 -0
  31. package/routes/enter.d.ts +18 -0
  32. package/routes/enter.js +47 -0
  33. package/routes/forward.d.ts +35 -0
  34. package/routes/forward.js +120 -0
  35. package/routes/orgs.d.ts +25 -0
  36. package/routes/orgs.js +113 -0
  37. package/routes/signout.d.ts +11 -0
  38. package/routes/signout.js +36 -0
  39. package/shared/enter.d.ts +36 -0
  40. package/shared/enter.js +82 -0
  41. package/shared/http.d.ts +44 -0
  42. package/shared/http.js +79 -0
  43. package/shared/member.d.ts +21 -0
  44. package/shared/member.js +93 -0
  45. package/shared/settings.d.ts +53 -0
  46. package/shared/settings.js +16 -0
  47. package/shared/state.d.ts +75 -0
  48. package/shared/state.js +107 -0
  49. package/views/web/codes.d.ts +27 -0
  50. package/views/web/codes.js +50 -0
  51. package/views/web/console-codes.d.ts +37 -0
  52. package/views/web/console-codes.js +166 -0
  53. package/views/web/console.d.ts +37 -0
  54. package/views/web/console.js +224 -0
  55. package/views/web/lists.d.ts +48 -0
  56. package/views/web/lists.js +42 -0
  57. package/views/web/org.d.ts +12 -0
  58. package/views/web/org.js +62 -0
  59. package/views/web/orgs.d.ts +148 -0
  60. package/views/web/orgs.js +253 -0
  61. package/views/web/style.d.ts +6 -0
  62. package/views/web/style.js +197 -0
  63. package/views/web/switcher.d.ts +81 -0
  64. package/views/web/switcher.js +367 -0
  65. package/views/web/words.d.ts +10 -0
  66. package/views/web/words.js +206 -0
  67. package/web.d.ts +36 -0
  68. package/web.js +57 -0
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Hosts orgs claimed (`shop.example.com`, an app's own): the directory
3
+ * hands a request to one to that org's routes by host (see
4
+ * routes/forward.ts), and the app's front sends it straight to `target`
5
+ * when there's one (an app running elsewhere: its Cloud Run URL). A host is
6
+ * one org's at a time.
7
+ *
8
+ * A name (`<name>.*`, its `_id`) is a host's first label on whichever
9
+ * domain: `shop` claims `shop.pairz.app` and `shop.copilotz.app` at once
10
+ * (a name published on every publish domain, a preview's label on every
11
+ * preview domain), so the domains can change without claiming again. A
12
+ * host's own claim comes first; the org's runtime checks the domain.
13
+ */
14
+ import { defineCollection } from "pairz";
15
+ const orgHostSchema = {
16
+ type: "object",
17
+ properties: {
18
+ /** The org whose it is. */
19
+ org: { type: "string" },
20
+ /** Where the front sends its requests, rather than to the app. */
21
+ target: { type: "string" },
22
+ /** What it serves in the org (a preview's label), for whoever reads the claims. */
23
+ preview: { type: "string" },
24
+ at: { type: "string" },
25
+ },
26
+ required: ["org", "at"],
27
+ };
28
+ export const orgHost = defineCollection({
29
+ schema: orgHostSchema,
30
+ indexes: [["org"]],
31
+ queries: {
32
+ /**
33
+ * Whose a host is, and where its requests go: `{ org, target? }`, or
34
+ * null. Its own claim, else its first label's name. The system's.
35
+ */
36
+ resolve: async (hosts, params) => {
37
+ const host = String(params.host ?? "").toLowerCase();
38
+ const found = await hosts.findOne({ _id: host }) ??
39
+ (/^[^.*]+\.[^*]/.test(host) ? await hosts.findOne({ _id: nameOf(host) }) : null);
40
+ return found ? { org: found.org, ...(found.target ? { target: found.target } : {}) } : null;
41
+ },
42
+ },
43
+ });
44
+ /** A host's first label, as a name's claim keeps it: `shop.pairz.app` is `shop.*`. */
45
+ export const nameOf = (host) => `${host.split(".")[0]}.*`;
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Orgs, as the directory routes them: a name, a kind (`personal` for the one
3
+ * everyone has, `team` for those people make), who made it, and where its
4
+ * rows live (`placement`: the schema it shares, or has to itself). An org's
5
+ * own data (its people's roles, its spaces) lives in the org, never here.
6
+ * `summary` is what the org last reported, for the platform console.
7
+ */
8
+ import { type Infer } from "pairz";
9
+ declare const orgSchema: {
10
+ readonly type: "object";
11
+ readonly properties: {
12
+ readonly name: {
13
+ readonly type: "string";
14
+ };
15
+ readonly kind: {
16
+ readonly type: "string";
17
+ readonly enum: readonly ["personal", "team"];
18
+ };
19
+ /** Who made it (a person, by their sign-in id). */
20
+ readonly by: {
21
+ readonly type: "string";
22
+ };
23
+ readonly placement: {
24
+ readonly type: "object";
25
+ readonly properties: {
26
+ readonly schema: {
27
+ readonly type: "string";
28
+ };
29
+ };
30
+ readonly required: readonly ["schema"];
31
+ };
32
+ /** A suspended org lets nobody in. */
33
+ readonly suspended: {
34
+ readonly type: "boolean";
35
+ };
36
+ readonly summary: {
37
+ readonly type: "object";
38
+ readonly properties: {
39
+ readonly people: {
40
+ readonly type: "number";
41
+ };
42
+ readonly spaces: {
43
+ readonly type: "number";
44
+ };
45
+ readonly active: {
46
+ readonly type: "string";
47
+ };
48
+ readonly at: {
49
+ readonly type: "string";
50
+ };
51
+ };
52
+ };
53
+ readonly at: {
54
+ readonly type: "string";
55
+ };
56
+ };
57
+ readonly required: readonly ["name", "kind", "by", "placement", "at"];
58
+ };
59
+ export declare const org: Omit<import("pairz").CollectionDef, "queries" | "schema"> & {
60
+ queries?: Record<string, import("pairz").QueryDef<import("pairz").WithId<{
61
+ [x: string]: unknown;
62
+ suspended?: boolean | undefined;
63
+ summary?: {
64
+ [x: string]: unknown;
65
+ at?: string | undefined;
66
+ people?: number | undefined;
67
+ spaces?: number | undefined;
68
+ active?: string | undefined;
69
+ } | undefined;
70
+ placement: {
71
+ [x: string]: unknown;
72
+ schema: string;
73
+ };
74
+ at: string;
75
+ name: string;
76
+ kind: "personal" | "team";
77
+ by: string;
78
+ }>>> | undefined;
79
+ } & {
80
+ schema: {
81
+ readonly type: "object";
82
+ readonly properties: {
83
+ readonly name: {
84
+ readonly type: "string";
85
+ };
86
+ readonly kind: {
87
+ readonly type: "string";
88
+ readonly enum: readonly ["personal", "team"];
89
+ };
90
+ /** Who made it (a person, by their sign-in id). */
91
+ readonly by: {
92
+ readonly type: "string";
93
+ };
94
+ readonly placement: {
95
+ readonly type: "object";
96
+ readonly properties: {
97
+ readonly schema: {
98
+ readonly type: "string";
99
+ };
100
+ };
101
+ readonly required: readonly ["schema"];
102
+ };
103
+ /** A suspended org lets nobody in. */
104
+ readonly suspended: {
105
+ readonly type: "boolean";
106
+ };
107
+ readonly summary: {
108
+ readonly type: "object";
109
+ readonly properties: {
110
+ readonly people: {
111
+ readonly type: "number";
112
+ };
113
+ readonly spaces: {
114
+ readonly type: "number";
115
+ };
116
+ readonly active: {
117
+ readonly type: "string";
118
+ };
119
+ readonly at: {
120
+ readonly type: "string";
121
+ };
122
+ };
123
+ };
124
+ readonly at: {
125
+ readonly type: "string";
126
+ };
127
+ };
128
+ readonly required: readonly ["name", "kind", "by", "placement", "at"];
129
+ };
130
+ };
131
+ export type Org = Infer<typeof orgSchema> & {
132
+ _id: string;
133
+ };
134
+ export {};
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Orgs, as the directory routes them: a name, a kind (`personal` for the one
3
+ * everyone has, `team` for those people make), who made it, and where its
4
+ * rows live (`placement`: the schema it shares, or has to itself). An org's
5
+ * own data (its people's roles, its spaces) lives in the org, never here.
6
+ * `summary` is what the org last reported, for the platform console.
7
+ */
8
+ import { defineCollection } from "pairz";
9
+ const orgSchema = {
10
+ type: "object",
11
+ properties: {
12
+ name: { type: "string" },
13
+ kind: { type: "string", enum: ["personal", "team"] },
14
+ /** Who made it (a person, by their sign-in id). */
15
+ by: { type: "string" },
16
+ placement: {
17
+ type: "object",
18
+ properties: { schema: { type: "string" } },
19
+ required: ["schema"],
20
+ },
21
+ /** A suspended org lets nobody in. */
22
+ suspended: { type: "boolean" },
23
+ summary: {
24
+ type: "object",
25
+ properties: {
26
+ people: { type: "number" },
27
+ spaces: { type: "number" },
28
+ active: { type: "string" },
29
+ at: { type: "string" },
30
+ },
31
+ },
32
+ at: { type: "string" },
33
+ },
34
+ required: ["name", "kind", "by", "placement", "at"],
35
+ };
36
+ export const org = defineCollection({
37
+ schema: orgSchema,
38
+ indexes: [["by"]],
39
+ queries: {
40
+ /**
41
+ * An org as the directory opens it (its name, kind, placement, and
42
+ * whether it's suspended), or null. The system's: the directory's routes
43
+ * ask it for every request they forward, and the app, to open an org.
44
+ */
45
+ info: async (orgs, params) => {
46
+ const found = await orgs.findOne({ _id: String(params.org ?? "") });
47
+ return found
48
+ ? {
49
+ id: found._id,
50
+ name: found.name,
51
+ kind: found.kind,
52
+ placement: found.placement,
53
+ ...(found.suspended ? { suspended: true } : {}),
54
+ }
55
+ : null;
56
+ },
57
+ },
58
+ });
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Platform staff, by verified email: they enter any org, reaching all of it,
3
+ * and what they do there is on its record as theirs. The `directory`
4
+ * resource's `staff` list seeds them.
5
+ */
6
+ import { type Infer } from "pairz";
7
+ declare const staffSchema: {
8
+ readonly type: "object";
9
+ readonly properties: {
10
+ readonly at: {
11
+ readonly type: "string";
12
+ };
13
+ };
14
+ readonly required: readonly ["at"];
15
+ };
16
+ export declare const staff: Omit<import("pairz").CollectionDef, "queries" | "schema"> & {
17
+ queries?: Record<string, import("pairz").QueryDef<import("pairz").WithId<{
18
+ [x: string]: unknown;
19
+ at: string;
20
+ }>>> | undefined;
21
+ } & {
22
+ schema: {
23
+ readonly type: "object";
24
+ readonly properties: {
25
+ readonly at: {
26
+ readonly type: "string";
27
+ };
28
+ };
29
+ readonly required: readonly ["at"];
30
+ };
31
+ };
32
+ export type Staff = Infer<typeof staffSchema> & {
33
+ _id: string;
34
+ };
35
+ export {};
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Platform staff, by verified email: they enter any org, reaching all of it,
3
+ * and what they do there is on its record as theirs. The `directory`
4
+ * resource's `staff` list seeds them.
5
+ */
6
+ import { defineCollection } from "pairz";
7
+ const staffSchema = {
8
+ type: "object",
9
+ properties: { at: { type: "string" } },
10
+ required: ["at"],
11
+ };
12
+ export const staff = defineCollection({ schema: staffSchema });
package/contract.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The directory plugin's contract: what other plugins' front ends use of it
3
+ * in the browser, its browser half (views/web/orgs.ts): the person's orgs
4
+ * and invitations, going between them, and staff's console. They reach the
5
+ * rest over HTTP, at the directory's routes (`/orgs`, `/console/orgs`,
6
+ * `/console/codes`). Its own front end (web.tsx) is built on the same.
7
+ */
8
+ export { answerOrgInvite, arrived, asStaff, type ConsoleOrg, consoleOrgs, createGiftCode, createOrg, currentOrg, deleteOrg, enterOrg, exportOrgUrl, type GiftCode, giftCodes, loadOrgs, moveOrg, type Org, type OrgInvite, orgName, type Orgs, type OrgsState, reenter, refreshOrgs, revokeGiftCode, type Switching, updateOrg, useOrgs, useSwitching, } from "./views/web/orgs.js";
package/contract.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The directory plugin's contract: what other plugins' front ends use of it
3
+ * in the browser, its browser half (views/web/orgs.ts): the person's orgs
4
+ * and invitations, going between them, and staff's console. They reach the
5
+ * rest over HTTP, at the directory's routes (`/orgs`, `/console/orgs`,
6
+ * `/console/codes`). Its own front end (web.tsx) is built on the same.
7
+ */
8
+ export { answerOrgInvite, arrived, asStaff, consoleOrgs, createGiftCode, createOrg, currentOrg, deleteOrg, enterOrg, exportOrgUrl, giftCodes, loadOrgs, moveOrg, orgName, reenter, refreshOrgs, revokeGiftCode, updateOrg, useOrgs, useSwitching, } from "./views/web/orgs.js";
package/mod.d.ts ADDED
@@ -0,0 +1,69 @@
1
+ /**
2
+ * The directory (`@pairz/directory`), for apps that serve many orgs behind
3
+ * one address (see design/tenancy.md): a runtime of its own, beside identity and the ways to
4
+ * sign in, in front of every org's. It knows who signs in (the identity
5
+ * plugin's people, by their sign-in method), which orgs each belongs to,
6
+ * invitations to orgs by email, where each org lives, the hosts orgs claimed
7
+ * (a custom domain, an app's; or a name, a first label on every domain: a
8
+ * published app's, a preview's; `orgHost.resolve` says whose), and
9
+ * platform staff.
10
+ * An org's own data (its people's roles, spaces, conversations) lives in the
11
+ * org: each is a runtime of its own, opened on its first use and closed when
12
+ * idle (the app's `runtimes(open)`, in `directory.orgs`), with
13
+ * `directory.member(dir, org)` among its plugins.
14
+ *
15
+ * Its runtime is the app's `fetch`: its routes answer what's the
16
+ * directory's, and hand everything else, untouched, to the org's runtime
17
+ * (routes/forward.ts):
18
+ *
19
+ * - `/o/<org>/…`: that org, by its address (its page's `/connect` and
20
+ * socket, its API, its webhooks, its computers);
21
+ * - anything else: the org the browser is in (its `org` cookie), going in
22
+ * first when a page needs it to; for someone signed in nowhere, the
23
+ * lobby (`directory.lobby`: the sign-in page);
24
+ * - a host an org claimed (with the app's own named, `hosts`): that
25
+ * org's routes by host alone; `GET /__pairz/hosts/resolve` says whose
26
+ * a host is, for the app's front.
27
+ *
28
+ * Its own: `GET /orgs`, `POST /orgs`, `POST /orgs/enter`, `POST
29
+ * /orgs/invites/answer` (routes/orgs.ts), `POST /signout` out of every org
30
+ * (routes/signout.ts), and staff's `/console/orgs…` and `/console/codes…`
31
+ * (routes/console.ts). People sign in at the directory, with its plugins'
32
+ * routes (`/signin/google`, `/signin/dev`); its session is identity's, in the
33
+ * `dir` cookie (`__Host-dir` wherever it's Secure); which org a browser is in,
34
+ * `org`; each org's session, `s_<org>`. Today's names, so nobody signs in
35
+ * again.
36
+ *
37
+ * ```ts
38
+ * import { identity, googleSignIn } from "pairz/plugins/access";
39
+ * import { directory } from "@pairz/directory";
40
+ *
41
+ * const dir = await createRuntime({ store, plugins: [identity, googleSignIn, directory,
42
+ * definePlugin({ name: "d", resources: {
43
+ * directory: { staff: ["you@example.com"], orgs, lobby },
44
+ * hosts: { "app.example.com": true },
45
+ * } })] });
46
+ * const orgs = runtimes(async (id) => {
47
+ * const org = await dir.query("org.info", { org: id });
48
+ * return org && await createRuntime({ store: storeOf(org), plugins: [...app, directory.member(dir, org)] });
49
+ * });
50
+ * Deno.serve(dir.fetch);
51
+ * ```
52
+ */
53
+ import { type Plugin } from "pairz";
54
+ import { member } from "./shared/member.js";
55
+ export type { Org } from "./collections/org.js";
56
+ export type { Membership } from "./collections/membership.js";
57
+ export type { Invite } from "./collections/invite.js";
58
+ export type { OrgHost } from "./collections/org-host.js";
59
+ export type { CreditCode } from "./collections/credit-code.js";
60
+ export type { DirectorySettings, Operations, OrgInfo } from "./shared/settings.js";
61
+ /**
62
+ * The directory plugin, and what each org's runtime gets of it:
63
+ * `directory.member(dir, org)` (see shared/member.ts), with the org as
64
+ * `org.info` says it.
65
+ */
66
+ export declare const directory: Plugin & {
67
+ member: typeof member;
68
+ };
69
+ export default directory;
package/mod.js ADDED
@@ -0,0 +1,126 @@
1
+ /**
2
+ * The directory (`@pairz/directory`), for apps that serve many orgs behind
3
+ * one address (see design/tenancy.md): a runtime of its own, beside identity and the ways to
4
+ * sign in, in front of every org's. It knows who signs in (the identity
5
+ * plugin's people, by their sign-in method), which orgs each belongs to,
6
+ * invitations to orgs by email, where each org lives, the hosts orgs claimed
7
+ * (a custom domain, an app's; or a name, a first label on every domain: a
8
+ * published app's, a preview's; `orgHost.resolve` says whose), and
9
+ * platform staff.
10
+ * An org's own data (its people's roles, spaces, conversations) lives in the
11
+ * org: each is a runtime of its own, opened on its first use and closed when
12
+ * idle (the app's `runtimes(open)`, in `directory.orgs`), with
13
+ * `directory.member(dir, org)` among its plugins.
14
+ *
15
+ * Its runtime is the app's `fetch`: its routes answer what's the
16
+ * directory's, and hand everything else, untouched, to the org's runtime
17
+ * (routes/forward.ts):
18
+ *
19
+ * - `/o/<org>/…`: that org, by its address (its page's `/connect` and
20
+ * socket, its API, its webhooks, its computers);
21
+ * - anything else: the org the browser is in (its `org` cookie), going in
22
+ * first when a page needs it to; for someone signed in nowhere, the
23
+ * lobby (`directory.lobby`: the sign-in page);
24
+ * - a host an org claimed (with the app's own named, `hosts`): that
25
+ * org's routes by host alone; `GET /__pairz/hosts/resolve` says whose
26
+ * a host is, for the app's front.
27
+ *
28
+ * Its own: `GET /orgs`, `POST /orgs`, `POST /orgs/enter`, `POST
29
+ * /orgs/invites/answer` (routes/orgs.ts), `POST /signout` out of every org
30
+ * (routes/signout.ts), and staff's `/console/orgs…` and `/console/codes…`
31
+ * (routes/console.ts). People sign in at the directory, with its plugins'
32
+ * routes (`/signin/google`, `/signin/dev`); its session is identity's, in the
33
+ * `dir` cookie (`__Host-dir` wherever it's Secure); which org a browser is in,
34
+ * `org`; each org's session, `s_<org>`. Today's names, so nobody signs in
35
+ * again.
36
+ *
37
+ * ```ts
38
+ * import { identity, googleSignIn } from "pairz/plugins/access";
39
+ * import { directory } from "@pairz/directory";
40
+ *
41
+ * const dir = await createRuntime({ store, plugins: [identity, googleSignIn, directory,
42
+ * definePlugin({ name: "d", resources: {
43
+ * directory: { staff: ["you@example.com"], orgs, lobby },
44
+ * hosts: { "app.example.com": true },
45
+ * } })] });
46
+ * const orgs = runtimes(async (id) => {
47
+ * const org = await dir.query("org.info", { org: id });
48
+ * return org && await createRuntime({ store: storeOf(org), plugins: [...app, directory.member(dir, org)] });
49
+ * });
50
+ * Deno.serve(dir.fetch);
51
+ * ```
52
+ */
53
+ import { definePlugin } from "pairz";
54
+ import { answerInviteRoute, enterOrgRoute, orgsRoute } from "./routes/orgs.js";
55
+ import { signOutRoute } from "./routes/signout.js";
56
+ import { codesRoute, consoleOrgsRoute, operateRoute, revokeCodeRoute } from "./routes/console.js";
57
+ import { addressedRoute, claimedRoute, currentRoute, resolveRoute } from "./routes/forward.js";
58
+ import { RESOLVE, RESOLVE_BEFORE } from "./shared/http.js";
59
+ import { member } from "./shared/member.js";
60
+ import { createOrgAction, deleteOrgAction, enterOrgAction, leaveOrgAction, listOrgsAction, myOrgsAction, placeOrgAction, renameOrgAction, reportOrgAction, suspendOrgAction, } from "./actions/org.js";
61
+ import { answerInviteAction, cancelInviteAction, myInvitesAction, orgInvitesAction, sendInviteAction, } from "./actions/invite.js";
62
+ import { claimHostAction, freeHostAction, releaseHostAction } from "./actions/host.js";
63
+ import { claimCodeAction, createCodeAction, listCodesAction, revokeCodeAction, } from "./actions/code.js";
64
+ import { creditCode } from "./collections/credit-code.js";
65
+ import { invite } from "./collections/invite.js";
66
+ import { membership } from "./collections/membership.js";
67
+ import { org } from "./collections/org.js";
68
+ import { orgHost } from "./collections/org-host.js";
69
+ import { staff } from "./collections/staff.js";
70
+ const plugin = definePlugin({
71
+ name: "directory",
72
+ requires: ["identity"],
73
+ collections: { org, membership, invite, staff, orgHost, creditCode },
74
+ actions: {
75
+ "org.create": createOrgAction,
76
+ "org.mine": myOrgsAction,
77
+ "org.enter": enterOrgAction,
78
+ "org.leave": leaveOrgAction,
79
+ "org.rename": renameOrgAction,
80
+ "org.suspend": suspendOrgAction,
81
+ "org.report": reportOrgAction,
82
+ "org.list": listOrgsAction,
83
+ "org.place": placeOrgAction,
84
+ "org.delete": deleteOrgAction,
85
+ "invite.send": sendInviteAction,
86
+ "invite.mine": myInvitesAction,
87
+ "invite.org": orgInvitesAction,
88
+ "invite.answer": answerInviteAction,
89
+ "invite.cancel": cancelInviteAction,
90
+ "host.claim": claimHostAction,
91
+ "host.release": releaseHostAction,
92
+ "host.free": freeHostAction,
93
+ "code.create": createCodeAction,
94
+ "code.claim": claimCodeAction,
95
+ "code.list": listCodesAction,
96
+ "code.revoke": revokeCodeAction,
97
+ },
98
+ routes: {
99
+ "/orgs": orgsRoute,
100
+ "/orgs/enter": enterOrgRoute,
101
+ "/orgs/invites/answer": answerInviteRoute,
102
+ // Out of every org, in place of identity's own.
103
+ "/signout": signOutRoute,
104
+ "/console/orgs": consoleOrgsRoute,
105
+ "/console/orgs/:org": operateRoute,
106
+ "/console/orgs/:org/:what": operateRoute,
107
+ "/console/codes": codesRoute,
108
+ "/console/codes/revoke": revokeCodeRoute,
109
+ [RESOLVE]: resolveRoute,
110
+ [RESOLVE_BEFORE]: resolveRoute,
111
+ "/o/:org": addressedRoute,
112
+ "/o/:org/*": addressedRoute,
113
+ "/*": currentRoute,
114
+ // Every host but the app's own (`hosts`): those orgs claimed.
115
+ "*://*:*/*": claimedRoute,
116
+ },
117
+ // Its session is identity's, in today's cookie: `dir` (`__Host-dir` wherever it's Secure).
118
+ resources: { cookies: { names: { session: "dir" } } },
119
+ });
120
+ /**
121
+ * The directory plugin, and what each org's runtime gets of it:
122
+ * `directory.member(dir, org)` (see shared/member.ts), with the org as
123
+ * `org.info` says it.
124
+ */
125
+ export const directory = Object.assign(plugin, { member });
126
+ export default directory;
package/package.json CHANGED
@@ -1,7 +1,67 @@
1
1
  {
2
2
  "name": "@pairz/directory",
3
- "version": "0.0.1",
4
- "description": "Pairz (formerly Copilotz): placeholder until the first release.",
3
+ "version": "1.0.0-rc.82",
4
+ "description": "Many orgs behind one address: who signs in, which orgs they belong to, and going between them. A Pairz plugin.",
5
+ "keywords": [
6
+ "pairz",
7
+ "agents",
8
+ "ai",
9
+ "plugin"
10
+ ],
11
+ "homepage": "https://github.com/pairzhq/pairz/tree/main/packages/directory#readme",
12
+ "bugs": "https://github.com/pairzhq/pairz/issues",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/pairzhq/pairz.git",
16
+ "directory": "packages/directory"
17
+ },
5
18
  "license": "MIT",
6
- "repository": { "type": "git", "url": "git+https://github.com/pairzhq/pairz.git" }
19
+ "type": "module",
20
+ "engines": {
21
+ "node": ">=24"
22
+ },
23
+ "sideEffects": false,
24
+ "types": "./mod.d.ts",
25
+ "exports": {
26
+ ".": {
27
+ "types": "./mod.d.ts",
28
+ "default": "./mod.js"
29
+ },
30
+ "./web": {
31
+ "types": "./web.d.ts",
32
+ "default": "./web.js"
33
+ },
34
+ "./contract": {
35
+ "types": "./contract.d.ts",
36
+ "default": "./contract.js"
37
+ },
38
+ "./package.json": "./package.json"
39
+ },
40
+ "files": [
41
+ "LICENSE",
42
+ "README.md",
43
+ "WORDS.md",
44
+ "actions",
45
+ "collections",
46
+ "contract.d.ts",
47
+ "contract.js",
48
+ "mod.d.ts",
49
+ "mod.js",
50
+ "routes",
51
+ "shared",
52
+ "views",
53
+ "web.d.ts",
54
+ "web.js"
55
+ ],
56
+ "dependencies": {},
57
+ "peerDependencies": {
58
+ "@types/react": "^19.3.0",
59
+ "pairz": "1.0.0-rc.82",
60
+ "react": "^19.3.1"
61
+ },
62
+ "peerDependenciesMeta": {
63
+ "@types/react": {
64
+ "optional": true
65
+ }
66
+ }
7
67
  }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Staff's console (platform staff only, by their sign-in or the email they
3
+ * verified; anyone else, a 403):
4
+ *
5
+ * - `GET /console/orgs`: every org, with what each last reported;
6
+ * - `POST /console/orgs/<id>` `{ suspended?, name? }`;
7
+ * - `POST /console/orgs/<id>/move` `{ schema }`: its rows to another schema
8
+ * (closed first, then opened there on its next use);
9
+ * - `GET /console/orgs/<id>/export`: its rows, as SQL, to save;
10
+ * - `POST /console/orgs/<id>/delete` `{ confirm: <its name> }`: closed, its
11
+ * rows dropped, and it's forgotten.
12
+ *
13
+ * The rows' part is the app's (`operations` in the directory's settings);
14
+ * without it, a 501. Gift codes: `GET /console/codes`; `POST /console/codes`
15
+ * `{ amount, expires?, until?, note? }` (the code, shown this once); `POST
16
+ * /console/codes/revoke` `{ id }`.
17
+ */
18
+ import { type Route } from "pairz";
19
+ /** `GET /console/orgs`. */
20
+ export declare const consoleOrgsRoute: Route;
21
+ /** `/console/orgs/<id>` and `/console/orgs/<id>/<what>`: staff's operations on an org. */
22
+ export declare const operateRoute: Route;
23
+ /** `GET /console/codes` and `POST /console/codes`. */
24
+ export declare const codesRoute: Route;
25
+ /** `POST /console/codes/revoke` `{ id }`. */
26
+ export declare const revokeCodeRoute: Route;