diff --git a/package-lock.json b/package-lock.json index f419c51..cf55dab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "solid-logic", - "version": "6.0.0-1", + "version": "6.0.0-2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "solid-logic", - "version": "6.0.0-1", + "version": "6.0.0-2", "license": "MIT", "dependencies": { "@dokieli/web-access-control": "^1.0.0", diff --git a/package.json b/package.json index 0934f79..737ad0a 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,15 @@ { "name": "solid-logic", - "version": "6.0.0-1", + "version": "6.0.0-2", "description": "Core business logic of SolidOS", "main": "dist/index.cjs.js", "module": "dist/index.esm.js", "types": "dist/index.d.ts", "exports": { ".": { + "types": "./dist/index.d.ts", "import": "./dist/index.esm.js", - "require": "./dist/index.cjs.js", - "types": "./dist/index.d.ts" + "require": "./dist/index.cjs.js" } }, "sideEffects": false, @@ -20,7 +20,8 @@ ], "scripts": { "clean": "rm -rf dist src/versionInfo.ts", - "build": "npm run clean && npm run typecheck && vite build", + "build": "npm run clean && npm run typecheck && vite build && npm run build-types", + "build-types": "tsc --emitDeclarationOnly", "watch": "vite build --watch", "postbuild": "npm run postbuild-js", "postbuild-js": "rm -f dist/versionInfo.d.ts dist/versionInfo.d.ts.map dist/index.js dist/index.js.map", diff --git a/src/index.ts b/src/index.ts index dc9b8c5..4dc0f9e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,6 +15,7 @@ export { getSuggestedIssuers } from './issuer/issuerLogic' export { createTypeIndexLogic } from './typeIndex/typeIndexLogic' export { createDirectoryLogic, DEFAULT_DIRECTORY_CATALOG_URL, DEFAULT_DIRECTORY_SOURCES } from './directory/directoryLogic' export type { AccessControlSubjectKind, AccessControlSubject } from './acl/accessControlSubjects' +export type { ACLContext, AccessMode, AccessSubject, Authorization, PatchPlan } from './types' export type { AppDetails, SolidNamespace, AuthenticationContext, SolidLogic, ChatLogic, DirectoryLogic, DirectoryEntry, DirectorySearchOptions, DirectoryRelationshipLabel, DirectorySource } from './types' export { UnauthorizedError, CrossOriginForbiddenError, SameOriginForbiddenError, NotFoundError, FetchError, NotEditableError, WebOperationError } from './logic/CustomError' diff --git a/test/publicAclApi.test.ts b/test/publicAclApi.test.ts new file mode 100644 index 0000000..a2f9926 --- /dev/null +++ b/test/publicAclApi.test.ts @@ -0,0 +1,32 @@ +import { describe, expect, expectTypeOf, it } from 'vitest' +import { + ACCESS_ROLES, + solidLogicSingleton, + type ACLContext, + type AccessControlSubjectKind, + type AccessMode, + type AccessRole, + type AccessSubject, + type Authorization, + type PatchPlan +} from '../src' + +describe('public ACL API', () => { + it('exports the role list and exposes mapping through the singleton', () => { + expect(ACCESS_ROLES).toEqual(['Owner', 'Editor', 'No Access', 'Viewer', 'Poster', 'Submitter']) + for (const role of ACCESS_ROLES) { + expect(solidLogicSingleton.acl.roleFromModes(solidLogicSingleton.acl.modesFromRole(role))).toBe(role) + } + }) + + it('exports the types used by access-control consumers', () => { + expectTypeOf(solidLogicSingleton.acl.modesFromRole).toEqualTypeOf<(role: AccessRole) => AccessMode[]>() + expectTypeOf(solidLogicSingleton.acl.roleFromModes).toEqualTypeOf<(modes: Iterable) => AccessRole>() + expectTypeOf(solidLogicSingleton.acl.findEffectiveAcl).returns.toEqualTypeOf>() + expectTypeOf(solidLogicSingleton.acl.findAccessGrants).returns.toEqualTypeOf>() + expectTypeOf(solidLogicSingleton.acl.planGrant).toEqualTypeOf< + (resource: string | import('rdflib').NamedNode, subject: AccessSubject, modes: AccessMode[]) => Promise + >() + expectTypeOf().toEqualTypeOf<'agent' | 'agentGroup' | 'agentClass' | 'origin'>() + }) +})