Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
PDP_API_KEY: test

jobs:
test-and-lint:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18, 20]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Run linting
run: yarn lint

- name: Build project
run: yarn build

- name: Run all tests
run: yarn test
47 changes: 21 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
{
"name": "permitio",
"version": "2.7.1-rc.0",
"version": "2.7.5",
"description": "Node.js client library for the Permit.io full-stack permissions platform",
"type": "commonjs",
"main": "build/main/index.js",
"typings": "build/main/index.d.ts",
"module": "build/module/index.mjs",
"main": "build/index.js",
"typings": "build/index.d.ts",
"module": "build/index.mjs",
"exports": {
".": {
"types": "./build/module/index.d.ts",
"import": "./build/module/index.mjs",
"require": "./build/main/index.js"
},
"./build/main/*": "./build/main/*",
"./build/module/*": "./build/module/*"
"types": "./build/index.d.ts",
"import": "./build/index.mjs",
"require": "./build/index.js"
}
},
"repository": {
"type": "git",
Expand All @@ -22,17 +20,21 @@
"license": "MIT",
"keywords": [],
"scripts": {
"build": "run-p build:*",
"build:main": "tsc -p tsconfig.json",
"build:module": "tsc -p tsconfig.module.json && yarn rename:esm",
"build": "run-s build:js build:types",
"build:js": "tsup",
"build:types": "tsc --emitDeclarationOnly --outDir build",
"lint": "run-s lint:*",
"lint:eslint": "eslint src --ext .ts",
"lint:prettier": "prettier --config .prettierrc \"src/**/*.{ts,css,less,scss,js}\" --check",
"fix": "run-s fix:*",
"fix:prettier": "prettier --config .prettierrc \"src/**/*.{ts,css,less,scss,js}\" --write",
"fix:lint": "eslint src --ext .ts --fix",
"test": "run-s test:*",
"test:integration": "run-s build && ava --verbose src/**/endpoints/**",
"test:e2e:rbac": "run-s build && ava --verbose src/**/e2e/rbac.e2e.spec.ts",
"test:e2e:rebac": "run-s build && ava --verbose src/**/e2e/rebac.e2e.spec.ts",
"test:e2e:local_facts": "run-s build && ava --verbose src/**/e2e/local_facts.e2e.spec.ts",
"test:integration": "run-s build && ava --verbose build/tests/endpoints/**/*.spec.js",
"test:module-imports": "run-s build && ava --verbose build/tests/module-imports/**/*.spec.js",
"test:e2e:rbac": "run-s build && ava --verbose build/tests/e2e/rbac.e2e.spec.js",
"test:e2e:rebac": "run-s build && ava --verbose build/tests/e2e/rebac.e2e.spec.js",
"test:e2e:local_facts": "run-s build && ava --verbose build/tests/e2e/local_facts.e2e.spec.js",
"check-cli": "run-s test diff-integration-tests check-integration-tests",
"check-integration-tests": "run-s check-integration-test:*",
"diff-integration-tests": "mkdir -p diff && rm -rf diff/test && cp -r test diff/test && rm -rf diff/test/test-*/.git && cd diff && git init --quiet && git add -A && git commit --quiet --no-verify --allow-empty -m 'WIP' && echo '\\n\\nCommitted most recent integration test output in the \"diff\" directory. Review the changes with \"cd diff && git diff HEAD\" or your preferred git diff viewer.'",
Expand All @@ -46,7 +48,6 @@
"docs": "typedoc",
"docs:watch": "typedoc --watch",
"version": "2.5.2",
"rename:esm": "/bin/bash ./scripts/rename-mjs.sh",
"reset-hard": "git clean -dfx && git reset --hard && yarn",
"prepare": "npm run build && husky install",
"prepare-release": "run-s reset-hard test cov:check doc:html version doc:publish",
Expand Down Expand Up @@ -94,12 +95,12 @@
"prettier": "^2.5.1",
"standard-version": "^9.0.0",
"ts-node": "^9.0.0",
"tsup": "^8.5.0",
"typedoc": "^0.24.7",
"typescript": "^4.6.4"
},
"files": [
"build/main",
"build/module",
"build",
"!**/*.spec.*",
"!**/*.json",
"CHANGELOG.md",
Expand All @@ -110,13 +111,7 @@
"failFast": true,
"failWithoutAssertions": false,
"timeout": "60s",
"typescript": {
"rewritePaths": {
"src/": "build/main/"
}
},
"files": [
"!build/module/**",
"!src/tests/fixtures.ts"
]
},
Expand Down
3 changes: 0 additions & 3 deletions scripts/rename-mjs.sh

This file was deleted.

2 changes: 1 addition & 1 deletion src/api/base.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios, { AxiosError, AxiosResponse } from 'axios';
import { Logger } from 'pino';

import { IPermitConfig, FactsSyncTimeoutPolicy } from '../config';
import { FactsSyncTimeoutPolicy, IPermitConfig } from '../config';
import { APIKeysApi, Configuration } from '../openapi';
import { BASE_PATH } from '../openapi/base';

Expand Down
1 change: 1 addition & 0 deletions src/enforcement/enforcer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import axios, { AxiosInstance } from 'axios';
import { Logger } from 'pino';
import URL from 'url-parse';

import { IPermitConfig } from '../config';
import { CheckConfig, Context, ContextStore } from '../utils/context';
import { AxiosLoggingInterceptor } from '../utils/http-logger';
Expand Down
2 changes: 1 addition & 1 deletion src/openapi/types/activity-details-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ export const ActivityDetailsListKindEnum = {
} as const;

export type ActivityDetailsListKindEnum =
typeof ActivityDetailsListKindEnum[keyof typeof ActivityDetailsListKindEnum];
(typeof ActivityDetailsListKindEnum)[keyof typeof ActivityDetailsListKindEnum];
2 changes: 1 addition & 1 deletion src/openapi/types/activity-details-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ export const ActivityDetailsObjectKindEnum = {
} as const;

export type ActivityDetailsObjectKindEnum =
typeof ActivityDetailsObjectKindEnum[keyof typeof ActivityDetailsObjectKindEnum];
(typeof ActivityDetailsObjectKindEnum)[keyof typeof ActivityDetailsObjectKindEnum];
2 changes: 1 addition & 1 deletion src/openapi/types/allowed-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ export const AllowedResultQueryTypeEnum = {
} as const;

export type AllowedResultQueryTypeEnum =
typeof AllowedResultQueryTypeEnum[keyof typeof AllowedResultQueryTypeEnum];
(typeof AllowedResultQueryTypeEnum)[keyof typeof AllowedResultQueryTypeEnum];
2 changes: 1 addition & 1 deletion src/openapi/types/apikey-owner-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ export const APIKeyOwnerType = {
Elements: 'elements',
} as const;

export type APIKeyOwnerType = typeof APIKeyOwnerType[keyof typeof APIKeyOwnerType];
export type APIKeyOwnerType = (typeof APIKeyOwnerType)[keyof typeof APIKeyOwnerType];
2 changes: 1 addition & 1 deletion src/openapi/types/apikey-viewer-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ export const APIKeyViewerContextTypeEnum = {
} as const;

export type APIKeyViewerContextTypeEnum =
typeof APIKeyViewerContextTypeEnum[keyof typeof APIKeyViewerContextTypeEnum];
(typeof APIKeyViewerContextTypeEnum)[keyof typeof APIKeyViewerContextTypeEnum];
2 changes: 1 addition & 1 deletion src/openapi/types/attribute-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ export const AttributeType = {
Json: 'json',
} as const;

export type AttributeType = typeof AttributeType[keyof typeof AttributeType];
export type AttributeType = (typeof AttributeType)[keyof typeof AttributeType];
2 changes: 1 addition & 1 deletion src/openapi/types/audit-log-sort-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ export const AuditLogSortKey = {
Timestamp: 'timestamp',
} as const;

export type AuditLogSortKey = typeof AuditLogSortKey[keyof typeof AuditLogSortKey];
export type AuditLogSortKey = (typeof AuditLogSortKey)[keyof typeof AuditLogSortKey];
2 changes: 1 addition & 1 deletion src/openapi/types/auth-mechanism.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ export const AuthMechanism = {
Headers: 'Headers',
} as const;

export type AuthMechanism = typeof AuthMechanism[keyof typeof AuthMechanism];
export type AuthMechanism = (typeof AuthMechanism)[keyof typeof AuthMechanism];
2 changes: 1 addition & 1 deletion src/openapi/types/authn-me-apikey-read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ export const AuthnMeAPIKeyReadActorTypeEnum = {
} as const;

export type AuthnMeAPIKeyReadActorTypeEnum =
typeof AuthnMeAPIKeyReadActorTypeEnum[keyof typeof AuthnMeAPIKeyReadActorTypeEnum];
(typeof AuthnMeAPIKeyReadActorTypeEnum)[keyof typeof AuthnMeAPIKeyReadActorTypeEnum];
2 changes: 1 addition & 1 deletion src/openapi/types/authn-me-member-read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ export const AuthnMeMemberReadActorTypeEnum = {
} as const;

export type AuthnMeMemberReadActorTypeEnum =
typeof AuthnMeMemberReadActorTypeEnum[keyof typeof AuthnMeMemberReadActorTypeEnum];
(typeof AuthnMeMemberReadActorTypeEnum)[keyof typeof AuthnMeMemberReadActorTypeEnum];
6 changes: 3 additions & 3 deletions src/openapi/types/authn-me-user-read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,16 @@ export const AuthnMeUserReadActorTypeEnum = {
} as const;

export type AuthnMeUserReadActorTypeEnum =
typeof AuthnMeUserReadActorTypeEnum[keyof typeof AuthnMeUserReadActorTypeEnum];
(typeof AuthnMeUserReadActorTypeEnum)[keyof typeof AuthnMeUserReadActorTypeEnum];
export const AuthnMeUserReadIsOnboardingEnum = {
False: false,
} as const;

export type AuthnMeUserReadIsOnboardingEnum =
typeof AuthnMeUserReadIsOnboardingEnum[keyof typeof AuthnMeUserReadIsOnboardingEnum];
(typeof AuthnMeUserReadIsOnboardingEnum)[keyof typeof AuthnMeUserReadIsOnboardingEnum];
export const AuthnMeUserReadOnboardingStepEnum = {
Done: 'done',
} as const;

export type AuthnMeUserReadOnboardingStepEnum =
typeof AuthnMeUserReadOnboardingStepEnum[keyof typeof AuthnMeUserReadOnboardingStepEnum];
(typeof AuthnMeUserReadOnboardingStepEnum)[keyof typeof AuthnMeUserReadOnboardingStepEnum];
2 changes: 1 addition & 1 deletion src/openapi/types/avpengine-decision-log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ export const AVPEngineDecisionLogEngineEnum = {
} as const;

export type AVPEngineDecisionLogEngineEnum =
typeof AVPEngineDecisionLogEngineEnum[keyof typeof AVPEngineDecisionLogEngineEnum];
(typeof AVPEngineDecisionLogEngineEnum)[keyof typeof AVPEngineDecisionLogEngineEnum];
2 changes: 1 addition & 1 deletion src/openapi/types/condition-set-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ export const ConditionSetType = {
Resourceset: 'resourceset',
} as const;

export type ConditionSetType = typeof ConditionSetType[keyof typeof ConditionSetType];
export type ConditionSetType = (typeof ConditionSetType)[keyof typeof ConditionSetType];
2 changes: 1 addition & 1 deletion src/openapi/types/elements-permission-level.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ export const ElementsPermissionLevel = {
} as const;

export type ElementsPermissionLevel =
typeof ElementsPermissionLevel[keyof typeof ElementsPermissionLevel];
(typeof ElementsPermissionLevel)[keyof typeof ElementsPermissionLevel];
2 changes: 1 addition & 1 deletion src/openapi/types/elements-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ export const ElementsType = {
ApprovalFlow: 'approval_flow',
} as const;

export type ElementsType = typeof ElementsType[keyof typeof ElementsType];
export type ElementsType = (typeof ElementsType)[keyof typeof ElementsType];
2 changes: 1 addition & 1 deletion src/openapi/types/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ export const Engine = {
Avp: 'AVP',
} as const;

export type Engine = typeof Engine[keyof typeof Engine];
export type Engine = (typeof Engine)[keyof typeof Engine];
2 changes: 1 addition & 1 deletion src/openapi/types/environment-copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ export const EnvironmentCopyConflictStrategyEnum = {
} as const;

export type EnvironmentCopyConflictStrategyEnum =
typeof EnvironmentCopyConflictStrategyEnum[keyof typeof EnvironmentCopyConflictStrategyEnum];
(typeof EnvironmentCopyConflictStrategyEnum)[keyof typeof EnvironmentCopyConflictStrategyEnum];
2 changes: 1 addition & 1 deletion src/openapi/types/environment-regeneration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ export const EnvironmentRegenerationScopeEnum = {
} as const;

export type EnvironmentRegenerationScopeEnum =
typeof EnvironmentRegenerationScopeEnum[keyof typeof EnvironmentRegenerationScopeEnum];
(typeof EnvironmentRegenerationScopeEnum)[keyof typeof EnvironmentRegenerationScopeEnum];
2 changes: 1 addition & 1 deletion src/openapi/types/full-regeneration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ export const FullRegenerationScopeEnum = {
} as const;

export type FullRegenerationScopeEnum =
typeof FullRegenerationScopeEnum[keyof typeof FullRegenerationScopeEnum];
(typeof FullRegenerationScopeEnum)[keyof typeof FullRegenerationScopeEnum];
2 changes: 1 addition & 1 deletion src/openapi/types/http-methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ export const HttpMethods = {
Delete: 'delete',
} as const;

export type HttpMethods = typeof HttpMethods[keyof typeof HttpMethods];
export type HttpMethods = (typeof HttpMethods)[keyof typeof HttpMethods];
2 changes: 1 addition & 1 deletion src/openapi/types/invite-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ export const InviteStatus = {
Canceled: 'canceled',
} as const;

export type InviteStatus = typeof InviteStatus[keyof typeof InviteStatus];
export type InviteStatus = (typeof InviteStatus)[keyof typeof InviteStatus];
2 changes: 1 addition & 1 deletion src/openapi/types/member-access-level.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ export const MemberAccessLevel = {
Read: 'read',
} as const;

export type MemberAccessLevel = typeof MemberAccessLevel[keyof typeof MemberAccessLevel];
export type MemberAccessLevel = (typeof MemberAccessLevel)[keyof typeof MemberAccessLevel];
2 changes: 1 addition & 1 deletion src/openapi/types/member-access-obj.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ export const MemberAccessObj = {
Env: 'env',
} as const;

export type MemberAccessObj = typeof MemberAccessObj[keyof typeof MemberAccessObj];
export type MemberAccessObj = (typeof MemberAccessObj)[keyof typeof MemberAccessObj];
2 changes: 1 addition & 1 deletion src/openapi/types/member-viewer-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ export const MemberViewerContextTypeEnum = {
} as const;

export type MemberViewerContextTypeEnum =
typeof MemberViewerContextTypeEnum[keyof typeof MemberViewerContextTypeEnum];
(typeof MemberViewerContextTypeEnum)[keyof typeof MemberViewerContextTypeEnum];
2 changes: 1 addition & 1 deletion src/openapi/types/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ export const Methods = {
Options: 'options',
} as const;

export type Methods = typeof Methods[keyof typeof Methods];
export type Methods = (typeof Methods)[keyof typeof Methods];
2 changes: 1 addition & 1 deletion src/openapi/types/onboarding-step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ export const OnboardingStep = {
Done: 'done',
} as const;

export type OnboardingStep = typeof OnboardingStep[keyof typeof OnboardingStep];
export type OnboardingStep = (typeof OnboardingStep)[keyof typeof OnboardingStep];
2 changes: 1 addition & 1 deletion src/openapi/types/opaengine-decision-log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ export const OPAEngineDecisionLogEngineEnum = {
} as const;

export type OPAEngineDecisionLogEngineEnum =
typeof OPAEngineDecisionLogEngineEnum[keyof typeof OPAEngineDecisionLogEngineEnum];
(typeof OPAEngineDecisionLogEngineEnum)[keyof typeof OPAEngineDecisionLogEngineEnum];
2 changes: 1 addition & 1 deletion src/openapi/types/organization-regeneration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ export const OrganizationRegenerationScopeEnum = {
} as const;

export type OrganizationRegenerationScopeEnum =
typeof OrganizationRegenerationScopeEnum[keyof typeof OrganizationRegenerationScopeEnum];
(typeof OrganizationRegenerationScopeEnum)[keyof typeof OrganizationRegenerationScopeEnum];
2 changes: 1 addition & 1 deletion src/openapi/types/policy-repo-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ export const PolicyRepoStatus = {
Valid: 'valid',
} as const;

export type PolicyRepoStatus = typeof PolicyRepoStatus[keyof typeof PolicyRepoStatus];
export type PolicyRepoStatus = (typeof PolicyRepoStatus)[keyof typeof PolicyRepoStatus];
2 changes: 1 addition & 1 deletion src/openapi/types/programming-language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ export const ProgrammingLanguage = {
KongGateway: 'kong_gateway',
} as const;

export type ProgrammingLanguage = typeof ProgrammingLanguage[keyof typeof ProgrammingLanguage];
export type ProgrammingLanguage = (typeof ProgrammingLanguage)[keyof typeof ProgrammingLanguage];
2 changes: 1 addition & 1 deletion src/openapi/types/project-regeneration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ export const ProjectRegenerationScopeEnum = {
} as const;

export type ProjectRegenerationScopeEnum =
typeof ProjectRegenerationScopeEnum[keyof typeof ProjectRegenerationScopeEnum];
(typeof ProjectRegenerationScopeEnum)[keyof typeof ProjectRegenerationScopeEnum];
2 changes: 1 addition & 1 deletion src/openapi/types/sshauth-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ export const SSHAuthDataAuthTypeEnum = {
} as const;

export type SSHAuthDataAuthTypeEnum =
typeof SSHAuthDataAuthTypeEnum[keyof typeof SSHAuthDataAuthTypeEnum];
(typeof SSHAuthDataAuthTypeEnum)[keyof typeof SSHAuthDataAuthTypeEnum];
2 changes: 1 addition & 1 deletion src/openapi/types/user-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ export const UserStatus = {
Pending: 'pending',
} as const;

export type UserStatus = typeof UserStatus[keyof typeof UserStatus];
export type UserStatus = (typeof UserStatus)[keyof typeof UserStatus];
2 changes: 1 addition & 1 deletion src/tests/e2e/rbac.e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import anyTest, { TestInterface } from 'ava';
import { UserCreate, UserRead } from '../../openapi';

import { UserCreate, UserRead } from '../../openapi';

Check warning on line 3 in src/tests/e2e/rbac.e2e.spec.ts

View workflow job for this annotation

GitHub Actions / test-and-lint (20)

'UserCreate' is defined but never used

Check warning on line 3 in src/tests/e2e/rbac.e2e.spec.ts

View workflow job for this annotation

GitHub Actions / test-and-lint (18)

'UserCreate' is defined but never used
import { printBreak, provideTestExecutionContext, TestContext } from '../fixtures';

const sleepTimeMs = 10000;
Expand Down Expand Up @@ -169,7 +169,7 @@
],
});

t.is(newUser.roles![0].role, viewer.key);

Check warning on line 172 in src/tests/e2e/rbac.e2e.spec.ts

View workflow job for this annotation

GitHub Actions / test-and-lint (20)

Forbidden non-null assertion

Check warning on line 172 in src/tests/e2e/rbac.e2e.spec.ts

View workflow job for this annotation

GitHub Actions / test-and-lint (18)

Forbidden non-null assertion

logger.info(
`sleeping ${sleepTimeMs} ms before permit.check() to make sure all writes propagated from cloud to PDP`,
Expand Down
Loading
Loading