@pairz/directory 0.0.1 → 1.0.0-rc.81
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/LICENSE +21 -0
- package/README.md +70 -1
- package/WORDS.md +198 -0
- package/actions/code.d.ts +4 -0
- package/actions/code.js +135 -0
- package/actions/host.d.ts +2 -0
- package/actions/host.js +55 -0
- package/actions/invite.d.ts +5 -0
- package/actions/invite.js +129 -0
- package/actions/org.d.ts +10 -0
- package/actions/org.js +273 -0
- package/collections/credit-code.d.ts +107 -0
- package/collections/credit-code.js +28 -0
- package/collections/invite.d.ts +74 -0
- package/collections/invite.js +20 -0
- package/collections/membership.d.ts +65 -0
- package/collections/membership.js +22 -0
- package/collections/org-host.d.ts +55 -0
- package/collections/org-host.js +30 -0
- package/collections/org.d.ts +134 -0
- package/collections/org.js +58 -0
- package/collections/staff.d.ts +35 -0
- package/collections/staff.js +12 -0
- package/contract.d.ts +8 -0
- package/contract.js +8 -0
- package/mod.d.ts +67 -0
- package/mod.js +123 -0
- package/package.json +63 -3
- package/routes/console.d.ts +26 -0
- package/routes/console.js +129 -0
- package/routes/enter.d.ts +18 -0
- package/routes/enter.js +47 -0
- package/routes/forward.d.ts +35 -0
- package/routes/forward.js +120 -0
- package/routes/orgs.d.ts +25 -0
- package/routes/orgs.js +113 -0
- package/routes/signout.d.ts +11 -0
- package/routes/signout.js +36 -0
- package/shared/enter.d.ts +36 -0
- package/shared/enter.js +82 -0
- package/shared/http.d.ts +44 -0
- package/shared/http.js +79 -0
- package/shared/member.d.ts +21 -0
- package/shared/member.js +73 -0
- package/shared/settings.d.ts +53 -0
- package/shared/settings.js +16 -0
- package/shared/state.d.ts +74 -0
- package/shared/state.js +101 -0
- package/views/web/codes.d.ts +27 -0
- package/views/web/codes.js +50 -0
- package/views/web/console-codes.d.ts +37 -0
- package/views/web/console-codes.js +166 -0
- package/views/web/console.d.ts +37 -0
- package/views/web/console.js +224 -0
- package/views/web/lists.d.ts +48 -0
- package/views/web/lists.js +42 -0
- package/views/web/org.d.ts +12 -0
- package/views/web/org.js +62 -0
- package/views/web/orgs.d.ts +148 -0
- package/views/web/orgs.js +253 -0
- package/views/web/style.d.ts +6 -0
- package/views/web/style.js +197 -0
- package/views/web/switcher.d.ts +81 -0
- package/views/web/switcher.js +367 -0
- package/views/web/words.d.ts +10 -0
- package/views/web/words.js +206 -0
- package/web.d.ts +36 -0
- package/web.js +57 -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,67 @@
|
|
|
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 preview's, an app's: `orgHost.resolve` says whose), and platform staff.
|
|
8
|
+
* An org's own data (its people's roles, spaces, conversations) lives in the
|
|
9
|
+
* org: each is a runtime of its own, opened on its first use and closed when
|
|
10
|
+
* idle (the app's `runtimes(open)`, in `directory.orgs`), with
|
|
11
|
+
* `directory.member(dir, org)` among its plugins.
|
|
12
|
+
*
|
|
13
|
+
* Its runtime is the app's `fetch`: its routes answer what's the
|
|
14
|
+
* directory's, and hand everything else, untouched, to the org's runtime
|
|
15
|
+
* (routes/forward.ts):
|
|
16
|
+
*
|
|
17
|
+
* - `/o/<org>/…`: that org, by its address (its page's `/connect` and
|
|
18
|
+
* socket, its API, its webhooks, its computers);
|
|
19
|
+
* - anything else: the org the browser is in (its `org` cookie), going in
|
|
20
|
+
* first when a page needs it to; for someone signed in nowhere, the
|
|
21
|
+
* lobby (`directory.lobby`: the sign-in page);
|
|
22
|
+
* - a host an org claimed (with the app's own named, `hosts`): that
|
|
23
|
+
* org's routes by host alone; `GET /__pairz/hosts/resolve` says whose
|
|
24
|
+
* a host is, for the app's front.
|
|
25
|
+
*
|
|
26
|
+
* Its own: `GET /orgs`, `POST /orgs`, `POST /orgs/enter`, `POST
|
|
27
|
+
* /orgs/invites/answer` (routes/orgs.ts), `POST /signout` out of every org
|
|
28
|
+
* (routes/signout.ts), and staff's `/console/orgs…` and `/console/codes…`
|
|
29
|
+
* (routes/console.ts). People sign in at the directory, with its plugins'
|
|
30
|
+
* routes (`/signin/google`, `/signin/dev`); its session is identity's, in the
|
|
31
|
+
* `dir` cookie (`__Host-dir` wherever it's Secure); which org a browser is in,
|
|
32
|
+
* `org`; each org's session, `s_<org>`. Today's names, so nobody signs in
|
|
33
|
+
* again.
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { identity, googleSignIn } from "pairz/plugins/access";
|
|
37
|
+
* import { directory } from "@pairz/directory";
|
|
38
|
+
*
|
|
39
|
+
* const dir = await createRuntime({ store, plugins: [identity, googleSignIn, directory,
|
|
40
|
+
* definePlugin({ name: "d", resources: {
|
|
41
|
+
* directory: { staff: ["you@example.com"], orgs, lobby },
|
|
42
|
+
* hosts: { "app.example.com": true },
|
|
43
|
+
* } })] });
|
|
44
|
+
* const orgs = runtimes(async (id) => {
|
|
45
|
+
* const org = await dir.query("org.info", { org: id });
|
|
46
|
+
* return org && await createRuntime({ store: storeOf(org), plugins: [...app, directory.member(dir, org)] });
|
|
47
|
+
* });
|
|
48
|
+
* Deno.serve(dir.fetch);
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
import { type Plugin } from "pairz";
|
|
52
|
+
import { member } from "./shared/member.js";
|
|
53
|
+
export type { Org } from "./collections/org.js";
|
|
54
|
+
export type { Membership } from "./collections/membership.js";
|
|
55
|
+
export type { Invite } from "./collections/invite.js";
|
|
56
|
+
export type { OrgHost } from "./collections/org-host.js";
|
|
57
|
+
export type { CreditCode } from "./collections/credit-code.js";
|
|
58
|
+
export type { DirectorySettings, Operations, OrgInfo } from "./shared/settings.js";
|
|
59
|
+
/**
|
|
60
|
+
* The directory plugin, and what each org's runtime gets of it:
|
|
61
|
+
* `directory.member(dir, org)` (see shared/member.ts), with the org as
|
|
62
|
+
* `org.info` says it.
|
|
63
|
+
*/
|
|
64
|
+
export declare const directory: Plugin & {
|
|
65
|
+
member: typeof member;
|
|
66
|
+
};
|
|
67
|
+
export default directory;
|
package/mod.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
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 preview's, an app's: `orgHost.resolve` says whose), and platform staff.
|
|
8
|
+
* An org's own data (its people's roles, spaces, conversations) lives in the
|
|
9
|
+
* org: each is a runtime of its own, opened on its first use and closed when
|
|
10
|
+
* idle (the app's `runtimes(open)`, in `directory.orgs`), with
|
|
11
|
+
* `directory.member(dir, org)` among its plugins.
|
|
12
|
+
*
|
|
13
|
+
* Its runtime is the app's `fetch`: its routes answer what's the
|
|
14
|
+
* directory's, and hand everything else, untouched, to the org's runtime
|
|
15
|
+
* (routes/forward.ts):
|
|
16
|
+
*
|
|
17
|
+
* - `/o/<org>/…`: that org, by its address (its page's `/connect` and
|
|
18
|
+
* socket, its API, its webhooks, its computers);
|
|
19
|
+
* - anything else: the org the browser is in (its `org` cookie), going in
|
|
20
|
+
* first when a page needs it to; for someone signed in nowhere, the
|
|
21
|
+
* lobby (`directory.lobby`: the sign-in page);
|
|
22
|
+
* - a host an org claimed (with the app's own named, `hosts`): that
|
|
23
|
+
* org's routes by host alone; `GET /__pairz/hosts/resolve` says whose
|
|
24
|
+
* a host is, for the app's front.
|
|
25
|
+
*
|
|
26
|
+
* Its own: `GET /orgs`, `POST /orgs`, `POST /orgs/enter`, `POST
|
|
27
|
+
* /orgs/invites/answer` (routes/orgs.ts), `POST /signout` out of every org
|
|
28
|
+
* (routes/signout.ts), and staff's `/console/orgs…` and `/console/codes…`
|
|
29
|
+
* (routes/console.ts). People sign in at the directory, with its plugins'
|
|
30
|
+
* routes (`/signin/google`, `/signin/dev`); its session is identity's, in the
|
|
31
|
+
* `dir` cookie (`__Host-dir` wherever it's Secure); which org a browser is in,
|
|
32
|
+
* `org`; each org's session, `s_<org>`. Today's names, so nobody signs in
|
|
33
|
+
* again.
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { identity, googleSignIn } from "pairz/plugins/access";
|
|
37
|
+
* import { directory } from "@pairz/directory";
|
|
38
|
+
*
|
|
39
|
+
* const dir = await createRuntime({ store, plugins: [identity, googleSignIn, directory,
|
|
40
|
+
* definePlugin({ name: "d", resources: {
|
|
41
|
+
* directory: { staff: ["you@example.com"], orgs, lobby },
|
|
42
|
+
* hosts: { "app.example.com": true },
|
|
43
|
+
* } })] });
|
|
44
|
+
* const orgs = runtimes(async (id) => {
|
|
45
|
+
* const org = await dir.query("org.info", { org: id });
|
|
46
|
+
* return org && await createRuntime({ store: storeOf(org), plugins: [...app, directory.member(dir, org)] });
|
|
47
|
+
* });
|
|
48
|
+
* Deno.serve(dir.fetch);
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
import { definePlugin } from "pairz";
|
|
52
|
+
import { answerInviteRoute, enterOrgRoute, orgsRoute } from "./routes/orgs.js";
|
|
53
|
+
import { signOutRoute } from "./routes/signout.js";
|
|
54
|
+
import { codesRoute, consoleOrgsRoute, operateRoute, revokeCodeRoute } from "./routes/console.js";
|
|
55
|
+
import { addressedRoute, claimedRoute, currentRoute, resolveRoute } from "./routes/forward.js";
|
|
56
|
+
import { RESOLVE, RESOLVE_BEFORE } from "./shared/http.js";
|
|
57
|
+
import { member } from "./shared/member.js";
|
|
58
|
+
import { createOrgAction, deleteOrgAction, enterOrgAction, leaveOrgAction, listOrgsAction, myOrgsAction, placeOrgAction, renameOrgAction, reportOrgAction, suspendOrgAction, } from "./actions/org.js";
|
|
59
|
+
import { answerInviteAction, cancelInviteAction, myInvitesAction, orgInvitesAction, sendInviteAction, } from "./actions/invite.js";
|
|
60
|
+
import { claimHostAction, releaseHostAction } from "./actions/host.js";
|
|
61
|
+
import { claimCodeAction, createCodeAction, listCodesAction, revokeCodeAction, } from "./actions/code.js";
|
|
62
|
+
import { creditCode } from "./collections/credit-code.js";
|
|
63
|
+
import { invite } from "./collections/invite.js";
|
|
64
|
+
import { membership } from "./collections/membership.js";
|
|
65
|
+
import { org } from "./collections/org.js";
|
|
66
|
+
import { orgHost } from "./collections/org-host.js";
|
|
67
|
+
import { staff } from "./collections/staff.js";
|
|
68
|
+
const plugin = definePlugin({
|
|
69
|
+
name: "directory",
|
|
70
|
+
requires: ["identity"],
|
|
71
|
+
collections: { org, membership, invite, staff, orgHost, creditCode },
|
|
72
|
+
actions: {
|
|
73
|
+
"org.create": createOrgAction,
|
|
74
|
+
"org.mine": myOrgsAction,
|
|
75
|
+
"org.enter": enterOrgAction,
|
|
76
|
+
"org.leave": leaveOrgAction,
|
|
77
|
+
"org.rename": renameOrgAction,
|
|
78
|
+
"org.suspend": suspendOrgAction,
|
|
79
|
+
"org.report": reportOrgAction,
|
|
80
|
+
"org.list": listOrgsAction,
|
|
81
|
+
"org.place": placeOrgAction,
|
|
82
|
+
"org.delete": deleteOrgAction,
|
|
83
|
+
"invite.send": sendInviteAction,
|
|
84
|
+
"invite.mine": myInvitesAction,
|
|
85
|
+
"invite.org": orgInvitesAction,
|
|
86
|
+
"invite.answer": answerInviteAction,
|
|
87
|
+
"invite.cancel": cancelInviteAction,
|
|
88
|
+
"host.claim": claimHostAction,
|
|
89
|
+
"host.release": releaseHostAction,
|
|
90
|
+
"code.create": createCodeAction,
|
|
91
|
+
"code.claim": claimCodeAction,
|
|
92
|
+
"code.list": listCodesAction,
|
|
93
|
+
"code.revoke": revokeCodeAction,
|
|
94
|
+
},
|
|
95
|
+
routes: {
|
|
96
|
+
"/orgs": orgsRoute,
|
|
97
|
+
"/orgs/enter": enterOrgRoute,
|
|
98
|
+
"/orgs/invites/answer": answerInviteRoute,
|
|
99
|
+
// Out of every org, in place of identity's own.
|
|
100
|
+
"/signout": signOutRoute,
|
|
101
|
+
"/console/orgs": consoleOrgsRoute,
|
|
102
|
+
"/console/orgs/:org": operateRoute,
|
|
103
|
+
"/console/orgs/:org/:what": operateRoute,
|
|
104
|
+
"/console/codes": codesRoute,
|
|
105
|
+
"/console/codes/revoke": revokeCodeRoute,
|
|
106
|
+
[RESOLVE]: resolveRoute,
|
|
107
|
+
[RESOLVE_BEFORE]: resolveRoute,
|
|
108
|
+
"/o/:org": addressedRoute,
|
|
109
|
+
"/o/:org/*": addressedRoute,
|
|
110
|
+
"/*": currentRoute,
|
|
111
|
+
// Every host but the app's own (`hosts`): those orgs claimed.
|
|
112
|
+
"*://*:*/*": claimedRoute,
|
|
113
|
+
},
|
|
114
|
+
// Its session is identity's, in today's cookie: `dir` (`__Host-dir` wherever it's Secure).
|
|
115
|
+
resources: { cookies: { names: { session: "dir" } } },
|
|
116
|
+
});
|
|
117
|
+
/**
|
|
118
|
+
* The directory plugin, and what each org's runtime gets of it:
|
|
119
|
+
* `directory.member(dir, org)` (see shared/member.ts), with the org as
|
|
120
|
+
* `org.info` says it.
|
|
121
|
+
*/
|
|
122
|
+
export const directory = Object.assign(plugin, { member });
|
|
123
|
+
export default directory;
|
package/package.json
CHANGED
|
@@ -1,7 +1,67 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pairz/directory",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.0-rc.81",
|
|
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
|
-
"
|
|
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.81",
|
|
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;
|