@b1-road/types 0.1.0-alpha.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/LICENSE +21 -0
- package/README.md +56 -0
- package/dist/iam.cjs +19 -0
- package/dist/iam.cjs.map +1 -0
- package/dist/iam.d.cts +94 -0
- package/dist/iam.d.ts +94 -0
- package/dist/iam.js +1 -0
- package/dist/iam.js.map +1 -0
- package/dist/index.cjs +66 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +186 -0
- package/dist/index.d.ts +186 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/permissions-BSbomCrB.d.cts +50 -0
- package/dist/permissions-BSbomCrB.d.ts +50 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 B1 Produtos Digitais Ltda
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# @b1-road/types
|
|
2
|
+
|
|
3
|
+
Shared types and constants for every Road SDK — the **single source of truth**
|
|
4
|
+
for the Road wire contract. Entities, the permission algebra, input shapes,
|
|
5
|
+
hosted API URLs, and the API contract version live here; `@b1-road/react`,
|
|
6
|
+
`@b1-road/nestjs`, and every other binding re-export from this package and never
|
|
7
|
+
redefine.
|
|
8
|
+
|
|
9
|
+
> **Alpha.** Road is pre-1.0. This package is published under the `alpha`
|
|
10
|
+
> dist-tag and its surface may change between minor versions until the API
|
|
11
|
+
> graduates its contract from `alpha` to `v1`.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install @b1-road/types@alpha
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Ships dual ESM/CJS builds with type declarations. Zero runtime dependencies.
|
|
20
|
+
|
|
21
|
+
## What's inside
|
|
22
|
+
|
|
23
|
+
| Export | What it is |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| `ROAD_API_CONTRACT` | The API contract version (`"alpha"`). SDKs build their base path as `` `${host}/api/${ROAD_API_CONTRACT}` ``. |
|
|
26
|
+
| `ROAD_API_URLS` | Hosted Road API base URLs (`production`, `sandbox`). |
|
|
27
|
+
| Entities | The resource shapes returned on the wire (business units, members, roles, permissions, …). |
|
|
28
|
+
| Inputs | The request-body shapes the API accepts. |
|
|
29
|
+
| Permissions | The `action:subject` permission algebra and its constants. |
|
|
30
|
+
| `@b1-road/types/iam` | IAM control-plane types (scopes, assignments, authorization, sessions). |
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { ROAD_API_CONTRACT, ROAD_API_URLS } from "@b1-road/types";
|
|
34
|
+
|
|
35
|
+
const baseUrl = `${ROAD_API_URLS.production}/api/${ROAD_API_CONTRACT}`;
|
|
36
|
+
// → https://api.road.app/api/alpha
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Why a shared package
|
|
40
|
+
|
|
41
|
+
Every wire type, permission constant, and hosted URL has exactly one definition.
|
|
42
|
+
SDKs import them; they never re-declare. If a binding needs a shape this package
|
|
43
|
+
doesn't yet expose, it contributes the shape back here in the same change — so
|
|
44
|
+
the React, Nest, and Laravel definitions can never drift. This is the
|
|
45
|
+
load-bearing principle of the multi-SDK ecosystem.
|
|
46
|
+
|
|
47
|
+
## Versioning
|
|
48
|
+
|
|
49
|
+
`@b1-road/types` carries its own semantic version, independent of the Road API's
|
|
50
|
+
release cadence. It tracks the API on the **contract** axis: while
|
|
51
|
+
`ROAD_API_CONTRACT` is `"alpha"`, this package stays pre-stable `0.x`. The bump
|
|
52
|
+
to `1.0.0` happens when the API cuts its first stable contract (`v1`).
|
|
53
|
+
|
|
54
|
+
## License
|
|
55
|
+
|
|
56
|
+
MIT
|
package/dist/iam.cjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/iam.ts
|
|
17
|
+
var iam_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(iam_exports);
|
|
19
|
+
//# sourceMappingURL=iam.cjs.map
|
package/dist/iam.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iam.ts"],"sourcesContent":["/**\n * IAM control-plane wire types. These describe the shapes Road's IAM API\n * speaks: scopes, assignments, authorization checks, effective permissions,\n * token exchange, and sessions.\n *\n * They live behind a subpath (`@b1-road/types/iam`) so the React SDK — which\n * never needs the control-plane — doesn't pay for them in its tree-shaken\n * bundle. The Nest SDK imports from here directly.\n */\n\nimport type { RoadPermission } from \"./permissions\";\n\n/** Scope shape. Three flavors today; platforms may register more over time. */\nexport type ScopeType = \"system\" | \"business_unit\" | \"platform\";\n\n/** Subjects the IAM engine can authorize. `service` covers M2M; `api_key` is legacy. */\nexport type SubjectType = \"user\" | \"service\" | \"api_key\";\n\nexport interface Scope {\n id: string;\n type: ScopeType;\n externalId: string | null;\n parentScopeId: string | null;\n parentScope?: {\n id: string;\n type: ScopeType;\n externalId: string | null;\n } | null;\n metadata: Record<string, unknown>;\n createdAt: string;\n updatedAt?: string;\n}\n\nexport interface CreateScopeInput {\n type: ScopeType;\n externalId?: string | null;\n parentScopeId?: string | null;\n metadata?: Record<string, unknown>;\n}\n\nexport interface Assignment {\n id: string;\n subjectType: SubjectType;\n subjectId: string;\n roleId: string;\n scopeId: string;\n grantedBy: string;\n grantedAt: string;\n expiresAt: string | null;\n}\n\nexport interface CreateAssignmentInput {\n subjectType: SubjectType;\n subjectId: string;\n roleId: string;\n scopeId: string;\n expiresAt?: string | null;\n}\n\nexport interface AuthorizeInput {\n subjectType: SubjectType;\n subjectId: string;\n scopeId: string;\n /** Either a single permission string (`\"read:Member\"`) or the wildcard. */\n permission: RoadPermission | (string & {});\n}\n\nexport interface AuthorizeResult {\n allowed: boolean;\n reason: string;\n /** Scope chain that was walked during evaluation (target → ... → root). */\n evaluatedScopes: string[];\n}\n\nexport interface AuthorizeBatchInput {\n subjectType: SubjectType;\n subjectId: string;\n scopeId: string;\n permissions: Array<RoadPermission | (string & {})>;\n}\n\nexport interface AuthorizeBatchResult {\n results: Array<{ permission: string; allowed: boolean }>;\n}\n\nexport interface EffectivePermissionsResult {\n /** Expanded permissions; `manage:X` has been expanded into the CRUD set. */\n permissions: string[];\n}\n\nexport interface Session {\n id: string;\n deviceName: string;\n ipAddress: string | null;\n userAgent?: string;\n provider: string;\n lastUsedAt: string;\n createdAt: string;\n current: boolean;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/iam.d.cts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { e as RoadPermission } from './permissions-BSbomCrB.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* IAM control-plane wire types. These describe the shapes Road's IAM API
|
|
5
|
+
* speaks: scopes, assignments, authorization checks, effective permissions,
|
|
6
|
+
* token exchange, and sessions.
|
|
7
|
+
*
|
|
8
|
+
* They live behind a subpath (`@b1-road/types/iam`) so the React SDK — which
|
|
9
|
+
* never needs the control-plane — doesn't pay for them in its tree-shaken
|
|
10
|
+
* bundle. The Nest SDK imports from here directly.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** Scope shape. Three flavors today; platforms may register more over time. */
|
|
14
|
+
type ScopeType = "system" | "business_unit" | "platform";
|
|
15
|
+
/** Subjects the IAM engine can authorize. `service` covers M2M; `api_key` is legacy. */
|
|
16
|
+
type SubjectType = "user" | "service" | "api_key";
|
|
17
|
+
interface Scope {
|
|
18
|
+
id: string;
|
|
19
|
+
type: ScopeType;
|
|
20
|
+
externalId: string | null;
|
|
21
|
+
parentScopeId: string | null;
|
|
22
|
+
parentScope?: {
|
|
23
|
+
id: string;
|
|
24
|
+
type: ScopeType;
|
|
25
|
+
externalId: string | null;
|
|
26
|
+
} | null;
|
|
27
|
+
metadata: Record<string, unknown>;
|
|
28
|
+
createdAt: string;
|
|
29
|
+
updatedAt?: string;
|
|
30
|
+
}
|
|
31
|
+
interface CreateScopeInput {
|
|
32
|
+
type: ScopeType;
|
|
33
|
+
externalId?: string | null;
|
|
34
|
+
parentScopeId?: string | null;
|
|
35
|
+
metadata?: Record<string, unknown>;
|
|
36
|
+
}
|
|
37
|
+
interface Assignment {
|
|
38
|
+
id: string;
|
|
39
|
+
subjectType: SubjectType;
|
|
40
|
+
subjectId: string;
|
|
41
|
+
roleId: string;
|
|
42
|
+
scopeId: string;
|
|
43
|
+
grantedBy: string;
|
|
44
|
+
grantedAt: string;
|
|
45
|
+
expiresAt: string | null;
|
|
46
|
+
}
|
|
47
|
+
interface CreateAssignmentInput {
|
|
48
|
+
subjectType: SubjectType;
|
|
49
|
+
subjectId: string;
|
|
50
|
+
roleId: string;
|
|
51
|
+
scopeId: string;
|
|
52
|
+
expiresAt?: string | null;
|
|
53
|
+
}
|
|
54
|
+
interface AuthorizeInput {
|
|
55
|
+
subjectType: SubjectType;
|
|
56
|
+
subjectId: string;
|
|
57
|
+
scopeId: string;
|
|
58
|
+
/** Either a single permission string (`"read:Member"`) or the wildcard. */
|
|
59
|
+
permission: RoadPermission | (string & {});
|
|
60
|
+
}
|
|
61
|
+
interface AuthorizeResult {
|
|
62
|
+
allowed: boolean;
|
|
63
|
+
reason: string;
|
|
64
|
+
/** Scope chain that was walked during evaluation (target → ... → root). */
|
|
65
|
+
evaluatedScopes: string[];
|
|
66
|
+
}
|
|
67
|
+
interface AuthorizeBatchInput {
|
|
68
|
+
subjectType: SubjectType;
|
|
69
|
+
subjectId: string;
|
|
70
|
+
scopeId: string;
|
|
71
|
+
permissions: Array<RoadPermission | (string & {})>;
|
|
72
|
+
}
|
|
73
|
+
interface AuthorizeBatchResult {
|
|
74
|
+
results: Array<{
|
|
75
|
+
permission: string;
|
|
76
|
+
allowed: boolean;
|
|
77
|
+
}>;
|
|
78
|
+
}
|
|
79
|
+
interface EffectivePermissionsResult {
|
|
80
|
+
/** Expanded permissions; `manage:X` has been expanded into the CRUD set. */
|
|
81
|
+
permissions: string[];
|
|
82
|
+
}
|
|
83
|
+
interface Session {
|
|
84
|
+
id: string;
|
|
85
|
+
deviceName: string;
|
|
86
|
+
ipAddress: string | null;
|
|
87
|
+
userAgent?: string;
|
|
88
|
+
provider: string;
|
|
89
|
+
lastUsedAt: string;
|
|
90
|
+
createdAt: string;
|
|
91
|
+
current: boolean;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export type { Assignment, AuthorizeBatchInput, AuthorizeBatchResult, AuthorizeInput, AuthorizeResult, CreateAssignmentInput, CreateScopeInput, EffectivePermissionsResult, Scope, ScopeType, Session, SubjectType };
|
package/dist/iam.d.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { e as RoadPermission } from './permissions-BSbomCrB.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* IAM control-plane wire types. These describe the shapes Road's IAM API
|
|
5
|
+
* speaks: scopes, assignments, authorization checks, effective permissions,
|
|
6
|
+
* token exchange, and sessions.
|
|
7
|
+
*
|
|
8
|
+
* They live behind a subpath (`@b1-road/types/iam`) so the React SDK — which
|
|
9
|
+
* never needs the control-plane — doesn't pay for them in its tree-shaken
|
|
10
|
+
* bundle. The Nest SDK imports from here directly.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** Scope shape. Three flavors today; platforms may register more over time. */
|
|
14
|
+
type ScopeType = "system" | "business_unit" | "platform";
|
|
15
|
+
/** Subjects the IAM engine can authorize. `service` covers M2M; `api_key` is legacy. */
|
|
16
|
+
type SubjectType = "user" | "service" | "api_key";
|
|
17
|
+
interface Scope {
|
|
18
|
+
id: string;
|
|
19
|
+
type: ScopeType;
|
|
20
|
+
externalId: string | null;
|
|
21
|
+
parentScopeId: string | null;
|
|
22
|
+
parentScope?: {
|
|
23
|
+
id: string;
|
|
24
|
+
type: ScopeType;
|
|
25
|
+
externalId: string | null;
|
|
26
|
+
} | null;
|
|
27
|
+
metadata: Record<string, unknown>;
|
|
28
|
+
createdAt: string;
|
|
29
|
+
updatedAt?: string;
|
|
30
|
+
}
|
|
31
|
+
interface CreateScopeInput {
|
|
32
|
+
type: ScopeType;
|
|
33
|
+
externalId?: string | null;
|
|
34
|
+
parentScopeId?: string | null;
|
|
35
|
+
metadata?: Record<string, unknown>;
|
|
36
|
+
}
|
|
37
|
+
interface Assignment {
|
|
38
|
+
id: string;
|
|
39
|
+
subjectType: SubjectType;
|
|
40
|
+
subjectId: string;
|
|
41
|
+
roleId: string;
|
|
42
|
+
scopeId: string;
|
|
43
|
+
grantedBy: string;
|
|
44
|
+
grantedAt: string;
|
|
45
|
+
expiresAt: string | null;
|
|
46
|
+
}
|
|
47
|
+
interface CreateAssignmentInput {
|
|
48
|
+
subjectType: SubjectType;
|
|
49
|
+
subjectId: string;
|
|
50
|
+
roleId: string;
|
|
51
|
+
scopeId: string;
|
|
52
|
+
expiresAt?: string | null;
|
|
53
|
+
}
|
|
54
|
+
interface AuthorizeInput {
|
|
55
|
+
subjectType: SubjectType;
|
|
56
|
+
subjectId: string;
|
|
57
|
+
scopeId: string;
|
|
58
|
+
/** Either a single permission string (`"read:Member"`) or the wildcard. */
|
|
59
|
+
permission: RoadPermission | (string & {});
|
|
60
|
+
}
|
|
61
|
+
interface AuthorizeResult {
|
|
62
|
+
allowed: boolean;
|
|
63
|
+
reason: string;
|
|
64
|
+
/** Scope chain that was walked during evaluation (target → ... → root). */
|
|
65
|
+
evaluatedScopes: string[];
|
|
66
|
+
}
|
|
67
|
+
interface AuthorizeBatchInput {
|
|
68
|
+
subjectType: SubjectType;
|
|
69
|
+
subjectId: string;
|
|
70
|
+
scopeId: string;
|
|
71
|
+
permissions: Array<RoadPermission | (string & {})>;
|
|
72
|
+
}
|
|
73
|
+
interface AuthorizeBatchResult {
|
|
74
|
+
results: Array<{
|
|
75
|
+
permission: string;
|
|
76
|
+
allowed: boolean;
|
|
77
|
+
}>;
|
|
78
|
+
}
|
|
79
|
+
interface EffectivePermissionsResult {
|
|
80
|
+
/** Expanded permissions; `manage:X` has been expanded into the CRUD set. */
|
|
81
|
+
permissions: string[];
|
|
82
|
+
}
|
|
83
|
+
interface Session {
|
|
84
|
+
id: string;
|
|
85
|
+
deviceName: string;
|
|
86
|
+
ipAddress: string | null;
|
|
87
|
+
userAgent?: string;
|
|
88
|
+
provider: string;
|
|
89
|
+
lastUsedAt: string;
|
|
90
|
+
createdAt: string;
|
|
91
|
+
current: boolean;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export type { Assignment, AuthorizeBatchInput, AuthorizeBatchResult, AuthorizeInput, AuthorizeResult, CreateAssignmentInput, CreateScopeInput, EffectivePermissionsResult, Scope, ScopeType, Session, SubjectType };
|
package/dist/iam.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=iam.js.map
|
package/dist/iam.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
ROAD_API_CONTRACT: () => ROAD_API_CONTRACT,
|
|
24
|
+
ROAD_API_URLS: () => ROAD_API_URLS,
|
|
25
|
+
ROAD_CORE_ACTIONS: () => ROAD_CORE_ACTIONS,
|
|
26
|
+
ROAD_CORE_SUBJECTS: () => ROAD_CORE_SUBJECTS,
|
|
27
|
+
ROAD_WILDCARD_PERMISSION: () => ROAD_WILDCARD_PERMISSION
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(src_exports);
|
|
30
|
+
|
|
31
|
+
// src/api-contract.ts
|
|
32
|
+
var ROAD_API_CONTRACT = "alpha";
|
|
33
|
+
|
|
34
|
+
// src/api-urls.ts
|
|
35
|
+
var ROAD_API_URLS = {
|
|
36
|
+
production: "https://api.road.app",
|
|
37
|
+
sandbox: "https://api.road-sandbox.b1.app"
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// src/permissions.ts
|
|
41
|
+
var ROAD_CORE_ACTIONS = [
|
|
42
|
+
"create",
|
|
43
|
+
"read",
|
|
44
|
+
"update",
|
|
45
|
+
"delete",
|
|
46
|
+
"manage"
|
|
47
|
+
];
|
|
48
|
+
var ROAD_CORE_SUBJECTS = [
|
|
49
|
+
"BusinessUnit",
|
|
50
|
+
"BUDashboard",
|
|
51
|
+
"BUSettings",
|
|
52
|
+
"Member",
|
|
53
|
+
"Role",
|
|
54
|
+
"Permission",
|
|
55
|
+
"Invitation"
|
|
56
|
+
];
|
|
57
|
+
var ROAD_WILDCARD_PERMISSION = "*";
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {
|
|
60
|
+
ROAD_API_CONTRACT,
|
|
61
|
+
ROAD_API_URLS,
|
|
62
|
+
ROAD_CORE_ACTIONS,
|
|
63
|
+
ROAD_CORE_SUBJECTS,
|
|
64
|
+
ROAD_WILDCARD_PERMISSION
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/api-contract.ts","../src/api-urls.ts","../src/permissions.ts"],"sourcesContent":["export * from \"./api-contract\";\nexport * from \"./api-urls\";\nexport * from \"./entities\";\nexport * from \"./inputs\";\nexport * from \"./permissions\";\n","/**\n * The Road API **contract version** — the major boundary of the HTTP wire\n * surface. The Road API mounts every route under `/api/<contract>`, and every\n * SDK builds its base path as `${host}/api/${ROAD_API_CONTRACT}`.\n *\n * This is the single source of truth for that value. The Road API imports it\n * for its global prefix; the in-repo clients (admin, tester) and the published\n * SDKs read it from here. It is **not** environment configuration — it is\n * identical in every environment and changes only by a deliberate edit when the\n * wire contract makes a breaking change: `alpha` → `v1` → `v2`.\n *\n * Promoting this from `alpha` to `v1` is the trigger to take the SDKs to their\n * first stable `1.0.0`. See `docs/plans/14-sdk-publishing-and-versioning.md`.\n */\nexport const ROAD_API_CONTRACT = \"alpha\" as const;\n\nexport type RoadApiContract = typeof ROAD_API_CONTRACT;\n","/**\n * Road's hosted API base URLs. SDKs default to ROAD_API_URLS.production; the\n * sandbox URL is the deployed Road sandbox (override via the SDK's apiBaseUrl\n * config if you're running against a different environment, eg. local dev or\n * a private staging cluster).\n *\n * If the deployed sandbox hostname changes, update this constant — it's the\n * single source of truth every SDK reads from.\n */\nexport const ROAD_API_URLS = {\n production: \"https://api.road.app\",\n sandbox: \"https://api.road-sandbox.b1.app\",\n} as const;\n\nexport type RoadEnvironment = keyof typeof ROAD_API_URLS;\n","/**\n * Road IAM permission algebra. Permissions are `${action}:${subject}` strings;\n * the wildcard `\"*\"` short-circuits to true for every action in a scope.\n *\n * The widget catalog calls into actions and subjects Road ships by default\n * (the union types below). Platforms can declare their own actions and\n * subjects in their IAM catalog — those flow through useCan as plain strings,\n * still type-safe via `RoadPermission | (string & {})` in the React SDK.\n */\n\n/**\n * The CRUD verbs Road's IAM engine recognizes, plus `manage` which the\n * engine expands server-side into the full CRUD set for the same subject\n * (`manage:Member` ⇒ also `create|read|update|delete:Member` in the\n * effective-permissions response).\n *\n * Platforms can register their own actions (`approve`, `submit`, `list`, …)\n * — those flow through useCan as plain strings (the `(string & {})` part\n * of PermissionInput in the React SDK), still type-safe via that escape.\n */\nexport type RoadAction = \"create\" | \"read\" | \"update\" | \"delete\" | \"manage\";\n\n/**\n * Built-in subjects Road's own permissions cover. Mirrors the subjects\n * registered in the API's `Subjects` constant\n * (apps/api/src/modules/iam/authorization/constants/subjects.ts), limited\n * to the subjects user-facing widgets actually surface:\n *\n * - BusinessUnit: system-level — create new BUs\n * - BUDashboard: BU-level — read a BU's detail page\n * - BUSettings: BU-level — edit a BU's settings\n * - Member, Role, Permission, Invitation: BU-level CRUD\n *\n * Admin / platform-engineer subjects (System, Platform, AdminUser,\n * PlatformIdentity, …) are not exposed here — they belong to a future\n * developer-facing widget (and admin SDK), not the customer-facing toolkit.\n *\n * Platform-specific subjects (eg. A4L's `Agent`) are not enumerated —\n * platforms register them at runtime under their own scope, and useCan's\n * `(string & {})` accepts them without complaint.\n */\nexport type RoadCoreSubject =\n | \"BusinessUnit\"\n | \"BUDashboard\"\n | \"BUSettings\"\n | \"Member\"\n | \"Role\"\n | \"Permission\"\n | \"Invitation\";\n\n/** `${action}:${Subject}` for the core set, plus the wildcard. */\nexport type RoadPermission = `${RoadAction}:${RoadCoreSubject}` | \"*\";\n\n/** Runtime array of the core actions — handy for iteration or validation. */\nexport const ROAD_CORE_ACTIONS = [\n \"create\",\n \"read\",\n \"update\",\n \"delete\",\n \"manage\",\n] as const satisfies readonly RoadAction[];\n\n/** Runtime array of the core subjects — handy for iteration or validation. */\nexport const ROAD_CORE_SUBJECTS = [\n \"BusinessUnit\",\n \"BUDashboard\",\n \"BUSettings\",\n \"Member\",\n \"Role\",\n \"Permission\",\n \"Invitation\",\n] as const satisfies readonly RoadCoreSubject[];\n\n/** The wildcard permission string. Use this instead of literal \"*\" for grep-ability. */\nexport const ROAD_WILDCARD_PERMISSION = \"*\" as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACcO,IAAM,oBAAoB;;;ACL1B,IAAM,gBAAgB;AAAA,EAC3B,YAAY;AAAA,EACZ,SAAS;AACX;;;AC0CO,IAAM,oBAAoB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGO,IAAM,qBAAqB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGO,IAAM,2BAA2B;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
export { R as ROAD_CORE_ACTIONS, a as ROAD_CORE_SUBJECTS, b as ROAD_WILDCARD_PERMISSION, c as RoadAction, d as RoadCoreSubject, e as RoadPermission } from './permissions-BSbomCrB.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The Road API **contract version** — the major boundary of the HTTP wire
|
|
5
|
+
* surface. The Road API mounts every route under `/api/<contract>`, and every
|
|
6
|
+
* SDK builds its base path as `${host}/api/${ROAD_API_CONTRACT}`.
|
|
7
|
+
*
|
|
8
|
+
* This is the single source of truth for that value. The Road API imports it
|
|
9
|
+
* for its global prefix; the in-repo clients (admin, tester) and the published
|
|
10
|
+
* SDKs read it from here. It is **not** environment configuration — it is
|
|
11
|
+
* identical in every environment and changes only by a deliberate edit when the
|
|
12
|
+
* wire contract makes a breaking change: `alpha` → `v1` → `v2`.
|
|
13
|
+
*
|
|
14
|
+
* Promoting this from `alpha` to `v1` is the trigger to take the SDKs to their
|
|
15
|
+
* first stable `1.0.0`. See `docs/plans/14-sdk-publishing-and-versioning.md`.
|
|
16
|
+
*/
|
|
17
|
+
declare const ROAD_API_CONTRACT: "alpha";
|
|
18
|
+
type RoadApiContract = typeof ROAD_API_CONTRACT;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Road's hosted API base URLs. SDKs default to ROAD_API_URLS.production; the
|
|
22
|
+
* sandbox URL is the deployed Road sandbox (override via the SDK's apiBaseUrl
|
|
23
|
+
* config if you're running against a different environment, eg. local dev or
|
|
24
|
+
* a private staging cluster).
|
|
25
|
+
*
|
|
26
|
+
* If the deployed sandbox hostname changes, update this constant — it's the
|
|
27
|
+
* single source of truth every SDK reads from.
|
|
28
|
+
*/
|
|
29
|
+
declare const ROAD_API_URLS: {
|
|
30
|
+
readonly production: "https://api.road.app";
|
|
31
|
+
readonly sandbox: "https://api.road-sandbox.b1.app";
|
|
32
|
+
};
|
|
33
|
+
type RoadEnvironment = keyof typeof ROAD_API_URLS;
|
|
34
|
+
|
|
35
|
+
type BUStatus = "active" | "suspended" | "archived";
|
|
36
|
+
type MemberStatus = "active" | "suspended" | "pending";
|
|
37
|
+
interface CurrentUser {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
email: string;
|
|
41
|
+
avatarUrl?: string;
|
|
42
|
+
}
|
|
43
|
+
interface BusinessUnitSummary {
|
|
44
|
+
id: string;
|
|
45
|
+
name: string;
|
|
46
|
+
slug: string;
|
|
47
|
+
}
|
|
48
|
+
interface BusinessUnitDetail {
|
|
49
|
+
id: string;
|
|
50
|
+
name: string;
|
|
51
|
+
slug: string;
|
|
52
|
+
status: BUStatus;
|
|
53
|
+
memberCount: number;
|
|
54
|
+
memberLimit: number | null;
|
|
55
|
+
joinCode: string | null;
|
|
56
|
+
createdAt: string;
|
|
57
|
+
/**
|
|
58
|
+
* Road IAM scope ID for this BU. The HTTP client uses it to call the
|
|
59
|
+
* per-scope role/permission endpoints (/iam/authorization/scopes/:scopeId/…).
|
|
60
|
+
* Exposed because the SDK needs it for role wiring; integrators usually
|
|
61
|
+
* don't need to touch it.
|
|
62
|
+
*/
|
|
63
|
+
iamScopeId: string;
|
|
64
|
+
}
|
|
65
|
+
interface RoleRef {
|
|
66
|
+
id: string;
|
|
67
|
+
name: string;
|
|
68
|
+
}
|
|
69
|
+
interface Membership {
|
|
70
|
+
businessUnit: BusinessUnitSummary;
|
|
71
|
+
status: MemberStatus;
|
|
72
|
+
joinedAt: string;
|
|
73
|
+
roles: RoleRef[];
|
|
74
|
+
}
|
|
75
|
+
interface PendingInvitation {
|
|
76
|
+
id: string;
|
|
77
|
+
businessUnit: BusinessUnitSummary;
|
|
78
|
+
roleName: string;
|
|
79
|
+
expiresAt: string;
|
|
80
|
+
}
|
|
81
|
+
interface MyBusinessUnits {
|
|
82
|
+
memberships: Membership[];
|
|
83
|
+
pendingInvitations: PendingInvitation[];
|
|
84
|
+
}
|
|
85
|
+
interface Member {
|
|
86
|
+
id: string;
|
|
87
|
+
userId: string;
|
|
88
|
+
status: MemberStatus;
|
|
89
|
+
joinedAt: string;
|
|
90
|
+
name: string;
|
|
91
|
+
email: string;
|
|
92
|
+
roles: RoleRef[];
|
|
93
|
+
}
|
|
94
|
+
interface Invitation {
|
|
95
|
+
id: string;
|
|
96
|
+
email: string;
|
|
97
|
+
roleId: string;
|
|
98
|
+
roleName: string;
|
|
99
|
+
status: "pending" | "accepted" | "expired" | "cancelled";
|
|
100
|
+
invitedAt: string;
|
|
101
|
+
expiresAt: string;
|
|
102
|
+
}
|
|
103
|
+
interface Role {
|
|
104
|
+
id: string;
|
|
105
|
+
name: string;
|
|
106
|
+
description: string;
|
|
107
|
+
permissions: string[];
|
|
108
|
+
isSystem: boolean;
|
|
109
|
+
memberCount: number;
|
|
110
|
+
}
|
|
111
|
+
interface Permission {
|
|
112
|
+
id: string;
|
|
113
|
+
code: string;
|
|
114
|
+
name: string;
|
|
115
|
+
description: string;
|
|
116
|
+
/** Subject group (e.g. "Member", "Role", "BusinessUnit") used to group in the picker. */
|
|
117
|
+
category: string;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Effective permissions for the current user, keyed by business-unit ID.
|
|
121
|
+
* A value of `["*"]` (ROAD_WILDCARD_PERMISSION) grants every action in that BU.
|
|
122
|
+
*/
|
|
123
|
+
type MyPermissions = Record<string, string[]>;
|
|
124
|
+
/**
|
|
125
|
+
* Cursor-paginated list response. The API issues opaque base64-url cursors
|
|
126
|
+
* the client treats as opaque — no parsing or arithmetic on the SDK side.
|
|
127
|
+
* `cursor` is null when no further page exists; `hasMore` is the canonical
|
|
128
|
+
* "more rows after this page" signal, redundant with `cursor !== null`.
|
|
129
|
+
*/
|
|
130
|
+
interface PageInfo {
|
|
131
|
+
/** Opaque cursor for the next page. Null when this is the last page. */
|
|
132
|
+
cursor: string | null;
|
|
133
|
+
/** True iff there is at least one row past this page. */
|
|
134
|
+
hasMore: boolean;
|
|
135
|
+
/** Total count of rows matching the filter, across all pages. */
|
|
136
|
+
totalCount: number;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Generic paged response shape returned from listing endpoints with
|
|
140
|
+
* cursor pagination (members, roles, invitations). Convertible 1:1 to
|
|
141
|
+
* React Query's useInfiniteQuery `pageParam` flow via `pageInfo.cursor`.
|
|
142
|
+
*/
|
|
143
|
+
interface PaginatedList<T> {
|
|
144
|
+
items: T[];
|
|
145
|
+
pageInfo: PageInfo;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Input shape for any paginated list call. Both fields are optional —
|
|
149
|
+
* omitting both fetches the first page with the API's default page size
|
|
150
|
+
* (currently 20).
|
|
151
|
+
*/
|
|
152
|
+
interface PaginationInput {
|
|
153
|
+
/** Opaque cursor from a previous `pageInfo.cursor`. Omit for the first page. */
|
|
154
|
+
cursor?: string;
|
|
155
|
+
/** Page size. Default 20, max 100 (server-enforced). */
|
|
156
|
+
limit?: number;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
interface CreateBusinessUnitInput {
|
|
160
|
+
name: string;
|
|
161
|
+
slug?: string;
|
|
162
|
+
memberLimit?: number | null;
|
|
163
|
+
}
|
|
164
|
+
interface UpdateBusinessUnitInput {
|
|
165
|
+
name?: string;
|
|
166
|
+
slug?: string;
|
|
167
|
+
memberLimit?: number | null;
|
|
168
|
+
}
|
|
169
|
+
interface CreateRoleInput {
|
|
170
|
+
name: string;
|
|
171
|
+
description?: string;
|
|
172
|
+
permissions: string[];
|
|
173
|
+
/** Source role ID when "clone from existing"; informational only. */
|
|
174
|
+
cloneFromRoleId?: string;
|
|
175
|
+
}
|
|
176
|
+
interface UpdateRoleInput {
|
|
177
|
+
name?: string;
|
|
178
|
+
description?: string;
|
|
179
|
+
permissions?: string[];
|
|
180
|
+
}
|
|
181
|
+
interface CreateInvitationInput {
|
|
182
|
+
email: string;
|
|
183
|
+
roleId: string;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export { type BUStatus, type BusinessUnitDetail, type BusinessUnitSummary, type CreateBusinessUnitInput, type CreateInvitationInput, type CreateRoleInput, type CurrentUser, type Invitation, type Member, type MemberStatus, type Membership, type MyBusinessUnits, type MyPermissions, type PageInfo, type PaginatedList, type PaginationInput, type PendingInvitation, type Permission, ROAD_API_CONTRACT, ROAD_API_URLS, type RoadApiContract, type RoadEnvironment, type Role, type RoleRef, type UpdateBusinessUnitInput, type UpdateRoleInput };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
export { R as ROAD_CORE_ACTIONS, a as ROAD_CORE_SUBJECTS, b as ROAD_WILDCARD_PERMISSION, c as RoadAction, d as RoadCoreSubject, e as RoadPermission } from './permissions-BSbomCrB.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The Road API **contract version** — the major boundary of the HTTP wire
|
|
5
|
+
* surface. The Road API mounts every route under `/api/<contract>`, and every
|
|
6
|
+
* SDK builds its base path as `${host}/api/${ROAD_API_CONTRACT}`.
|
|
7
|
+
*
|
|
8
|
+
* This is the single source of truth for that value. The Road API imports it
|
|
9
|
+
* for its global prefix; the in-repo clients (admin, tester) and the published
|
|
10
|
+
* SDKs read it from here. It is **not** environment configuration — it is
|
|
11
|
+
* identical in every environment and changes only by a deliberate edit when the
|
|
12
|
+
* wire contract makes a breaking change: `alpha` → `v1` → `v2`.
|
|
13
|
+
*
|
|
14
|
+
* Promoting this from `alpha` to `v1` is the trigger to take the SDKs to their
|
|
15
|
+
* first stable `1.0.0`. See `docs/plans/14-sdk-publishing-and-versioning.md`.
|
|
16
|
+
*/
|
|
17
|
+
declare const ROAD_API_CONTRACT: "alpha";
|
|
18
|
+
type RoadApiContract = typeof ROAD_API_CONTRACT;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Road's hosted API base URLs. SDKs default to ROAD_API_URLS.production; the
|
|
22
|
+
* sandbox URL is the deployed Road sandbox (override via the SDK's apiBaseUrl
|
|
23
|
+
* config if you're running against a different environment, eg. local dev or
|
|
24
|
+
* a private staging cluster).
|
|
25
|
+
*
|
|
26
|
+
* If the deployed sandbox hostname changes, update this constant — it's the
|
|
27
|
+
* single source of truth every SDK reads from.
|
|
28
|
+
*/
|
|
29
|
+
declare const ROAD_API_URLS: {
|
|
30
|
+
readonly production: "https://api.road.app";
|
|
31
|
+
readonly sandbox: "https://api.road-sandbox.b1.app";
|
|
32
|
+
};
|
|
33
|
+
type RoadEnvironment = keyof typeof ROAD_API_URLS;
|
|
34
|
+
|
|
35
|
+
type BUStatus = "active" | "suspended" | "archived";
|
|
36
|
+
type MemberStatus = "active" | "suspended" | "pending";
|
|
37
|
+
interface CurrentUser {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
email: string;
|
|
41
|
+
avatarUrl?: string;
|
|
42
|
+
}
|
|
43
|
+
interface BusinessUnitSummary {
|
|
44
|
+
id: string;
|
|
45
|
+
name: string;
|
|
46
|
+
slug: string;
|
|
47
|
+
}
|
|
48
|
+
interface BusinessUnitDetail {
|
|
49
|
+
id: string;
|
|
50
|
+
name: string;
|
|
51
|
+
slug: string;
|
|
52
|
+
status: BUStatus;
|
|
53
|
+
memberCount: number;
|
|
54
|
+
memberLimit: number | null;
|
|
55
|
+
joinCode: string | null;
|
|
56
|
+
createdAt: string;
|
|
57
|
+
/**
|
|
58
|
+
* Road IAM scope ID for this BU. The HTTP client uses it to call the
|
|
59
|
+
* per-scope role/permission endpoints (/iam/authorization/scopes/:scopeId/…).
|
|
60
|
+
* Exposed because the SDK needs it for role wiring; integrators usually
|
|
61
|
+
* don't need to touch it.
|
|
62
|
+
*/
|
|
63
|
+
iamScopeId: string;
|
|
64
|
+
}
|
|
65
|
+
interface RoleRef {
|
|
66
|
+
id: string;
|
|
67
|
+
name: string;
|
|
68
|
+
}
|
|
69
|
+
interface Membership {
|
|
70
|
+
businessUnit: BusinessUnitSummary;
|
|
71
|
+
status: MemberStatus;
|
|
72
|
+
joinedAt: string;
|
|
73
|
+
roles: RoleRef[];
|
|
74
|
+
}
|
|
75
|
+
interface PendingInvitation {
|
|
76
|
+
id: string;
|
|
77
|
+
businessUnit: BusinessUnitSummary;
|
|
78
|
+
roleName: string;
|
|
79
|
+
expiresAt: string;
|
|
80
|
+
}
|
|
81
|
+
interface MyBusinessUnits {
|
|
82
|
+
memberships: Membership[];
|
|
83
|
+
pendingInvitations: PendingInvitation[];
|
|
84
|
+
}
|
|
85
|
+
interface Member {
|
|
86
|
+
id: string;
|
|
87
|
+
userId: string;
|
|
88
|
+
status: MemberStatus;
|
|
89
|
+
joinedAt: string;
|
|
90
|
+
name: string;
|
|
91
|
+
email: string;
|
|
92
|
+
roles: RoleRef[];
|
|
93
|
+
}
|
|
94
|
+
interface Invitation {
|
|
95
|
+
id: string;
|
|
96
|
+
email: string;
|
|
97
|
+
roleId: string;
|
|
98
|
+
roleName: string;
|
|
99
|
+
status: "pending" | "accepted" | "expired" | "cancelled";
|
|
100
|
+
invitedAt: string;
|
|
101
|
+
expiresAt: string;
|
|
102
|
+
}
|
|
103
|
+
interface Role {
|
|
104
|
+
id: string;
|
|
105
|
+
name: string;
|
|
106
|
+
description: string;
|
|
107
|
+
permissions: string[];
|
|
108
|
+
isSystem: boolean;
|
|
109
|
+
memberCount: number;
|
|
110
|
+
}
|
|
111
|
+
interface Permission {
|
|
112
|
+
id: string;
|
|
113
|
+
code: string;
|
|
114
|
+
name: string;
|
|
115
|
+
description: string;
|
|
116
|
+
/** Subject group (e.g. "Member", "Role", "BusinessUnit") used to group in the picker. */
|
|
117
|
+
category: string;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Effective permissions for the current user, keyed by business-unit ID.
|
|
121
|
+
* A value of `["*"]` (ROAD_WILDCARD_PERMISSION) grants every action in that BU.
|
|
122
|
+
*/
|
|
123
|
+
type MyPermissions = Record<string, string[]>;
|
|
124
|
+
/**
|
|
125
|
+
* Cursor-paginated list response. The API issues opaque base64-url cursors
|
|
126
|
+
* the client treats as opaque — no parsing or arithmetic on the SDK side.
|
|
127
|
+
* `cursor` is null when no further page exists; `hasMore` is the canonical
|
|
128
|
+
* "more rows after this page" signal, redundant with `cursor !== null`.
|
|
129
|
+
*/
|
|
130
|
+
interface PageInfo {
|
|
131
|
+
/** Opaque cursor for the next page. Null when this is the last page. */
|
|
132
|
+
cursor: string | null;
|
|
133
|
+
/** True iff there is at least one row past this page. */
|
|
134
|
+
hasMore: boolean;
|
|
135
|
+
/** Total count of rows matching the filter, across all pages. */
|
|
136
|
+
totalCount: number;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Generic paged response shape returned from listing endpoints with
|
|
140
|
+
* cursor pagination (members, roles, invitations). Convertible 1:1 to
|
|
141
|
+
* React Query's useInfiniteQuery `pageParam` flow via `pageInfo.cursor`.
|
|
142
|
+
*/
|
|
143
|
+
interface PaginatedList<T> {
|
|
144
|
+
items: T[];
|
|
145
|
+
pageInfo: PageInfo;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Input shape for any paginated list call. Both fields are optional —
|
|
149
|
+
* omitting both fetches the first page with the API's default page size
|
|
150
|
+
* (currently 20).
|
|
151
|
+
*/
|
|
152
|
+
interface PaginationInput {
|
|
153
|
+
/** Opaque cursor from a previous `pageInfo.cursor`. Omit for the first page. */
|
|
154
|
+
cursor?: string;
|
|
155
|
+
/** Page size. Default 20, max 100 (server-enforced). */
|
|
156
|
+
limit?: number;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
interface CreateBusinessUnitInput {
|
|
160
|
+
name: string;
|
|
161
|
+
slug?: string;
|
|
162
|
+
memberLimit?: number | null;
|
|
163
|
+
}
|
|
164
|
+
interface UpdateBusinessUnitInput {
|
|
165
|
+
name?: string;
|
|
166
|
+
slug?: string;
|
|
167
|
+
memberLimit?: number | null;
|
|
168
|
+
}
|
|
169
|
+
interface CreateRoleInput {
|
|
170
|
+
name: string;
|
|
171
|
+
description?: string;
|
|
172
|
+
permissions: string[];
|
|
173
|
+
/** Source role ID when "clone from existing"; informational only. */
|
|
174
|
+
cloneFromRoleId?: string;
|
|
175
|
+
}
|
|
176
|
+
interface UpdateRoleInput {
|
|
177
|
+
name?: string;
|
|
178
|
+
description?: string;
|
|
179
|
+
permissions?: string[];
|
|
180
|
+
}
|
|
181
|
+
interface CreateInvitationInput {
|
|
182
|
+
email: string;
|
|
183
|
+
roleId: string;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export { type BUStatus, type BusinessUnitDetail, type BusinessUnitSummary, type CreateBusinessUnitInput, type CreateInvitationInput, type CreateRoleInput, type CurrentUser, type Invitation, type Member, type MemberStatus, type Membership, type MyBusinessUnits, type MyPermissions, type PageInfo, type PaginatedList, type PaginationInput, type PendingInvitation, type Permission, ROAD_API_CONTRACT, ROAD_API_URLS, type RoadApiContract, type RoadEnvironment, type Role, type RoleRef, type UpdateBusinessUnitInput, type UpdateRoleInput };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// src/api-contract.ts
|
|
2
|
+
var ROAD_API_CONTRACT = "alpha";
|
|
3
|
+
|
|
4
|
+
// src/api-urls.ts
|
|
5
|
+
var ROAD_API_URLS = {
|
|
6
|
+
production: "https://api.road.app",
|
|
7
|
+
sandbox: "https://api.road-sandbox.b1.app"
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// src/permissions.ts
|
|
11
|
+
var ROAD_CORE_ACTIONS = [
|
|
12
|
+
"create",
|
|
13
|
+
"read",
|
|
14
|
+
"update",
|
|
15
|
+
"delete",
|
|
16
|
+
"manage"
|
|
17
|
+
];
|
|
18
|
+
var ROAD_CORE_SUBJECTS = [
|
|
19
|
+
"BusinessUnit",
|
|
20
|
+
"BUDashboard",
|
|
21
|
+
"BUSettings",
|
|
22
|
+
"Member",
|
|
23
|
+
"Role",
|
|
24
|
+
"Permission",
|
|
25
|
+
"Invitation"
|
|
26
|
+
];
|
|
27
|
+
var ROAD_WILDCARD_PERMISSION = "*";
|
|
28
|
+
export {
|
|
29
|
+
ROAD_API_CONTRACT,
|
|
30
|
+
ROAD_API_URLS,
|
|
31
|
+
ROAD_CORE_ACTIONS,
|
|
32
|
+
ROAD_CORE_SUBJECTS,
|
|
33
|
+
ROAD_WILDCARD_PERMISSION
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/api-contract.ts","../src/api-urls.ts","../src/permissions.ts"],"sourcesContent":["/**\n * The Road API **contract version** — the major boundary of the HTTP wire\n * surface. The Road API mounts every route under `/api/<contract>`, and every\n * SDK builds its base path as `${host}/api/${ROAD_API_CONTRACT}`.\n *\n * This is the single source of truth for that value. The Road API imports it\n * for its global prefix; the in-repo clients (admin, tester) and the published\n * SDKs read it from here. It is **not** environment configuration — it is\n * identical in every environment and changes only by a deliberate edit when the\n * wire contract makes a breaking change: `alpha` → `v1` → `v2`.\n *\n * Promoting this from `alpha` to `v1` is the trigger to take the SDKs to their\n * first stable `1.0.0`. See `docs/plans/14-sdk-publishing-and-versioning.md`.\n */\nexport const ROAD_API_CONTRACT = \"alpha\" as const;\n\nexport type RoadApiContract = typeof ROAD_API_CONTRACT;\n","/**\n * Road's hosted API base URLs. SDKs default to ROAD_API_URLS.production; the\n * sandbox URL is the deployed Road sandbox (override via the SDK's apiBaseUrl\n * config if you're running against a different environment, eg. local dev or\n * a private staging cluster).\n *\n * If the deployed sandbox hostname changes, update this constant — it's the\n * single source of truth every SDK reads from.\n */\nexport const ROAD_API_URLS = {\n production: \"https://api.road.app\",\n sandbox: \"https://api.road-sandbox.b1.app\",\n} as const;\n\nexport type RoadEnvironment = keyof typeof ROAD_API_URLS;\n","/**\n * Road IAM permission algebra. Permissions are `${action}:${subject}` strings;\n * the wildcard `\"*\"` short-circuits to true for every action in a scope.\n *\n * The widget catalog calls into actions and subjects Road ships by default\n * (the union types below). Platforms can declare their own actions and\n * subjects in their IAM catalog — those flow through useCan as plain strings,\n * still type-safe via `RoadPermission | (string & {})` in the React SDK.\n */\n\n/**\n * The CRUD verbs Road's IAM engine recognizes, plus `manage` which the\n * engine expands server-side into the full CRUD set for the same subject\n * (`manage:Member` ⇒ also `create|read|update|delete:Member` in the\n * effective-permissions response).\n *\n * Platforms can register their own actions (`approve`, `submit`, `list`, …)\n * — those flow through useCan as plain strings (the `(string & {})` part\n * of PermissionInput in the React SDK), still type-safe via that escape.\n */\nexport type RoadAction = \"create\" | \"read\" | \"update\" | \"delete\" | \"manage\";\n\n/**\n * Built-in subjects Road's own permissions cover. Mirrors the subjects\n * registered in the API's `Subjects` constant\n * (apps/api/src/modules/iam/authorization/constants/subjects.ts), limited\n * to the subjects user-facing widgets actually surface:\n *\n * - BusinessUnit: system-level — create new BUs\n * - BUDashboard: BU-level — read a BU's detail page\n * - BUSettings: BU-level — edit a BU's settings\n * - Member, Role, Permission, Invitation: BU-level CRUD\n *\n * Admin / platform-engineer subjects (System, Platform, AdminUser,\n * PlatformIdentity, …) are not exposed here — they belong to a future\n * developer-facing widget (and admin SDK), not the customer-facing toolkit.\n *\n * Platform-specific subjects (eg. A4L's `Agent`) are not enumerated —\n * platforms register them at runtime under their own scope, and useCan's\n * `(string & {})` accepts them without complaint.\n */\nexport type RoadCoreSubject =\n | \"BusinessUnit\"\n | \"BUDashboard\"\n | \"BUSettings\"\n | \"Member\"\n | \"Role\"\n | \"Permission\"\n | \"Invitation\";\n\n/** `${action}:${Subject}` for the core set, plus the wildcard. */\nexport type RoadPermission = `${RoadAction}:${RoadCoreSubject}` | \"*\";\n\n/** Runtime array of the core actions — handy for iteration or validation. */\nexport const ROAD_CORE_ACTIONS = [\n \"create\",\n \"read\",\n \"update\",\n \"delete\",\n \"manage\",\n] as const satisfies readonly RoadAction[];\n\n/** Runtime array of the core subjects — handy for iteration or validation. */\nexport const ROAD_CORE_SUBJECTS = [\n \"BusinessUnit\",\n \"BUDashboard\",\n \"BUSettings\",\n \"Member\",\n \"Role\",\n \"Permission\",\n \"Invitation\",\n] as const satisfies readonly RoadCoreSubject[];\n\n/** The wildcard permission string. Use this instead of literal \"*\" for grep-ability. */\nexport const ROAD_WILDCARD_PERMISSION = \"*\" as const;\n"],"mappings":";AAcO,IAAM,oBAAoB;;;ACL1B,IAAM,gBAAgB;AAAA,EAC3B,YAAY;AAAA,EACZ,SAAS;AACX;;;AC0CO,IAAM,oBAAoB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGO,IAAM,qBAAqB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGO,IAAM,2BAA2B;","names":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Road IAM permission algebra. Permissions are `${action}:${subject}` strings;
|
|
3
|
+
* the wildcard `"*"` short-circuits to true for every action in a scope.
|
|
4
|
+
*
|
|
5
|
+
* The widget catalog calls into actions and subjects Road ships by default
|
|
6
|
+
* (the union types below). Platforms can declare their own actions and
|
|
7
|
+
* subjects in their IAM catalog — those flow through useCan as plain strings,
|
|
8
|
+
* still type-safe via `RoadPermission | (string & {})` in the React SDK.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* The CRUD verbs Road's IAM engine recognizes, plus `manage` which the
|
|
12
|
+
* engine expands server-side into the full CRUD set for the same subject
|
|
13
|
+
* (`manage:Member` ⇒ also `create|read|update|delete:Member` in the
|
|
14
|
+
* effective-permissions response).
|
|
15
|
+
*
|
|
16
|
+
* Platforms can register their own actions (`approve`, `submit`, `list`, …)
|
|
17
|
+
* — those flow through useCan as plain strings (the `(string & {})` part
|
|
18
|
+
* of PermissionInput in the React SDK), still type-safe via that escape.
|
|
19
|
+
*/
|
|
20
|
+
type RoadAction = "create" | "read" | "update" | "delete" | "manage";
|
|
21
|
+
/**
|
|
22
|
+
* Built-in subjects Road's own permissions cover. Mirrors the subjects
|
|
23
|
+
* registered in the API's `Subjects` constant
|
|
24
|
+
* (apps/api/src/modules/iam/authorization/constants/subjects.ts), limited
|
|
25
|
+
* to the subjects user-facing widgets actually surface:
|
|
26
|
+
*
|
|
27
|
+
* - BusinessUnit: system-level — create new BUs
|
|
28
|
+
* - BUDashboard: BU-level — read a BU's detail page
|
|
29
|
+
* - BUSettings: BU-level — edit a BU's settings
|
|
30
|
+
* - Member, Role, Permission, Invitation: BU-level CRUD
|
|
31
|
+
*
|
|
32
|
+
* Admin / platform-engineer subjects (System, Platform, AdminUser,
|
|
33
|
+
* PlatformIdentity, …) are not exposed here — they belong to a future
|
|
34
|
+
* developer-facing widget (and admin SDK), not the customer-facing toolkit.
|
|
35
|
+
*
|
|
36
|
+
* Platform-specific subjects (eg. A4L's `Agent`) are not enumerated —
|
|
37
|
+
* platforms register them at runtime under their own scope, and useCan's
|
|
38
|
+
* `(string & {})` accepts them without complaint.
|
|
39
|
+
*/
|
|
40
|
+
type RoadCoreSubject = "BusinessUnit" | "BUDashboard" | "BUSettings" | "Member" | "Role" | "Permission" | "Invitation";
|
|
41
|
+
/** `${action}:${Subject}` for the core set, plus the wildcard. */
|
|
42
|
+
type RoadPermission = `${RoadAction}:${RoadCoreSubject}` | "*";
|
|
43
|
+
/** Runtime array of the core actions — handy for iteration or validation. */
|
|
44
|
+
declare const ROAD_CORE_ACTIONS: readonly ["create", "read", "update", "delete", "manage"];
|
|
45
|
+
/** Runtime array of the core subjects — handy for iteration or validation. */
|
|
46
|
+
declare const ROAD_CORE_SUBJECTS: readonly ["BusinessUnit", "BUDashboard", "BUSettings", "Member", "Role", "Permission", "Invitation"];
|
|
47
|
+
/** The wildcard permission string. Use this instead of literal "*" for grep-ability. */
|
|
48
|
+
declare const ROAD_WILDCARD_PERMISSION: "*";
|
|
49
|
+
|
|
50
|
+
export { ROAD_CORE_ACTIONS as R, ROAD_CORE_SUBJECTS as a, ROAD_WILDCARD_PERMISSION as b, type RoadAction as c, type RoadCoreSubject as d, type RoadPermission as e };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Road IAM permission algebra. Permissions are `${action}:${subject}` strings;
|
|
3
|
+
* the wildcard `"*"` short-circuits to true for every action in a scope.
|
|
4
|
+
*
|
|
5
|
+
* The widget catalog calls into actions and subjects Road ships by default
|
|
6
|
+
* (the union types below). Platforms can declare their own actions and
|
|
7
|
+
* subjects in their IAM catalog — those flow through useCan as plain strings,
|
|
8
|
+
* still type-safe via `RoadPermission | (string & {})` in the React SDK.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* The CRUD verbs Road's IAM engine recognizes, plus `manage` which the
|
|
12
|
+
* engine expands server-side into the full CRUD set for the same subject
|
|
13
|
+
* (`manage:Member` ⇒ also `create|read|update|delete:Member` in the
|
|
14
|
+
* effective-permissions response).
|
|
15
|
+
*
|
|
16
|
+
* Platforms can register their own actions (`approve`, `submit`, `list`, …)
|
|
17
|
+
* — those flow through useCan as plain strings (the `(string & {})` part
|
|
18
|
+
* of PermissionInput in the React SDK), still type-safe via that escape.
|
|
19
|
+
*/
|
|
20
|
+
type RoadAction = "create" | "read" | "update" | "delete" | "manage";
|
|
21
|
+
/**
|
|
22
|
+
* Built-in subjects Road's own permissions cover. Mirrors the subjects
|
|
23
|
+
* registered in the API's `Subjects` constant
|
|
24
|
+
* (apps/api/src/modules/iam/authorization/constants/subjects.ts), limited
|
|
25
|
+
* to the subjects user-facing widgets actually surface:
|
|
26
|
+
*
|
|
27
|
+
* - BusinessUnit: system-level — create new BUs
|
|
28
|
+
* - BUDashboard: BU-level — read a BU's detail page
|
|
29
|
+
* - BUSettings: BU-level — edit a BU's settings
|
|
30
|
+
* - Member, Role, Permission, Invitation: BU-level CRUD
|
|
31
|
+
*
|
|
32
|
+
* Admin / platform-engineer subjects (System, Platform, AdminUser,
|
|
33
|
+
* PlatformIdentity, …) are not exposed here — they belong to a future
|
|
34
|
+
* developer-facing widget (and admin SDK), not the customer-facing toolkit.
|
|
35
|
+
*
|
|
36
|
+
* Platform-specific subjects (eg. A4L's `Agent`) are not enumerated —
|
|
37
|
+
* platforms register them at runtime under their own scope, and useCan's
|
|
38
|
+
* `(string & {})` accepts them without complaint.
|
|
39
|
+
*/
|
|
40
|
+
type RoadCoreSubject = "BusinessUnit" | "BUDashboard" | "BUSettings" | "Member" | "Role" | "Permission" | "Invitation";
|
|
41
|
+
/** `${action}:${Subject}` for the core set, plus the wildcard. */
|
|
42
|
+
type RoadPermission = `${RoadAction}:${RoadCoreSubject}` | "*";
|
|
43
|
+
/** Runtime array of the core actions — handy for iteration or validation. */
|
|
44
|
+
declare const ROAD_CORE_ACTIONS: readonly ["create", "read", "update", "delete", "manage"];
|
|
45
|
+
/** Runtime array of the core subjects — handy for iteration or validation. */
|
|
46
|
+
declare const ROAD_CORE_SUBJECTS: readonly ["BusinessUnit", "BUDashboard", "BUSettings", "Member", "Role", "Permission", "Invitation"];
|
|
47
|
+
/** The wildcard permission string. Use this instead of literal "*" for grep-ability. */
|
|
48
|
+
declare const ROAD_WILDCARD_PERMISSION: "*";
|
|
49
|
+
|
|
50
|
+
export { ROAD_CORE_ACTIONS as R, ROAD_CORE_SUBJECTS as a, ROAD_WILDCARD_PERMISSION as b, type RoadAction as c, type RoadCoreSubject as d, type RoadPermission as e };
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@b1-road/types",
|
|
3
|
+
"version": "0.1.0-alpha.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Shared types and constants for every @b1-road SDK — entities, permission algebra, hosted API URLs.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "B1 Produtos Digitais Ltda",
|
|
8
|
+
"homepage": "https://portal.road.b1.app",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/B1Company/road.git",
|
|
12
|
+
"directory": "apps/sdks/road-types"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://portal.road.b1.app"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"road",
|
|
19
|
+
"iam",
|
|
20
|
+
"rbac",
|
|
21
|
+
"authorization",
|
|
22
|
+
"types",
|
|
23
|
+
"b1"
|
|
24
|
+
],
|
|
25
|
+
"main": "./dist/index.cjs",
|
|
26
|
+
"module": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"import": { "types": "./dist/index.d.ts", "default": "./dist/index.js" },
|
|
31
|
+
"require": { "types": "./dist/index.d.cts", "default": "./dist/index.cjs" }
|
|
32
|
+
},
|
|
33
|
+
"./iam": {
|
|
34
|
+
"import": { "types": "./dist/iam.d.ts", "default": "./dist/iam.js" },
|
|
35
|
+
"require": { "types": "./dist/iam.d.cts", "default": "./dist/iam.cjs" }
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist"
|
|
40
|
+
],
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"sideEffects": false,
|
|
45
|
+
"scripts": {
|
|
46
|
+
"typecheck": "tsc --noEmit",
|
|
47
|
+
"build": "tsup",
|
|
48
|
+
"prepack": "npm run build"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"tsup": "^8.5.1",
|
|
52
|
+
"typescript": "^5.7.0"
|
|
53
|
+
}
|
|
54
|
+
}
|