gitoria
All repositories: gitoria
2.4 KB
// lib/orgs.hl — ORGANIZATIONS (ticket gitoria#34, GO34). An organization is a name that is its own address <org>.<domain>; its repos live at// <org>.<domain>/<repo> and look like a repo page on <repo>.<domain>. One hl:mpackdb table, storage/mpackdb/orgs.db:// pk @id index !slug, owner { slug, owner (users @id), priv (true = every repo of it is private, also new ones), created }// An organization's name and a repo's name share one namespace (both are subdomains): lib/repos.hl checks both. Who belongs to an// organization is the one member list of lib/members.hl. Statics only; no page code.import { MPackDB } from 'hl:mpackdb'import { now } from 'hl:time'import { storageDir, firstOf, slugOfHost } from './util.hl'static orgsTable = new MPackDB(file = storageDir + '/orgs.db', primaryKey = '@id', indexes = ['!slug', 'owner'])static orgBySlug = (slug) => {if (slug == null || hlTypeName(slug) != 'String' || slug == '') { return null }return firstOf(orgsTable.find('slug', slug))}static putOrg = (slug, owner, priv) => {id = orgsTable.put({ slug = slug owner = owner priv = priv created = now() })return id == null ? null : orgsTable.fetch(id)}static setOrgPriv = (o, priv) => {orgsTable.update(o.id, { id = o.id slug = o.slug owner = o.owner priv = priv created = o.created })after = orgsTable.fetch(o.id)return after != null && after.priv == priv}// every organization recordstatic allOrgs = () => {all = orgsTable.find(null, null)return all == null || all.length == null ? [] : all}// THE REPO NAME OF A REQUEST: `host` (no port) and `orepo` (the first path segment of an organization's address, '' elsewhere).// '' = the main address; `name` = a repo's own address; `org/name` = a repo inside an organization; '!x' = a path that names// no repo (a first segment on a host that is not an organization) — "No such repository".static slugOfRequest = (host, orepo) => {label = slugOfHost(host)if (orepo == null || orepo == '') { return label }if (label != '' && orgBySlug(label) != null) { return label + '/' + orepo }return '!'}// the first path segment of an organization's address (the repo inside it), '' on every other host or at the organization's rootstatic orepoOfPath = (host, path) => {label = slugOfHost(host)if (label == '' || path == null || orgBySlug(label) == null) { return '' }rest = path.startsWith('/') ? path.slice(1) : pathi = rest.indexOf('/')return i < 0 ? rest : rest.slice(0, i)}
Branches
- f1-broken-json
- f2-api-bugs
- gp-gate-ports
- heap-revert
- hl25-records
- ident-chooser-selector
- mainmain branch
- p51-public-pr-reads
- records-1112
- s25-no-session-on-login-error
- v59
- w52-person-approval
- w52b-approval-followup
- w52c-header-phone
- w53-pulls-speed-pr
- w54-repo-rename-pr
- w55-rename-org
- w56-owner-members
- w62-pr-close
- w63-force-push
- w64-org-slash
Latest commits
- 2f2959c5|||PR apps API: broken JSON body gives 400 invalid_json, not 500mre
- f7c6ca07Merge branch 'ident-chooser-selector' into mainGitoria
- 691abb8e|||PR tests: find ident identity choice without the removed .choose classmre
- 16a3530fMerge branch 'heap-revert' into mainGitoria
- 220a80e0|||PR Remove temporary /__heap route and heap helper; logmre
- 13f0c342Merge branch 'hl25-records' into mainGitoria
- a002ecb7|||PR records: HL25 report, heap helper, logmre
- 2492a55cTemporary keyed /__heap route for the live memory snapshotmre
- fefaedd2log: tracker PR-only, HL25 startedmre
- 21aa57calog: parkmre
- e9f950a8reports: G25c soakmre
- a7783686log: deploy 9f41ffcmre
- 9f41ffc1log: W30b mergedmre
- bef635c1Merge branch 'w30b'mre
- 15b996a5Org list: keyed rows by @id, newest first, concat instead of hand loopmre
- c4f6d9e3reports: G25c growth huntmre
- b88e39f1log: privacy cleanup donemre
- bfd7826ddocs: neutral example organisation namemre
- 01b71c2edocs: neutral wording in missions, reports and logmre
- 3eeea733log: 2026-11-09 PR flow plan and membersmre