permdock 0.0.0 → 0.1.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 +268 -1
- package/dist/a2a/index.d.ts +178 -0
- package/dist/a2a/index.js +271 -0
- package/dist/ai-sdk/index.d.ts +74 -0
- package/dist/ai-sdk/index.js +137 -0
- package/dist/approval-required-TzNB9oQA.js +6 -0
- package/dist/approvals/index.d.ts +3 -0
- package/dist/approvals/index.js +4 -0
- package/dist/approvals-DaxY-Bdg.js +218 -0
- package/dist/approvers-aH0PJkmf.js +20 -0
- package/dist/arazzo-CTeVuXr5.js +70 -0
- package/dist/arazzo-aoTkqYsJ.js +54 -0
- package/dist/authzen/index.d.ts +48 -0
- package/dist/authzen/index.js +336 -0
- package/dist/better-auth/index.d.ts +92 -0
- package/dist/better-auth/index.js +324 -0
- package/dist/budget-JqcRqyhK.d.ts +11 -0
- package/dist/budget-NbEtbJC_.js +11 -0
- package/dist/capability-B68OFnZx.js +171 -0
- package/dist/capability-BDG_nkxt.d.ts +99 -0
- package/dist/catalog/index.d.ts +12 -0
- package/dist/catalog/index.js +2 -0
- package/dist/catalog-B0E6bggc.js +48 -0
- package/dist/catalog-H-vFGwWK.js +55 -0
- package/dist/catalog-doc-BSo_Q_-6.js +298 -0
- package/dist/catalog-idsHc0vo.js +2 -0
- package/dist/catalog-path-CnI0XTFK.js +12 -0
- package/dist/claude-agent/index.d.ts +81 -0
- package/dist/claude-agent/index.js +83 -0
- package/dist/clerk/index.d.ts +56 -0
- package/dist/clerk/index.js +280 -0
- package/dist/cli/bin.d.ts +1 -0
- package/dist/cli/bin.js +20 -0
- package/dist/cli/index.d.ts +46 -0
- package/dist/cli/index.js +5 -0
- package/dist/cloud/index.d.ts +91 -0
- package/dist/cloud/index.js +390 -0
- package/dist/cloud-BNQTrmrr.js +50 -0
- package/dist/cloud-Cuxr6Czw.js +117 -0
- package/dist/collect-B7_TIfmg.js +49 -0
- package/dist/collect-O-tOtbnk.js +350 -0
- package/dist/collect-fRPAQIWb.js +2 -0
- package/dist/commands-BMh_Etm2.js +93 -0
- package/dist/compact-y6vfu2_f.js +19 -0
- package/dist/compare-pfyVnBjE.js +12 -0
- package/dist/compile-CQbvyIBr.d.ts +30 -0
- package/dist/compile-D22iwvuV.js +558 -0
- package/dist/config-BPYmjTOp.js +26 -0
- package/dist/connection-JvqwHODC.js +194 -0
- package/dist/context-CKEAabd7.js +73 -0
- package/dist/context-gtAwAILx.js +6 -0
- package/dist/convex/index.d.ts +40 -0
- package/dist/convex/index.js +55 -0
- package/dist/create-BKF3dgFk.d.ts +162 -0
- package/dist/create-CSkhDU9T.js +222 -0
- package/dist/credential-B_rkUNlY.js +326 -0
- package/dist/credentials-BgRX3WEg.js +268 -0
- package/dist/describe-Bt1YD5uS.js +99 -0
- package/dist/describe-DernyItf.d.ts +37 -0
- package/dist/diff-BUzf5Poi.js +48 -0
- package/dist/diff-x5Il8LVa.js +418 -0
- package/dist/digest-B3kc_PgQ.d.ts +19 -0
- package/dist/digest-BI-6aa6d.js +27 -0
- package/dist/doctor-BGle8Gqi.js +1314 -0
- package/dist/doctor-Bqo6FwUa.js +53 -0
- package/dist/drizzle/index.d.ts +72 -0
- package/dist/drizzle/index.js +160 -0
- package/dist/duration-xK2jGFVc.js +25 -0
- package/dist/elysia/index.d.ts +71 -0
- package/dist/elysia/index.js +103 -0
- package/dist/errors-DSMnAVNa.js +43 -0
- package/dist/errors-DbZ1YOnb.d.ts +138 -0
- package/dist/errors-Iy71s7Oj.js +177 -0
- package/dist/errors-m3u9TmDu.js +27 -0
- package/dist/evaluations-DsAU9ppl.js +479 -0
- package/dist/eve/index.d.ts +95 -0
- package/dist/eve/index.js +181 -0
- package/dist/express/index.d.ts +46 -0
- package/dist/express/index.js +108 -0
- package/dist/fastify/index.d.ts +56 -0
- package/dist/fastify/index.js +141 -0
- package/dist/files-B_wAGYmt.js +121 -0
- package/dist/fixtures-Cvaw0gDG.js +64 -0
- package/dist/freeze-y1_jQL4v.js +31 -0
- package/dist/from-snapshot-BMGnhmgv.js +552 -0
- package/dist/generate-CH7ThJ14.js +173 -0
- package/dist/grantee-Bv04_Vzf.js +521 -0
- package/dist/headers-B5RRv3Xm.js +6 -0
- package/dist/headers-C8SHQccD.d.ts +6 -0
- package/dist/helpers-DnSOrhB9.js +682 -0
- package/dist/hono/index.d.ts +70 -0
- package/dist/hono/index.js +131 -0
- package/dist/hosted-BwKQ1BTA.js +265 -0
- package/dist/http-DPuDaChb.d.ts +13 -0
- package/dist/http-GgVApX1k.js +111 -0
- package/dist/index-CltcQ4Bf.d.ts +138 -0
- package/dist/index-LF_hS-yn.d.ts +177 -0
- package/dist/index-fG6NSXlc.d.ts +9 -0
- package/dist/index-xIxJLwOQ.d.ts +415 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +21 -0
- package/dist/jwt/index.d.ts +87 -0
- package/dist/jwt/index.js +571 -0
- package/dist/kernel-YOGCWNLf.js +211 -0
- package/dist/kysely/index.d.ts +77 -0
- package/dist/kysely/index.js +129 -0
- package/dist/load-BZ24CpZP.js +69 -0
- package/dist/load-QOOm1z70.js +2 -0
- package/dist/load-jose-BL6LH4bL.js +11 -0
- package/dist/lru-8q4WZjBV.js +28 -0
- package/dist/manifest-DDQbC6K0.d.ts +118 -0
- package/dist/map-DowSO96j.js +158 -0
- package/dist/map-claims-B_6I1Rn-.js +360 -0
- package/dist/map-error-RJ3ZsUyA.js +16 -0
- package/dist/markers-B0hYLvMD.js +60 -0
- package/dist/may-use-CnFEjVEp.js +37 -0
- package/dist/mcp/index.d.ts +127 -0
- package/dist/mcp/index.js +563 -0
- package/dist/nest/index.d.ts +80 -0
- package/dist/nest/index.js +270 -0
- package/dist/next/client.d.ts +24 -0
- package/dist/next/client.js +31 -0
- package/dist/next/index.d.ts +110 -0
- package/dist/next/index.js +195 -0
- package/dist/next/plugin.d.ts +14 -0
- package/dist/next/plugin.js +2 -0
- package/dist/node/index.d.ts +43 -0
- package/dist/node/index.js +66 -0
- package/dist/openai/index.d.ts +71 -0
- package/dist/openai/index.js +105 -0
- package/dist/openapi/index.d.ts +93 -0
- package/dist/openapi/index.js +3 -0
- package/dist/openapi-CwePaF7C.js +164 -0
- package/dist/openapi-DWD0Uc_4.js +250 -0
- package/dist/openapi-DcqM8nU7.js +306 -0
- package/dist/openapi-import-BWRUNNeW.js +5959 -0
- package/dist/openapi-schema-D8j_T9tO.js +6902 -0
- package/dist/orpc/index.d.ts +64 -0
- package/dist/orpc/index.js +188 -0
- package/dist/otel/index.d.ts +13 -0
- package/dist/otel/index.js +202 -0
- package/dist/package-root-zGkxO3oN.js +30 -0
- package/dist/parse-DPfIvFMU.js +135 -0
- package/dist/pdp/index.d.ts +22 -0
- package/dist/pdp/index.js +795 -0
- package/dist/peer-BOr_kJE1.js +31 -0
- package/dist/permdock-yoZ7EjxX.js +2956 -0
- package/dist/permissions-B4apnahQ.d.ts +185 -0
- package/dist/permissions-B8vCg_bI.d.ts +52 -0
- package/dist/permissions-CofRqesP.js +142 -0
- package/dist/permissions-DC7GROPA.js +600 -0
- package/dist/pg-4GJWDUxG.js +953 -0
- package/dist/pins-CqE1jZuF.js +12 -0
- package/dist/plugin-4gr7IxFJ.js +65 -0
- package/dist/policy-ANp36PnI.js +971 -0
- package/dist/policy-CInmNGkM.d.ts +1959 -0
- package/dist/policy-Cq2fB8Q5.d.ts +20 -0
- package/dist/prisma/index.d.ts +135 -0
- package/dist/prisma/index.js +430 -0
- package/dist/problem-Cgp9-KZA.js +226 -0
- package/dist/prompt-CXYhLfsS.js +32 -0
- package/dist/protected-B4K3BKoX.js +138 -0
- package/dist/protected-BuPAycJT.d.ts +26 -0
- package/dist/protected-wY7nXhY9.d.ts +23 -0
- package/dist/provider-_wx46HpB.js +48 -0
- package/dist/provider-wTAUda2v.d.ts +6 -0
- package/dist/react/index.d.ts +6 -0
- package/dist/react/index.js +6 -0
- package/dist/react/provider-client.d.ts +2 -0
- package/dist/react/provider-client.js +3 -0
- package/dist/react-native/index.d.ts +42 -0
- package/dist/react-native/index.js +174 -0
- package/dist/refs-ChLSxbST.js +90 -0
- package/dist/relations-r4soIFZB.js +426 -0
- package/dist/revocations-Cy06JNx2.d.ts +21 -0
- package/dist/rls-BOFU3chG.js +233 -0
- package/dist/rls-CJVja9Ww.js +2119 -0
- package/dist/rls-graph-DxQ39PJj.js +371 -0
- package/dist/rls-helpers-BxRuif0l.js +1346 -0
- package/dist/rls-import-CXV6LBlS.js +942 -0
- package/dist/rls-migrate-DrFPbf8p.js +366 -0
- package/dist/row-check-BajTgQZ-.d.ts +43 -0
- package/dist/run-CJ6UvS3a.js +155 -0
- package/dist/runtime-DP9ttFh1.js +27 -0
- package/dist/saas-BRrZzJkM.js +1193 -0
- package/dist/schema-P8yoma__.js +296 -0
- package/dist/scim/index.d.ts +2 -0
- package/dist/scim/index.js +2 -0
- package/dist/scim-9NFa0XVZ.js +1445 -0
- package/dist/scopes-cKVp_WTw.js +212 -0
- package/dist/server/index.d.ts +123 -0
- package/dist/server/index.js +8 -0
- package/dist/sha256-BO0swRXL.js +150 -0
- package/dist/sink-Bd9PSyfq.js +141 -0
- package/dist/sink-Cfr9-7YC.d.ts +104 -0
- package/dist/skills-C_lpV4Jx.js +50 -0
- package/dist/skills-Dx3QLnMY.js +110 -0
- package/dist/snapshot-DE8dE_hz.js +1051 -0
- package/dist/solid/index.d.ts +63 -0
- package/dist/solid/index.js +197 -0
- package/dist/source-DoBBYJi2.js +6 -0
- package/dist/sources-DOpW5Ila.d.ts +347 -0
- package/dist/sources-DVHM3Mwq.js +284 -0
- package/dist/sql-Bll1d7y0.js +22 -0
- package/dist/src-CTNT-PBW.js +430 -0
- package/dist/ssf/index.d.ts +3 -0
- package/dist/ssf/index.js +622 -0
- package/dist/store-Bq90395i.d.ts +27 -0
- package/dist/store-C6hFW6ta.js +508 -0
- package/dist/stores-CkG2HrSg.js +140 -0
- package/dist/stores-CvOnu_2T.d.ts +41 -0
- package/dist/stream-BhMfZOwr.d.ts +12 -0
- package/dist/stream-Q_xlB6Ko.js +52 -0
- package/dist/style-CTm1AXDT.js +22 -0
- package/dist/subject-C6dLxqHU.js +24 -0
- package/dist/subject-settings-xt7V845g.js +82 -0
- package/dist/supabase/index.d.ts +67 -0
- package/dist/supabase/index.js +4 -0
- package/dist/supabase/middleware.d.ts +77 -0
- package/dist/supabase/middleware.js +68 -0
- package/dist/supabase-D8UlBA7Z.js +83 -0
- package/dist/supabase-DTxGtYdi.js +796 -0
- package/dist/supabase-hook-DW-xP4hU.js +2 -0
- package/dist/supabase-hook-D_OqGb_V.js +1528 -0
- package/dist/svelte/Protected.svelte +34 -0
- package/dist/svelte/index.d.ts +10 -0
- package/dist/svelte/index.js +53 -0
- package/dist/svelte/runtime.d.ts +6 -0
- package/dist/svelte/runtime.js +3 -0
- package/dist/svelte/source.d.ts +10 -0
- package/dist/svelte/source.js +8 -0
- package/dist/terminal/index.d.ts +171 -0
- package/dist/terminal/index.js +821 -0
- package/dist/testing/index.d.ts +656 -0
- package/dist/testing/index.js +3208 -0
- package/dist/testing/saas/index.d.ts +194 -0
- package/dist/testing/saas/index.js +3 -0
- package/dist/testing/saas/permissions.d.ts +2 -0
- package/dist/testing/saas/permissions.js +2 -0
- package/dist/text-diff-BdkkYSbi.js +15 -0
- package/dist/thenable-okc2xDsj.js +10 -0
- package/dist/timeout-D51niuQP.js +8 -0
- package/dist/trpc/index.d.ts +80 -0
- package/dist/trpc/index.js +205 -0
- package/dist/types-B8w5PFtS.d.ts +141 -0
- package/dist/types-B9dmiiab.d.ts +66 -0
- package/dist/types-BBK-exvJ.d.ts +177 -0
- package/dist/types-BvBk1wgn.d.ts +118 -0
- package/dist/types-CxquUByI.d.ts +9 -0
- package/dist/types-D6Z6-rKJ.d.ts +312 -0
- package/dist/types-DbWdEfcm.d.ts +87 -0
- package/dist/types-bva3i4Gf.d.ts +98 -0
- package/dist/types-i4BAOvdb.d.ts +97 -0
- package/dist/unplugin/index.d.ts +7 -0
- package/dist/unplugin/index.js +30 -0
- package/dist/usage-1ozMubLY.js +42 -0
- package/dist/usage-CUnK6Ou9.js +530 -0
- package/dist/usage-PyEor6GA.js +2 -0
- package/dist/validity-D0uRmJKJ.js +224 -0
- package/dist/verifier-B90agnhl.js +461 -0
- package/dist/version-CnSh33Fj.js +16 -0
- package/dist/vocabulary-Dk0fs-Jk.d.ts +56 -0
- package/dist/vue/index.d.ts +57 -0
- package/dist/vue/index.js +203 -0
- package/dist/webmcp/index.d.ts +75 -0
- package/dist/webmcp/index.js +313 -0
- package/package.json +423 -4
- package/rulesets/permdock.yaml +29 -0
- package/schemas/catalog-v1.json +507 -0
- package/schemas/openapi/oas-3.1.json +1298 -0
- package/schemas/openapi/oas-3.2.json +1516 -0
- package/schemas/openapi/overlay-1.1.json +79 -0
- package/schemas/supabase-claims-v1.json +139 -0
- package/schemas/supabase-manifest-v1.json +217 -0
- package/skills/permdock/SKILL.md +66 -0
- package/skills/permdock-agents/SKILL.md +77 -0
- package/skills/permdock-agents/references/runtimes.md +211 -0
- package/skills/permdock-approvals/SKILL.md +80 -0
- package/skills/permdock-approvals/references/stores-and-resume.md +83 -0
- package/skills/permdock-audit/SKILL.md +67 -0
- package/skills/permdock-credentials/SKILL.md +55 -0
- package/skills/permdock-credentials/references/tokens-keys-links.md +127 -0
- package/skills/permdock-data/SKILL.md +57 -0
- package/skills/permdock-data/references/queries-and-rls.md +54 -0
- package/skills/permdock-data/references/relationships.md +65 -0
- package/skills/permdock-tenancy/SKILL.md +77 -0
- package/skills/permdock-tenancy/references/ownership-and-custom-roles.md +83 -0
- package/skills/permdock-wire/SKILL.md +116 -0
- package/skills/permdock-wire/references/adapters.md +480 -0
- package/skills/permdock-wire/references/policy-options.md +43 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
|
+
//#region src/core/permissions.d.ts
|
|
3
|
+
declare const RESOURCE_BRAND: unique symbol;
|
|
4
|
+
/** `definePermissions` options. */
|
|
5
|
+
type DefinePermissionsOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* Keys a permission used to have, mapped to its current key. Old keys are
|
|
8
|
+
* accepted wherever a key arrives as a string (stored custom roles, OAuth
|
|
9
|
+
* scopes, AuthZEN actions, hosted grants, `findPermission`) and resolve to
|
|
10
|
+
* the current leaf; code, decisions and audit only ever see the current key.
|
|
11
|
+
*/
|
|
12
|
+
readonly renamed?: Readonly<Record<string, string>>;
|
|
13
|
+
};
|
|
14
|
+
type ActionMeta = {
|
|
15
|
+
readonly title?: string;
|
|
16
|
+
readonly description?: string;
|
|
17
|
+
readonly tags?: readonly string[];
|
|
18
|
+
readonly readOnly?: boolean;
|
|
19
|
+
/** The action may destroy or overwrite data; only meaningful when not `readOnly`. */
|
|
20
|
+
readonly destructive?: boolean;
|
|
21
|
+
/** Repeating the action with the same input has no further effect. */
|
|
22
|
+
readonly idempotent?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* On a role, or on a permission the subject is granted: whoever holds it may
|
|
25
|
+
* assign the whole custom-role ceiling, not only what they hold themselves.
|
|
26
|
+
*/
|
|
27
|
+
readonly manageRoles?: boolean;
|
|
28
|
+
/** Set by a generator (`permdock openapi import`) to the operation an action was inferred from. */
|
|
29
|
+
readonly inferredFrom?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Data the application owns, such as a risk level or an undo window. Plain
|
|
32
|
+
* JSON; PermDock carries it on the leaf, the catalog and snapshots and
|
|
33
|
+
* never reads it.
|
|
34
|
+
*/
|
|
35
|
+
readonly x?: Readonly<Record<string, MetaValue>>;
|
|
36
|
+
};
|
|
37
|
+
/** A JSON value in `ActionMeta.x`. */
|
|
38
|
+
type MetaValue = string | number | boolean | null | readonly MetaValue[] | {
|
|
39
|
+
readonly [key: string]: MetaValue;
|
|
40
|
+
};
|
|
41
|
+
type PermissionKind = "instance" | "collection";
|
|
42
|
+
type Permission<K extends string = string, T = unknown, Kind extends PermissionKind = PermissionKind> = {
|
|
43
|
+
readonly key: K;
|
|
44
|
+
readonly scope: string;
|
|
45
|
+
readonly resource: string;
|
|
46
|
+
readonly action: string;
|
|
47
|
+
readonly meta: ActionMeta;
|
|
48
|
+
readonly kind: Kind;
|
|
49
|
+
} & ([T] extends [never] ? unknown : unknown);
|
|
50
|
+
type ResourceParent = {
|
|
51
|
+
readonly field: string;
|
|
52
|
+
readonly resource: string;
|
|
53
|
+
};
|
|
54
|
+
/** Relations on the same resource whose holders also hold this one. */
|
|
55
|
+
type RelationIncludes = {
|
|
56
|
+
readonly includes?: readonly string[];
|
|
57
|
+
};
|
|
58
|
+
/** The row's `field` holds the principal id (or, with `memberOf`, a scope id). */
|
|
59
|
+
type FieldRelation = RelationIncludes & {
|
|
60
|
+
readonly field: string;
|
|
61
|
+
/** A declared scope name (or the `tenant` / `team` alias): the field holds that scope's id. */
|
|
62
|
+
readonly memberOf?: string;
|
|
63
|
+
};
|
|
64
|
+
/** Literal values an edge row's columns must hold, so one table backs several relations. */
|
|
65
|
+
type EdgeMatch = Readonly<Record<string, string | number | boolean>>;
|
|
66
|
+
/**
|
|
67
|
+
* Edge rows that name a group instead of a principal: `column` holds the
|
|
68
|
+
* resource name, `subject` the group's id, and the row holds for whoever
|
|
69
|
+
* holds `resources[<name>]` on that group. A null `column` (or `direct`)
|
|
70
|
+
* names a principal; any other value matches nothing.
|
|
71
|
+
*/
|
|
72
|
+
type EdgeGroups = {
|
|
73
|
+
readonly column: string;
|
|
74
|
+
readonly resources: Readonly<Record<string, string>>;
|
|
75
|
+
/** The `column` value of a row naming a principal, besides `null`. */
|
|
76
|
+
readonly direct?: string;
|
|
77
|
+
};
|
|
78
|
+
/** One row per holder in an edge table: `object` holds the resource id, `subject` the principal id. */
|
|
79
|
+
type EdgeRelation = RelationIncludes & {
|
|
80
|
+
readonly edge: string;
|
|
81
|
+
/** Default `<resource>_id`. */
|
|
82
|
+
readonly object?: string;
|
|
83
|
+
/** Default `user_id`. */
|
|
84
|
+
readonly subject?: string;
|
|
85
|
+
/** A timestamp column; an edge whose value has passed does not match. */
|
|
86
|
+
readonly expiresAt?: string;
|
|
87
|
+
readonly match?: EdgeMatch;
|
|
88
|
+
readonly groups?: EdgeGroups;
|
|
89
|
+
};
|
|
90
|
+
/** On a principal resource: the row's `principal` column holds the principal who holds the relation over it. */
|
|
91
|
+
type PrincipalRelation = RelationIncludes & {
|
|
92
|
+
readonly principal: string;
|
|
93
|
+
/** Timestamp columns bounding when the relation holds; `null` leaves that side open. */
|
|
94
|
+
readonly period?: {
|
|
95
|
+
readonly startsAt?: string;
|
|
96
|
+
readonly expiresAt?: string;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
/** Held only through the relations it includes. */
|
|
100
|
+
type ComputedRelation = {
|
|
101
|
+
readonly includes: readonly string[];
|
|
102
|
+
};
|
|
103
|
+
type ResourceRelation = FieldRelation | EdgeRelation | PrincipalRelation | ComputedRelation;
|
|
104
|
+
type ResourceRelationInput = string | ResourceRelation;
|
|
105
|
+
/** A to-one link from a row to another resource's instance, walked by `through: [<link>]`. */
|
|
106
|
+
type ResourceLink = {
|
|
107
|
+
readonly field: string;
|
|
108
|
+
readonly resource: string;
|
|
109
|
+
};
|
|
110
|
+
type ActionList = readonly string[] | Record<string, ActionMeta>;
|
|
111
|
+
type ResourceOptions<A extends ActionList | undefined = ActionList | undefined, C extends ActionList | undefined = ActionList | undefined> = {
|
|
112
|
+
/**
|
|
113
|
+
* The resource name leaves, tables, relations and AuthZEN types use; the
|
|
114
|
+
* last path segment when absent. Names are unique across a tree.
|
|
115
|
+
*/
|
|
116
|
+
readonly name?: string;
|
|
117
|
+
readonly id?: string;
|
|
118
|
+
readonly actions?: A;
|
|
119
|
+
readonly collection?: C;
|
|
120
|
+
readonly parent?: ResourceParent;
|
|
121
|
+
readonly links?: Readonly<Record<string, ResourceLink>>;
|
|
122
|
+
readonly relations?: Readonly<Record<string, ResourceRelationInput>>;
|
|
123
|
+
/**
|
|
124
|
+
* The row field that changes whenever the row does (`updatedAt`, a revision
|
|
125
|
+
* counter). An `approval: { staleOn: 'resource-change' }` binds to its value.
|
|
126
|
+
*/
|
|
127
|
+
readonly version?: string;
|
|
128
|
+
/**
|
|
129
|
+
* A boolean column: a row where it is `true` is reached only by grants on
|
|
130
|
+
* itself, never by relations held on its ancestors.
|
|
131
|
+
*/
|
|
132
|
+
readonly restricted?: string;
|
|
133
|
+
/**
|
|
134
|
+
* `'hide'`: a denied check on a loaded row answers as if the row did not
|
|
135
|
+
* exist (HTTP `404`), so an id never confirms a row the caller cannot read.
|
|
136
|
+
*/
|
|
137
|
+
readonly disclosure?: "hide" | "reveal";
|
|
138
|
+
};
|
|
139
|
+
type ResourceInit<T = unknown, A extends ActionList | undefined = ActionList | undefined, C extends ActionList | undefined = ActionList | undefined> = {
|
|
140
|
+
readonly [RESOURCE_BRAND]: true;
|
|
141
|
+
readonly schema: StandardSchemaV1<unknown, T> | undefined;
|
|
142
|
+
readonly options: ResourceOptions<A, C>;
|
|
143
|
+
};
|
|
144
|
+
type ResourceNode<T = unknown> = {
|
|
145
|
+
readonly name: string;
|
|
146
|
+
readonly path: string;
|
|
147
|
+
readonly schema: StandardSchemaV1<unknown, T> | undefined;
|
|
148
|
+
readonly id: string;
|
|
149
|
+
readonly parent: ResourceParent | undefined;
|
|
150
|
+
readonly links: Readonly<Record<string, ResourceLink>>;
|
|
151
|
+
readonly relations: Readonly<Record<string, ResourceRelation>>;
|
|
152
|
+
readonly version: string | undefined;
|
|
153
|
+
readonly restricted: string | undefined;
|
|
154
|
+
readonly disclosure: "hide" | "reveal";
|
|
155
|
+
readonly instanceActions: ReadonlySet<string>;
|
|
156
|
+
readonly collectionActions: ReadonlySet<string>;
|
|
157
|
+
};
|
|
158
|
+
type PermissionTree = {
|
|
159
|
+
readonly [key: string]: PermissionTree | Permission;
|
|
160
|
+
};
|
|
161
|
+
type ActionNames<A extends ActionList | undefined> = A extends readonly string[] ? A[number] : A extends Record<string, ActionMeta> ? keyof A & string : never;
|
|
162
|
+
type LeavesFrom<Prefix extends string, Names extends string, T, Kind extends PermissionKind> = [Names] extends [never] ? object : { readonly [K in Names]: Permission<Prefix extends "" ? K : `${Prefix}.${K}`, T, Kind>; };
|
|
163
|
+
type InferResourceLeaves<R extends ResourceInit, Prefix extends string> = R extends ResourceInit<infer T, infer A, infer C> ? LeavesFrom<Prefix, ActionNames<A>, T, "instance"> & LeavesFrom<Prefix, ActionNames<C>, T, "collection"> : object;
|
|
164
|
+
type InferPermissionTree<Input, Prefix extends string = ""> = Input extends ResourceInit ? InferResourceLeaves<Input, Prefix> : Input extends Record<string, unknown> ? { readonly [K in keyof Input & string]: InferPermissionTree<Input[K], Prefix extends "" ? K : `${Prefix}.${K}`>; } : never;
|
|
165
|
+
/**
|
|
166
|
+
* The keys `permission` was renamed from, sorted. Empty for a leaf without
|
|
167
|
+
* renames and for one that crossed a serialisation boundary.
|
|
168
|
+
*/
|
|
169
|
+
declare function formerKeys(permission: object): readonly string[];
|
|
170
|
+
declare function resource<T, const A extends ActionList = readonly [], const C extends ActionList = readonly []>(schema: StandardSchemaV1<unknown, T>, options?: ResourceOptions<A, C>): ResourceInit<T, A, C>;
|
|
171
|
+
declare function resource<const A extends ActionList = readonly [], const C extends ActionList = readonly []>(options: ResourceOptions<A, C>): ResourceInit<unknown, A, C>;
|
|
172
|
+
declare function getResource(tree: PermissionTree, name: string): ResourceNode | undefined;
|
|
173
|
+
declare function definePermissions<const Input>(input: Input, options?: DefinePermissionsOptions): InferPermissionTree<Input>;
|
|
174
|
+
declare function listPermissions(tree: PermissionTree | Permission): readonly Permission[];
|
|
175
|
+
declare function findPermission(tree: PermissionTree, keyOrScope: string): Permission | undefined;
|
|
176
|
+
/**
|
|
177
|
+
* A permission leaf: string `key`, `scope`, `resource` and `action` plus an
|
|
178
|
+
* object `meta`. `kind` is non-enumerable and does not survive
|
|
179
|
+
* `JSON.stringify`, so a leaf that crossed a serialisation boundary passes
|
|
180
|
+
* without it; when present it must be `instance` or `collection`.
|
|
181
|
+
*/
|
|
182
|
+
declare function isPermission(value: unknown): value is Permission;
|
|
183
|
+
declare function mergePermissions<const Trees extends readonly PermissionTree[]>(...trees: Trees): PermissionTree;
|
|
184
|
+
//#endregion
|
|
185
|
+
export { findPermission as C, listPermissions as D, isPermission as E, mergePermissions as O, definePermissions as S, getResource as T, ResourceNode as _, EdgeGroups as a, ResourceRelation as b, FieldRelation as c, Permission as d, PermissionKind as f, ResourceLink as g, ResourceInit as h, DefinePermissionsOptions as i, resource as k, InferPermissionTree as l, PrincipalRelation as m, ActionMeta as n, EdgeMatch as o, PermissionTree as p, ComputedRelation as r, EdgeRelation as s, ActionList as t, MetaValue as u, ResourceOptions as v, formerKeys as w, ResourceRelationInput as x, ResourceParent as y };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { h as ResourceInit, l as InferPermissionTree } from "./permissions-B4apnahQ.js";
|
|
2
|
+
import { r as Role, t as Plan } from "./vocabulary-Dk0fs-Jk.js";
|
|
3
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
4
|
+
//#region src/testing/saas/permissions.d.ts
|
|
5
|
+
declare const SaasProjectSchema: StandardSchemaV1<SaasProject>;
|
|
6
|
+
declare const SaasDocSchema: StandardSchemaV1<SaasDoc>;
|
|
7
|
+
declare const SaasFolderSchema: StandardSchemaV1<SaasFolder>;
|
|
8
|
+
/** A folder in an org's tree; `restricted` keeps grants held on its ancestors out. */
|
|
9
|
+
type SaasFolder = {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly orgId: string;
|
|
12
|
+
readonly parentId: string | null;
|
|
13
|
+
readonly name: string;
|
|
14
|
+
readonly restricted: boolean;
|
|
15
|
+
};
|
|
16
|
+
type SaasProject = {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly orgId: string;
|
|
19
|
+
readonly ownerId: string;
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly archived: boolean;
|
|
22
|
+
};
|
|
23
|
+
type SaasDoc = {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly orgId: string;
|
|
26
|
+
readonly teamId: string | null;
|
|
27
|
+
readonly title: string;
|
|
28
|
+
readonly locked: boolean;
|
|
29
|
+
};
|
|
30
|
+
type CrudActions = readonly ["read", "update", "delete"];
|
|
31
|
+
type CrudCollection = readonly ["create", "list"];
|
|
32
|
+
type Collection<C extends readonly string[]> = ResourceInit<unknown, readonly [], C>;
|
|
33
|
+
type SaasDefinition = {
|
|
34
|
+
readonly project: ResourceInit<SaasProject, CrudActions, CrudCollection>;
|
|
35
|
+
readonly doc: ResourceInit<SaasDoc, CrudActions, CrudCollection>;
|
|
36
|
+
readonly folder: ResourceInit<SaasFolder, CrudActions, CrudCollection>;
|
|
37
|
+
readonly member: Collection<readonly ["list", "invite", "assignRole"]>;
|
|
38
|
+
readonly settings: Collection<readonly ["manage"]>;
|
|
39
|
+
readonly billing: Collection<readonly ["read", "manage"]>;
|
|
40
|
+
readonly analytics: Collection<readonly ["read"]>;
|
|
41
|
+
readonly audit: Collection<readonly ["read"]>;
|
|
42
|
+
readonly sso: Collection<readonly ["manage"]>;
|
|
43
|
+
readonly apiKey: Collection<readonly ["manage", "create", "revokeAll"]>;
|
|
44
|
+
readonly integration: Collection<readonly ["read"]>;
|
|
45
|
+
};
|
|
46
|
+
declare const saasPermissions: InferPermissionTree<SaasDefinition>;
|
|
47
|
+
type SaasRoleName = "owner" | "admin" | "member" | "viewer" | "lead" | "collaborator";
|
|
48
|
+
declare const saasRoles: { readonly [K in SaasRoleName]: Role<K>; };
|
|
49
|
+
declare const saasPlans: { readonly [K in "free" | "pro"]: Plan<K>; };
|
|
50
|
+
declare const saasTenantRoleNames: readonly ["owner", "admin", "member", "viewer"];
|
|
51
|
+
//#endregion
|
|
52
|
+
export { SaasProject as a, saasPlans as c, SaasFolderSchema as i, saasRoles as l, SaasDocSchema as n, SaasProjectSchema as o, SaasFolder as r, saasPermissions as s, SaasDoc as t, saasTenantRoleNames as u };
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { n as definePermissions, y as resource } from "./permissions-DC7GROPA.js";
|
|
2
|
+
import { s as crud } from "./src-CTNT-PBW.js";
|
|
3
|
+
import { v as definePlans, y as defineRoles } from "./grantee-Bv04_Vzf.js";
|
|
4
|
+
//#region src/testing/saas/schema.ts
|
|
5
|
+
function accepts(kind, value) {
|
|
6
|
+
switch (kind) {
|
|
7
|
+
case "string": return typeof value === "string";
|
|
8
|
+
case "boolean": return typeof value === "boolean";
|
|
9
|
+
case "nullable-string": return value === null || typeof value === "string";
|
|
10
|
+
default: return kind;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** A dependency-free Standard Schema for flat fixture rows. */
|
|
14
|
+
function rowSchema(shape) {
|
|
15
|
+
return { "~standard": {
|
|
16
|
+
version: 1,
|
|
17
|
+
vendor: "permdock-testing",
|
|
18
|
+
validate(value) {
|
|
19
|
+
if (typeof value !== "object" || value === null) return { issues: [{ message: "expected an object" }] };
|
|
20
|
+
const record = value;
|
|
21
|
+
const issues = [];
|
|
22
|
+
for (const [field, kind] of Object.entries(shape)) if (!accepts(kind, record[field])) issues.push({
|
|
23
|
+
message: `expected ${kind}`,
|
|
24
|
+
path: [field]
|
|
25
|
+
});
|
|
26
|
+
return issues.length > 0 ? { issues } : { value: record };
|
|
27
|
+
}
|
|
28
|
+
} };
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/testing/saas/permissions.ts
|
|
32
|
+
const SaasProjectSchema = rowSchema({
|
|
33
|
+
id: "string",
|
|
34
|
+
orgId: "string",
|
|
35
|
+
ownerId: "string",
|
|
36
|
+
name: "string",
|
|
37
|
+
archived: "boolean"
|
|
38
|
+
});
|
|
39
|
+
const SaasDocSchema = rowSchema({
|
|
40
|
+
id: "string",
|
|
41
|
+
orgId: "string",
|
|
42
|
+
teamId: "nullable-string",
|
|
43
|
+
title: "string",
|
|
44
|
+
locked: "boolean"
|
|
45
|
+
});
|
|
46
|
+
const SaasFolderSchema = rowSchema({
|
|
47
|
+
id: "string",
|
|
48
|
+
orgId: "string",
|
|
49
|
+
parentId: "nullable-string",
|
|
50
|
+
name: "string",
|
|
51
|
+
restricted: "boolean"
|
|
52
|
+
});
|
|
53
|
+
const saasPermissions = definePermissions({
|
|
54
|
+
project: resource(SaasProjectSchema, crud({ relations: { org: {
|
|
55
|
+
field: "orgId",
|
|
56
|
+
memberOf: "tenant"
|
|
57
|
+
} } })),
|
|
58
|
+
doc: resource(SaasDocSchema, crud({ relations: {
|
|
59
|
+
org: {
|
|
60
|
+
field: "orgId",
|
|
61
|
+
memberOf: "tenant"
|
|
62
|
+
},
|
|
63
|
+
team: {
|
|
64
|
+
field: "teamId",
|
|
65
|
+
memberOf: "team"
|
|
66
|
+
}
|
|
67
|
+
} })),
|
|
68
|
+
folder: resource(SaasFolderSchema, crud({
|
|
69
|
+
parent: {
|
|
70
|
+
field: "parentId",
|
|
71
|
+
resource: "folder"
|
|
72
|
+
},
|
|
73
|
+
restricted: "restricted",
|
|
74
|
+
relations: {
|
|
75
|
+
org: {
|
|
76
|
+
field: "orgId",
|
|
77
|
+
memberOf: "tenant"
|
|
78
|
+
},
|
|
79
|
+
viewer: {
|
|
80
|
+
edge: "folder_share",
|
|
81
|
+
object: "folder_id",
|
|
82
|
+
expiresAt: "expires_at"
|
|
83
|
+
},
|
|
84
|
+
editor: {
|
|
85
|
+
edge: "folder_editor",
|
|
86
|
+
object: "folder_id"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
})),
|
|
90
|
+
member: resource({ collection: [
|
|
91
|
+
"list",
|
|
92
|
+
"invite",
|
|
93
|
+
"assignRole"
|
|
94
|
+
] }),
|
|
95
|
+
settings: resource({ collection: ["manage"] }),
|
|
96
|
+
billing: resource({ collection: ["read", "manage"] }),
|
|
97
|
+
analytics: resource({ collection: ["read"] }),
|
|
98
|
+
audit: resource({ collection: ["read"] }),
|
|
99
|
+
sso: resource({ collection: ["manage"] }),
|
|
100
|
+
apiKey: resource({ collection: [
|
|
101
|
+
"manage",
|
|
102
|
+
"create",
|
|
103
|
+
"revokeAll"
|
|
104
|
+
] }),
|
|
105
|
+
integration: resource({ collection: ["read"] })
|
|
106
|
+
});
|
|
107
|
+
const saasRoles = defineRoles({
|
|
108
|
+
owner: {
|
|
109
|
+
on: "tenant",
|
|
110
|
+
assignable: true
|
|
111
|
+
},
|
|
112
|
+
admin: {
|
|
113
|
+
on: "tenant",
|
|
114
|
+
assignable: true
|
|
115
|
+
},
|
|
116
|
+
member: {
|
|
117
|
+
on: "tenant",
|
|
118
|
+
assignable: true
|
|
119
|
+
},
|
|
120
|
+
viewer: {
|
|
121
|
+
on: "tenant",
|
|
122
|
+
assignable: true
|
|
123
|
+
},
|
|
124
|
+
lead: {
|
|
125
|
+
on: "team",
|
|
126
|
+
assignable: true
|
|
127
|
+
},
|
|
128
|
+
/** Resource-scoped; `role(..., { on: saasPermissions.project })` in the policy. */
|
|
129
|
+
collaborator: { assignable: true }
|
|
130
|
+
});
|
|
131
|
+
const saasPlans = definePlans({
|
|
132
|
+
free: {},
|
|
133
|
+
pro: {}
|
|
134
|
+
});
|
|
135
|
+
const saasTenantRoleNames = [
|
|
136
|
+
"owner",
|
|
137
|
+
"admin",
|
|
138
|
+
"member",
|
|
139
|
+
"viewer"
|
|
140
|
+
];
|
|
141
|
+
//#endregion
|
|
142
|
+
export { saasPlans as a, rowSchema as c, saasPermissions as i, SaasFolderSchema as n, saasRoles as o, SaasProjectSchema as r, saasTenantRoleNames as s, SaasDocSchema as t };
|