Skip to content

Commit eac4b08

Browse files
authored
Merge pull request #337 from SolidOS/fix/solidui
needed exported types
2 parents aab2b85 + 879d79f commit eac4b08

4 files changed

Lines changed: 40 additions & 6 deletions

File tree

‎package-lock.json‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"name": "solid-logic",
3-
"version": "6.0.0-1",
3+
"version": "6.0.0-2",
44
"description": "Core business logic of SolidOS",
55
"main": "dist/index.cjs.js",
66
"module": "dist/index.esm.js",
77
"types": "dist/index.d.ts",
88
"exports": {
99
".": {
10+
"types": "./dist/index.d.ts",
1011
"import": "./dist/index.esm.js",
11-
"require": "./dist/index.cjs.js",
12-
"types": "./dist/index.d.ts"
12+
"require": "./dist/index.cjs.js"
1313
}
1414
},
1515
"sideEffects": false,
@@ -20,7 +20,8 @@
2020
],
2121
"scripts": {
2222
"clean": "rm -rf dist src/versionInfo.ts",
23-
"build": "npm run clean && npm run typecheck && vite build",
23+
"build": "npm run clean && npm run typecheck && vite build && npm run build-types",
24+
"build-types": "tsc --emitDeclarationOnly",
2425
"watch": "vite build --watch",
2526
"postbuild": "npm run postbuild-js",
2627
"postbuild-js": "rm -f dist/versionInfo.d.ts dist/versionInfo.d.ts.map dist/index.js dist/index.js.map",

‎src/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export { getSuggestedIssuers } from './issuer/issuerLogic'
1515
export { createTypeIndexLogic } from './typeIndex/typeIndexLogic'
1616
export { createDirectoryLogic, DEFAULT_DIRECTORY_CATALOG_URL, DEFAULT_DIRECTORY_SOURCES } from './directory/directoryLogic'
1717
export type { AccessControlSubjectKind, AccessControlSubject } from './acl/accessControlSubjects'
18+
export type { ACLContext, AccessMode, AccessSubject, Authorization, PatchPlan } from './types'
1819
export type { AppDetails, SolidNamespace, AuthenticationContext, SolidLogic, ChatLogic, DirectoryLogic, DirectoryEntry, DirectorySearchOptions, DirectoryRelationshipLabel, DirectorySource } from './types'
1920
export { UnauthorizedError, CrossOriginForbiddenError, SameOriginForbiddenError, NotFoundError, FetchError, NotEditableError, WebOperationError } from './logic/CustomError'
2021

‎test/publicAclApi.test.ts‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { describe, expect, expectTypeOf, it } from 'vitest'
2+
import {
3+
ACCESS_ROLES,
4+
solidLogicSingleton,
5+
type ACLContext,
6+
type AccessControlSubjectKind,
7+
type AccessMode,
8+
type AccessRole,
9+
type AccessSubject,
10+
type Authorization,
11+
type PatchPlan
12+
} from '../src'
13+
14+
describe('public ACL API', () => {
15+
it('exports the role list and exposes mapping through the singleton', () => {
16+
expect(ACCESS_ROLES).toEqual(['Owner', 'Editor', 'No Access', 'Viewer', 'Poster', 'Submitter'])
17+
for (const role of ACCESS_ROLES) {
18+
expect(solidLogicSingleton.acl.roleFromModes(solidLogicSingleton.acl.modesFromRole(role))).toBe(role)
19+
}
20+
})
21+
22+
it('exports the types used by access-control consumers', () => {
23+
expectTypeOf(solidLogicSingleton.acl.modesFromRole).toEqualTypeOf<(role: AccessRole) => AccessMode[]>()
24+
expectTypeOf(solidLogicSingleton.acl.roleFromModes).toEqualTypeOf<(modes: Iterable<AccessMode>) => AccessRole>()
25+
expectTypeOf(solidLogicSingleton.acl.findEffectiveAcl).returns.toEqualTypeOf<Promise<ACLContext>>()
26+
expectTypeOf(solidLogicSingleton.acl.findAccessGrants).returns.toEqualTypeOf<Promise<Authorization[]>>()
27+
expectTypeOf(solidLogicSingleton.acl.planGrant).toEqualTypeOf<
28+
(resource: string | import('rdflib').NamedNode, subject: AccessSubject, modes: AccessMode[]) => Promise<PatchPlan>
29+
>()
30+
expectTypeOf<AccessControlSubjectKind>().toEqualTypeOf<'agent' | 'agentGroup' | 'agentClass' | 'origin'>()
31+
})
32+
})

0 commit comments

Comments
 (0)