@atls/nestjs-keto 0.0.6 → 0.0.8
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/dist/decorators/get-guarding-relation.helper.d.ts +1 -1
- package/dist/decorators/get-guarding-relation.helper.js +2 -6
- package/dist/decorators/guarded-by-keto.constants.js +1 -4
- package/dist/decorators/guarded-by-keto.decorator.d.ts +1 -1
- package/dist/decorators/guarded-by-keto.decorator.js +3 -7
- package/dist/decorators/guarded-by-keto.interfaces.d.ts +5 -5
- package/dist/decorators/guarded-by-keto.interfaces.js +1 -2
- package/dist/decorators/index.d.ts +5 -5
- package/dist/decorators/index.js +3 -22
- package/dist/exceptions/exception-message.constants.js +2 -5
- package/dist/exceptions/general.exception.d.ts +2 -2
- package/dist/exceptions/general.exception.js +4 -8
- package/dist/exceptions/index.d.ts +2 -2
- package/dist/exceptions/index.js +2 -18
- package/dist/exceptions/relation-tuple-invalid.exception.d.ts +2 -2
- package/dist/exceptions/relation-tuple-invalid.exception.js +4 -8
- package/dist/guards/index.d.ts +1 -1
- package/dist/guards/index.js +1 -17
- package/dist/guards/keto.guard.d.ts +3 -3
- package/dist/guards/keto.guard.js +20 -21
- package/dist/index.d.ts +4 -4
- package/dist/index.js +5 -21
- package/dist/module/index.d.ts +3 -3
- package/dist/module/index.js +3 -19
- package/dist/module/keto-module.interfaces.d.ts +10 -10
- package/dist/module/keto-module.interfaces.js +1 -2
- package/dist/module/keto.constants.js +5 -8
- package/dist/module/keto.module.d.ts +3 -3
- package/dist/module/keto.module.js +12 -15
- package/dist/module/keto.providers.d.ts +4 -4
- package/dist/module/keto.providers.js +26 -31
- package/dist/services/index.d.ts +5 -5
- package/dist/services/index.js +5 -21
- package/dist/services/keto-configuration.service.js +9 -11
- package/dist/services/keto-permissions.service.d.ts +1 -1
- package/dist/services/keto-permissions.service.js +11 -13
- package/dist/services/keto-read-client.service.d.ts +2 -2
- package/dist/services/keto-read-client.service.js +11 -13
- package/dist/services/keto-relations.service.js +11 -13
- package/dist/services/keto-write-client.service.d.ts +4 -4
- package/dist/services/keto-write-client.service.js +13 -15
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -17
- package/dist/utils/relation-tuple-converter.d.ts +2 -2
- package/dist/utils/relation-tuple-converter.js +7 -7
- package/package.json +36 -17
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { GetGuardingRelationTuple } from './guarded-by-keto.interfaces';
|
|
1
|
+
import type { GetGuardingRelationTuple } from './guarded-by-keto.interfaces.js';
|
|
2
2
|
export declare const getGuardingRelationTuple: GetGuardingRelationTuple;
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getGuardingRelationTuple = void 0;
|
|
4
|
-
const guarded_by_keto_constants_1 = require("./guarded-by-keto.constants");
|
|
5
|
-
const getGuardingRelationTuple = (reflector, handler) => reflector.get(guarded_by_keto_constants_1.GUARDED_BY_METADATA_KEY, handler) ?? null;
|
|
6
|
-
exports.getGuardingRelationTuple = getGuardingRelationTuple;
|
|
1
|
+
import { GUARDED_BY_METADATA_KEY } from './guarded-by-keto.constants.js';
|
|
2
|
+
export const getGuardingRelationTuple = (reflector, handler) => reflector.get(GUARDED_BY_METADATA_KEY, handler) ?? null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { GuardedByKetoFunction } from './guarded-by-keto.interfaces';
|
|
1
|
+
import type { GuardedByKetoFunction } from './guarded-by-keto.interfaces.js';
|
|
2
2
|
export declare const GuardedByKeto: GuardedByKetoFunction;
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const guarded_by_keto_constants_1 = require("./guarded-by-keto.constants");
|
|
6
|
-
const GuardedByKeto = (relationTuple) => (0, common_1.SetMetadata)(guarded_by_keto_constants_1.GUARDED_BY_METADATA_KEY, relationTuple);
|
|
7
|
-
exports.GuardedByKeto = GuardedByKeto;
|
|
1
|
+
import { SetMetadata } from '@nestjs/common';
|
|
2
|
+
import { GUARDED_BY_METADATA_KEY } from './guarded-by-keto.constants.js';
|
|
3
|
+
export const GuardedByKeto = (relationTuple) => SetMetadata(GUARDED_BY_METADATA_KEY, relationTuple);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CustomDecorator } from '@nestjs/common';
|
|
2
|
-
import { Reflector } from '@nestjs/core';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
1
|
+
import type { CustomDecorator } from '@nestjs/common';
|
|
2
|
+
import type { Reflector } from '@nestjs/core';
|
|
3
|
+
export type GetGuardingRelationTuple = (reflector: Reflector, handler: Parameters<Reflector['get']>[1]) => ReplaceGenerator | string;
|
|
4
|
+
export type ReplaceGenerator = (value: string) => string;
|
|
5
|
+
export type GuardedByKetoFunction = (relationTuple: ReplaceGenerator | string) => CustomDecorator<symbol>;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './guarded-by-keto.decorator';
|
|
2
|
-
export { GuardedByKetoFunction } from './guarded-by-keto.interfaces';
|
|
3
|
-
export { GetGuardingRelationTuple } from './guarded-by-keto.interfaces';
|
|
4
|
-
export { GUARDED_BY_METADATA_KEY } from './guarded-by-keto.constants';
|
|
5
|
-
export { getGuardingRelationTuple } from './get-guarding-relation.helper';
|
|
1
|
+
export * from './guarded-by-keto.decorator.js';
|
|
2
|
+
export type { GuardedByKetoFunction } from './guarded-by-keto.interfaces.js';
|
|
3
|
+
export type { GetGuardingRelationTuple } from './guarded-by-keto.interfaces.js';
|
|
4
|
+
export { GUARDED_BY_METADATA_KEY } from './guarded-by-keto.constants.js';
|
|
5
|
+
export { getGuardingRelationTuple } from './get-guarding-relation.helper.js';
|
package/dist/decorators/index.js
CHANGED
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.getGuardingRelationTuple = exports.GUARDED_BY_METADATA_KEY = void 0;
|
|
18
|
-
__exportStar(require("./guarded-by-keto.decorator"), exports);
|
|
19
|
-
var guarded_by_keto_constants_1 = require("./guarded-by-keto.constants");
|
|
20
|
-
Object.defineProperty(exports, "GUARDED_BY_METADATA_KEY", { enumerable: true, get: function () { return guarded_by_keto_constants_1.GUARDED_BY_METADATA_KEY; } });
|
|
21
|
-
var get_guarding_relation_helper_1 = require("./get-guarding-relation.helper");
|
|
22
|
-
Object.defineProperty(exports, "getGuardingRelationTuple", { enumerable: true, get: function () { return get_guarding_relation_helper_1.getGuardingRelationTuple; } });
|
|
1
|
+
export * from "./guarded-by-keto.decorator.js";
|
|
2
|
+
export { GUARDED_BY_METADATA_KEY } from "./guarded-by-keto.constants.js";
|
|
3
|
+
export { getGuardingRelationTuple } from "./get-guarding-relation.helper.js";
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.KetoExceptionMessage = void 0;
|
|
4
|
-
var KetoExceptionMessage;
|
|
1
|
+
export var KetoExceptionMessage;
|
|
5
2
|
(function (KetoExceptionMessage) {
|
|
6
3
|
KetoExceptionMessage["GENERAL_ERROR"] = "General Keto error";
|
|
7
4
|
KetoExceptionMessage["RELATION_TUPLE_INVALID"] = "Provided relation tuple is invalid";
|
|
8
|
-
})(KetoExceptionMessage
|
|
5
|
+
})(KetoExceptionMessage || (KetoExceptionMessage = {}));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { AssertionError } from 'assert';
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import { AssertionError } from 'node:assert';
|
|
3
3
|
export declare class KetoGeneralException extends AssertionError {
|
|
4
4
|
constructor(message: string);
|
|
5
5
|
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const assert_1 = require("assert");
|
|
5
|
-
const exception_message_constants_1 = require("./exception-message.constants");
|
|
6
|
-
class KetoGeneralException extends assert_1.AssertionError {
|
|
1
|
+
import { AssertionError } from 'node:assert';
|
|
2
|
+
import { KetoExceptionMessage } from './exception-message.constants.js';
|
|
3
|
+
export class KetoGeneralException extends AssertionError {
|
|
7
4
|
constructor(message) {
|
|
8
|
-
super({ message: `${
|
|
5
|
+
super({ message: `${KetoExceptionMessage.GENERAL_ERROR}: ${message}` });
|
|
9
6
|
}
|
|
10
7
|
}
|
|
11
|
-
exports.KetoGeneralException = KetoGeneralException;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './general.exception';
|
|
2
|
-
export * from './relation-tuple-invalid.exception';
|
|
1
|
+
export * from './general.exception.js';
|
|
2
|
+
export * from './relation-tuple-invalid.exception.js';
|
package/dist/exceptions/index.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./general.exception"), exports);
|
|
18
|
-
__exportStar(require("./relation-tuple-invalid.exception"), exports);
|
|
1
|
+
export * from "./general.exception.js";
|
|
2
|
+
export * from "./relation-tuple-invalid.exception.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { AssertionError } from 'assert';
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import { AssertionError } from 'node:assert';
|
|
3
3
|
export declare class KetoRelationTupleInvalidException extends AssertionError {
|
|
4
4
|
constructor();
|
|
5
5
|
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const assert_1 = require("assert");
|
|
5
|
-
const exception_message_constants_1 = require("./exception-message.constants");
|
|
6
|
-
class KetoRelationTupleInvalidException extends assert_1.AssertionError {
|
|
1
|
+
import { AssertionError } from 'node:assert';
|
|
2
|
+
import { KetoExceptionMessage } from './exception-message.constants.js';
|
|
3
|
+
export class KetoRelationTupleInvalidException extends AssertionError {
|
|
7
4
|
constructor() {
|
|
8
|
-
super({ message: `${
|
|
5
|
+
super({ message: `${KetoExceptionMessage.RELATION_TUPLE_INVALID}` });
|
|
9
6
|
}
|
|
10
7
|
}
|
|
11
|
-
exports.KetoRelationTupleInvalidException = KetoRelationTupleInvalidException;
|
package/dist/guards/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './keto.guard';
|
|
1
|
+
export * from './keto.guard.js';
|
package/dist/guards/index.js
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./keto.guard"), exports);
|
|
1
|
+
export * from "./keto.guard.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ExecutionContext } from '@nestjs/common';
|
|
2
|
-
import { CanActivate } from '@nestjs/common';
|
|
1
|
+
import type { ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import type { CanActivate } from '@nestjs/common';
|
|
3
3
|
import { Reflector } from '@nestjs/core';
|
|
4
|
-
import { KetoReadClientService } from '../services';
|
|
4
|
+
import { KetoReadClientService } from '../services/index.js';
|
|
5
5
|
export declare class KetoGuard implements CanActivate {
|
|
6
6
|
private readonly reflector;
|
|
7
7
|
private readonly ketoReadClient;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -11,18 +10,18 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
10
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
11
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
12
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const utils_1 = require("../utils");
|
|
24
|
-
const decorators_1 = require("../decorators");
|
|
13
|
+
import { Inject } from '@nestjs/common';
|
|
14
|
+
import { Injectable } from '@nestjs/common';
|
|
15
|
+
import { Reflector } from '@nestjs/core';
|
|
16
|
+
import { GqlExecutionContext } from '@nestjs/graphql';
|
|
17
|
+
import { KetoGeneralException } from '../exceptions/index.js';
|
|
18
|
+
import { KETO_READ_CLIENT } from '../module/index.js';
|
|
19
|
+
import { KetoReadClientService } from '../services/index.js';
|
|
20
|
+
import { RelationTupleConverter } from '../utils/index.js';
|
|
21
|
+
import { getGuardingRelationTuple } from '../decorators/index.js';
|
|
25
22
|
let KetoGuard = class KetoGuard {
|
|
23
|
+
reflector;
|
|
24
|
+
ketoReadClient;
|
|
26
25
|
constructor(reflector, ketoReadClient) {
|
|
27
26
|
this.reflector = reflector;
|
|
28
27
|
this.ketoReadClient = ketoReadClient;
|
|
@@ -32,15 +31,15 @@ let KetoGuard = class KetoGuard {
|
|
|
32
31
|
const userId = this.getUserId(context);
|
|
33
32
|
if (!userId)
|
|
34
33
|
return false;
|
|
35
|
-
const relationTuple =
|
|
34
|
+
const relationTuple = getGuardingRelationTuple(this.reflector, context.getHandler());
|
|
36
35
|
if (relationTuple === null)
|
|
37
36
|
return false;
|
|
38
|
-
const converter = new
|
|
37
|
+
const converter = new RelationTupleConverter(relationTuple, userId);
|
|
39
38
|
const tuple = converter.run();
|
|
40
39
|
return await this.ketoReadClient.validateRelationTuple(tuple);
|
|
41
40
|
}
|
|
42
41
|
catch (err) {
|
|
43
|
-
throw new
|
|
42
|
+
throw new KetoGeneralException(err.toString());
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
45
|
getUserId(ctx) {
|
|
@@ -48,7 +47,7 @@ let KetoGuard = class KetoGuard {
|
|
|
48
47
|
let metadata;
|
|
49
48
|
switch (contextType) {
|
|
50
49
|
case 'graphql':
|
|
51
|
-
metadata =
|
|
50
|
+
metadata = GqlExecutionContext.create(ctx).getContext();
|
|
52
51
|
return metadata.user;
|
|
53
52
|
default:
|
|
54
53
|
metadata = ctx.switchToHttp().getRequest();
|
|
@@ -57,9 +56,9 @@ let KetoGuard = class KetoGuard {
|
|
|
57
56
|
}
|
|
58
57
|
};
|
|
59
58
|
KetoGuard = __decorate([
|
|
60
|
-
|
|
61
|
-
__param(1,
|
|
62
|
-
__metadata("design:paramtypes", [
|
|
63
|
-
|
|
59
|
+
Injectable(),
|
|
60
|
+
__param(1, Inject(KETO_READ_CLIENT)),
|
|
61
|
+
__metadata("design:paramtypes", [Reflector,
|
|
62
|
+
KetoReadClientService])
|
|
64
63
|
], KetoGuard);
|
|
65
|
-
|
|
64
|
+
export { KetoGuard };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './module';
|
|
1
|
+
export * from './module/index.js';
|
|
2
2
|
export * from '@ory/keto-client';
|
|
3
|
-
export * from './guards';
|
|
4
|
-
export * from './decorators';
|
|
5
|
-
export * from './utils';
|
|
3
|
+
export * from './guards/index.js';
|
|
4
|
+
export * from './decorators/index.js';
|
|
5
|
+
export * from './utils/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./module"), exports);
|
|
18
|
-
__exportStar(require("@ory/keto-client"), exports);
|
|
19
|
-
__exportStar(require("./guards"), exports);
|
|
20
|
-
__exportStar(require("./decorators"), exports);
|
|
21
|
-
__exportStar(require("./utils"), exports);
|
|
1
|
+
export * from "./module/index.js";
|
|
2
|
+
export * from "@ory/keto-client";
|
|
3
|
+
export * from "./guards/index.js";
|
|
4
|
+
export * from "./decorators/index.js";
|
|
5
|
+
export * from "./utils/index.js";
|
package/dist/module/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './keto.module';
|
|
2
|
-
export * from './keto.constants';
|
|
3
|
-
export * from './keto-module.interfaces';
|
|
1
|
+
export * from './keto.module.js';
|
|
2
|
+
export * from './keto.constants.js';
|
|
3
|
+
export * from './keto-module.interfaces.js';
|
package/dist/module/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./keto.module"), exports);
|
|
18
|
-
__exportStar(require("./keto.constants"), exports);
|
|
19
|
-
__exportStar(require("./keto-module.interfaces"), exports);
|
|
1
|
+
export * from "./keto.module.js";
|
|
2
|
+
export * from "./keto.constants.js";
|
|
3
|
+
export * from "./keto-module.interfaces.js";
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { Type } from '@nestjs/common/interfaces';
|
|
2
|
-
import { ModuleMetadata } from '@nestjs/common/interfaces';
|
|
3
|
-
import { ConfigurationParameters } from '@ory/keto-client';
|
|
4
|
-
import { SubjectSet } from '@ory/keto-client';
|
|
1
|
+
import type { Type } from '@nestjs/common/interfaces';
|
|
2
|
+
import type { ModuleMetadata } from '@nestjs/common/interfaces';
|
|
3
|
+
import type { ConfigurationParameters } from '@ory/keto-client';
|
|
4
|
+
import type { SubjectSet } from '@ory/keto-client';
|
|
5
5
|
export interface KetoModuleOptions extends ConfigurationParameters {
|
|
6
6
|
global?: boolean;
|
|
7
7
|
}
|
|
8
8
|
export interface KetoOptionsFactory {
|
|
9
|
-
createKetoOptions()
|
|
9
|
+
createKetoOptions: () => KetoModuleOptions | Promise<KetoModuleOptions>;
|
|
10
10
|
}
|
|
11
11
|
export interface KetoModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
12
12
|
useExisting?: Type<KetoOptionsFactory>;
|
|
13
13
|
useClass?: Type<KetoOptionsFactory>;
|
|
14
|
-
useFactory?: (...args: any
|
|
15
|
-
inject?: any
|
|
14
|
+
useFactory?: (...args: Array<any>) => KetoModuleOptions | Promise<KetoModuleOptions>;
|
|
15
|
+
inject?: Array<any>;
|
|
16
16
|
global?: boolean;
|
|
17
17
|
}
|
|
18
|
-
export
|
|
19
|
-
export
|
|
18
|
+
export type RelationShipTuple = RelationShipTupleWithId | RelationShipTupleWithSet;
|
|
19
|
+
export type RelationShipTupleWithId = {
|
|
20
20
|
namespace: string;
|
|
21
21
|
object: string;
|
|
22
22
|
relation: string;
|
|
23
23
|
subject_id: string;
|
|
24
24
|
};
|
|
25
|
-
export
|
|
25
|
+
export type RelationShipTupleWithSet = {
|
|
26
26
|
namespace: string;
|
|
27
27
|
object: string;
|
|
28
28
|
relation: string;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.KETO_PERMISSIONS = 'KETO_PERMISSIONS';
|
|
7
|
-
exports.KETO_WRITE_CLIENT = 'KETO_WRITE_CLIENT';
|
|
8
|
-
exports.KETO_RELATIONS = 'KETO_RELATIONS';
|
|
1
|
+
export const KETO_MODULE_CONFIGURATION = 'KETO_MODULE_CONFIGURATION';
|
|
2
|
+
export const KETO_READ_CLIENT = 'KETO_READ_CLIENT';
|
|
3
|
+
export const KETO_PERMISSIONS = 'KETO_PERMISSIONS';
|
|
4
|
+
export const KETO_WRITE_CLIENT = 'KETO_WRITE_CLIENT';
|
|
5
|
+
export const KETO_RELATIONS = 'KETO_RELATIONS';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DynamicModule } from '@nestjs/common';
|
|
2
|
-
import { KetoModuleAsyncOptions } from './keto-module.interfaces';
|
|
3
|
-
import { KetoModuleOptions } from './keto-module.interfaces';
|
|
1
|
+
import type { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import type { KetoModuleAsyncOptions } from './keto-module.interfaces.js';
|
|
3
|
+
import type { KetoModuleOptions } from './keto-module.interfaces.js';
|
|
4
4
|
export declare class KetoModule {
|
|
5
5
|
static register(options: KetoModuleOptions): DynamicModule;
|
|
6
6
|
static registerAsync(options: KetoModuleAsyncOptions): DynamicModule;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -6,16 +5,14 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
6
|
};
|
|
8
7
|
var KetoModule_1;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const keto_providers_1 = require("./keto.providers");
|
|
14
|
-
const keto_providers_2 = require("./keto.providers");
|
|
8
|
+
import { Module } from '@nestjs/common';
|
|
9
|
+
import { KETO_MODULE_CONFIGURATION } from './keto.constants.js';
|
|
10
|
+
import { createKetoExportsProvider } from './keto.providers.js';
|
|
11
|
+
import { createKetoConfigurationProvider } from './keto.providers.js';
|
|
15
12
|
let KetoModule = KetoModule_1 = class KetoModule {
|
|
16
13
|
static register(options) {
|
|
17
|
-
const optionsProvider =
|
|
18
|
-
const exportsProvider =
|
|
14
|
+
const optionsProvider = createKetoConfigurationProvider(options);
|
|
15
|
+
const exportsProvider = createKetoExportsProvider();
|
|
19
16
|
return {
|
|
20
17
|
global: options?.global ?? true,
|
|
21
18
|
module: KetoModule_1,
|
|
@@ -24,7 +21,7 @@ let KetoModule = KetoModule_1 = class KetoModule {
|
|
|
24
21
|
};
|
|
25
22
|
}
|
|
26
23
|
static registerAsync(options) {
|
|
27
|
-
const exportsProvider =
|
|
24
|
+
const exportsProvider = createKetoExportsProvider();
|
|
28
25
|
return {
|
|
29
26
|
global: options?.global ?? true,
|
|
30
27
|
module: KetoModule_1,
|
|
@@ -48,19 +45,19 @@ let KetoModule = KetoModule_1 = class KetoModule {
|
|
|
48
45
|
static createAsyncOptionsProvider(options) {
|
|
49
46
|
if (options.useFactory) {
|
|
50
47
|
return {
|
|
51
|
-
provide:
|
|
48
|
+
provide: KETO_MODULE_CONFIGURATION,
|
|
52
49
|
useFactory: options.useFactory,
|
|
53
50
|
inject: options.inject || [],
|
|
54
51
|
};
|
|
55
52
|
}
|
|
56
53
|
return {
|
|
57
|
-
provide:
|
|
58
|
-
useFactory: (optionsFactory) => optionsFactory.createKetoOptions(),
|
|
54
|
+
provide: KETO_MODULE_CONFIGURATION,
|
|
55
|
+
useFactory: async (optionsFactory) => optionsFactory.createKetoOptions(),
|
|
59
56
|
inject: [options.useExisting || options.useClass],
|
|
60
57
|
};
|
|
61
58
|
}
|
|
62
59
|
};
|
|
63
60
|
KetoModule = KetoModule_1 = __decorate([
|
|
64
|
-
|
|
61
|
+
Module({})
|
|
65
62
|
], KetoModule);
|
|
66
|
-
|
|
63
|
+
export { KetoModule };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Provider } from '@nestjs/common';
|
|
2
|
-
import { KetoModuleOptions } from './keto-module.interfaces';
|
|
3
|
-
export declare const createKetoConfigurationProvider: (options: KetoModuleOptions) => Provider
|
|
4
|
-
export declare const createKetoExportsProvider: () => Provider
|
|
1
|
+
import type { Provider } from '@nestjs/common';
|
|
2
|
+
import type { KetoModuleOptions } from './keto-module.interfaces.js';
|
|
3
|
+
export declare const createKetoConfigurationProvider: (options: KetoModuleOptions) => Array<Provider>;
|
|
4
|
+
export declare const createKetoExportsProvider: () => Array<Provider>;
|
|
@@ -1,43 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const keto_constants_4 = require("./keto.constants");
|
|
13
|
-
const keto_constants_5 = require("./keto.constants");
|
|
14
|
-
const createKetoConfigurationProvider = (options) => [
|
|
1
|
+
import { KetoConfigurationService } from '../services/index.js';
|
|
2
|
+
import { KetoPermissionsService } from '../services/index.js';
|
|
3
|
+
import { KetoWriteClientService } from '../services/index.js';
|
|
4
|
+
import { KetoReadClientService } from '../services/index.js';
|
|
5
|
+
import { KetoRelationsService } from '../services/index.js';
|
|
6
|
+
import { KETO_RELATIONS } from './keto.constants.js';
|
|
7
|
+
import { KETO_PERMISSIONS } from './keto.constants.js';
|
|
8
|
+
import { KETO_WRITE_CLIENT } from './keto.constants.js';
|
|
9
|
+
import { KETO_READ_CLIENT } from './keto.constants.js';
|
|
10
|
+
import { KETO_MODULE_CONFIGURATION } from './keto.constants.js';
|
|
11
|
+
export const createKetoConfigurationProvider = (options) => [
|
|
15
12
|
{
|
|
16
|
-
provide:
|
|
17
|
-
useFactory: () => new
|
|
13
|
+
provide: KETO_MODULE_CONFIGURATION,
|
|
14
|
+
useFactory: () => new KetoConfigurationService(options),
|
|
18
15
|
},
|
|
19
16
|
];
|
|
20
|
-
|
|
21
|
-
const createKetoExportsProvider = () => [
|
|
17
|
+
export const createKetoExportsProvider = () => [
|
|
22
18
|
{
|
|
23
|
-
provide:
|
|
24
|
-
useFactory: (options) => new
|
|
25
|
-
inject: [
|
|
19
|
+
provide: KETO_PERMISSIONS,
|
|
20
|
+
useFactory: (options) => new KetoPermissionsService(options),
|
|
21
|
+
inject: [KETO_MODULE_CONFIGURATION],
|
|
26
22
|
},
|
|
27
23
|
{
|
|
28
|
-
provide:
|
|
29
|
-
useFactory: (options) => new
|
|
30
|
-
inject: [
|
|
24
|
+
provide: KETO_RELATIONS,
|
|
25
|
+
useFactory: (options) => new KetoRelationsService(options),
|
|
26
|
+
inject: [KETO_MODULE_CONFIGURATION],
|
|
31
27
|
},
|
|
32
28
|
{
|
|
33
|
-
provide:
|
|
34
|
-
useFactory: (permissionsService) => new
|
|
35
|
-
inject: [
|
|
29
|
+
provide: KETO_READ_CLIENT,
|
|
30
|
+
useFactory: (permissionsService) => new KetoReadClientService(permissionsService),
|
|
31
|
+
inject: [KETO_PERMISSIONS],
|
|
36
32
|
},
|
|
37
33
|
{
|
|
38
|
-
provide:
|
|
39
|
-
useFactory: (relationshipsService) => new
|
|
40
|
-
inject: [
|
|
34
|
+
provide: KETO_WRITE_CLIENT,
|
|
35
|
+
useFactory: (relationshipsService) => new KetoWriteClientService(relationshipsService),
|
|
36
|
+
inject: [KETO_RELATIONS],
|
|
41
37
|
},
|
|
42
38
|
];
|
|
43
|
-
exports.createKetoExportsProvider = createKetoExportsProvider;
|
package/dist/services/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './keto-read-client.service';
|
|
2
|
-
export * from './keto-write-client.service';
|
|
3
|
-
export * from './keto-configuration.service';
|
|
4
|
-
export * from './keto-permissions.service';
|
|
5
|
-
export * from './keto-relations.service';
|
|
1
|
+
export * from './keto-read-client.service.js';
|
|
2
|
+
export * from './keto-write-client.service.js';
|
|
3
|
+
export * from './keto-configuration.service.js';
|
|
4
|
+
export * from './keto-permissions.service.js';
|
|
5
|
+
export * from './keto-relations.service.js';
|
package/dist/services/index.js
CHANGED
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./keto-read-client.service"), exports);
|
|
18
|
-
__exportStar(require("./keto-write-client.service"), exports);
|
|
19
|
-
__exportStar(require("./keto-configuration.service"), exports);
|
|
20
|
-
__exportStar(require("./keto-permissions.service"), exports);
|
|
21
|
-
__exportStar(require("./keto-relations.service"), exports);
|
|
1
|
+
export * from "./keto-read-client.service.js";
|
|
2
|
+
export * from "./keto-write-client.service.js";
|
|
3
|
+
export * from "./keto-configuration.service.js";
|
|
4
|
+
export * from "./keto-permissions.service.js";
|
|
5
|
+
export * from "./keto-relations.service.js";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -11,21 +10,20 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
10
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
11
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
12
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
let KetoConfigurationService = class KetoConfigurationService extends keto_client_1.Configuration {
|
|
13
|
+
import { Inject } from '@nestjs/common';
|
|
14
|
+
import { Injectable } from '@nestjs/common';
|
|
15
|
+
import { Configuration } from '@ory/keto-client';
|
|
16
|
+
import { KETO_MODULE_CONFIGURATION } from '../module/index.js';
|
|
17
|
+
let KetoConfigurationService = class KetoConfigurationService extends Configuration {
|
|
18
|
+
options;
|
|
21
19
|
constructor(options) {
|
|
22
20
|
super(options);
|
|
23
21
|
this.options = options;
|
|
24
22
|
}
|
|
25
23
|
};
|
|
26
24
|
KetoConfigurationService = __decorate([
|
|
27
|
-
|
|
28
|
-
__param(0,
|
|
25
|
+
Injectable(),
|
|
26
|
+
__param(0, Inject(KETO_MODULE_CONFIGURATION)),
|
|
29
27
|
__metadata("design:paramtypes", [Object])
|
|
30
28
|
], KetoConfigurationService);
|
|
31
|
-
|
|
29
|
+
export { KetoConfigurationService };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PermissionApi } from '@ory/keto-client';
|
|
2
|
-
import { KetoConfigurationService } from './keto-configuration.service';
|
|
2
|
+
import { KetoConfigurationService } from './keto-configuration.service.js';
|
|
3
3
|
export declare class KetoPermissionsService extends PermissionApi {
|
|
4
4
|
readonly configuration: KetoConfigurationService;
|
|
5
5
|
constructor(configuration: KetoConfigurationService);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -11,22 +10,21 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
10
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
11
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
12
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
let KetoPermissionsService = class KetoPermissionsService extends keto_client_1.PermissionApi {
|
|
13
|
+
import { Inject } from '@nestjs/common';
|
|
14
|
+
import { Injectable } from '@nestjs/common';
|
|
15
|
+
import { PermissionApi } from '@ory/keto-client';
|
|
16
|
+
import { KETO_MODULE_CONFIGURATION } from '../module/index.js';
|
|
17
|
+
import { KetoConfigurationService } from './keto-configuration.service.js';
|
|
18
|
+
let KetoPermissionsService = class KetoPermissionsService extends PermissionApi {
|
|
19
|
+
configuration;
|
|
22
20
|
constructor(configuration) {
|
|
23
21
|
super(configuration);
|
|
24
22
|
this.configuration = configuration;
|
|
25
23
|
}
|
|
26
24
|
};
|
|
27
25
|
KetoPermissionsService = __decorate([
|
|
28
|
-
|
|
29
|
-
__param(0,
|
|
30
|
-
__metadata("design:paramtypes", [
|
|
26
|
+
Injectable(),
|
|
27
|
+
__param(0, Inject(KETO_MODULE_CONFIGURATION)),
|
|
28
|
+
__metadata("design:paramtypes", [KetoConfigurationService])
|
|
31
29
|
], KetoPermissionsService);
|
|
32
|
-
|
|
30
|
+
export { KetoPermissionsService };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RelationShipTuple } from '../module';
|
|
2
|
-
import { KetoPermissionsService } from './keto-permissions.service';
|
|
1
|
+
import type { RelationShipTuple } from '../module/index.js';
|
|
2
|
+
import { KetoPermissionsService } from './keto-permissions.service.js';
|
|
3
3
|
export declare class KetoReadClientService {
|
|
4
4
|
private readonly permissionService;
|
|
5
5
|
constructor(permissionService: KetoPermissionsService);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -11,14 +10,13 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
10
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
11
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
12
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const module_1 = require("../module");
|
|
20
|
-
const keto_permissions_service_1 = require("./keto-permissions.service");
|
|
13
|
+
import { Inject } from '@nestjs/common';
|
|
14
|
+
import { Injectable } from '@nestjs/common';
|
|
15
|
+
import { KetoGeneralException } from '../exceptions/index.js';
|
|
16
|
+
import { KETO_PERMISSIONS } from '../module/index.js';
|
|
17
|
+
import { KetoPermissionsService } from './keto-permissions.service.js';
|
|
21
18
|
let KetoReadClientService = class KetoReadClientService {
|
|
19
|
+
permissionService;
|
|
22
20
|
constructor(permissionService) {
|
|
23
21
|
this.permissionService = permissionService;
|
|
24
22
|
}
|
|
@@ -49,13 +47,13 @@ let KetoReadClientService = class KetoReadClientService {
|
|
|
49
47
|
return response.data.allowed;
|
|
50
48
|
}
|
|
51
49
|
catch (error) {
|
|
52
|
-
throw new
|
|
50
|
+
throw new KetoGeneralException(error.toString());
|
|
53
51
|
}
|
|
54
52
|
}
|
|
55
53
|
};
|
|
56
54
|
KetoReadClientService = __decorate([
|
|
57
|
-
|
|
58
|
-
__param(0,
|
|
59
|
-
__metadata("design:paramtypes", [
|
|
55
|
+
Injectable(),
|
|
56
|
+
__param(0, Inject(KETO_PERMISSIONS)),
|
|
57
|
+
__metadata("design:paramtypes", [KetoPermissionsService])
|
|
60
58
|
], KetoReadClientService);
|
|
61
|
-
|
|
59
|
+
export { KetoReadClientService };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -11,22 +10,21 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
10
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
11
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
12
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
let KetoRelationsService = class KetoRelationsService extends keto_client_1.RelationshipApi {
|
|
13
|
+
import { Inject } from '@nestjs/common';
|
|
14
|
+
import { Injectable } from '@nestjs/common';
|
|
15
|
+
import { RelationshipApi } from '@ory/keto-client';
|
|
16
|
+
import { Configuration } from '@ory/keto-client';
|
|
17
|
+
import { KETO_MODULE_CONFIGURATION } from '../module/index.js';
|
|
18
|
+
let KetoRelationsService = class KetoRelationsService extends RelationshipApi {
|
|
19
|
+
options;
|
|
22
20
|
constructor(options) {
|
|
23
21
|
super(options);
|
|
24
22
|
this.options = options;
|
|
25
23
|
}
|
|
26
24
|
};
|
|
27
25
|
KetoRelationsService = __decorate([
|
|
28
|
-
|
|
29
|
-
__param(0,
|
|
30
|
-
__metadata("design:paramtypes", [
|
|
26
|
+
Injectable(),
|
|
27
|
+
__param(0, Inject(KETO_MODULE_CONFIGURATION)),
|
|
28
|
+
__metadata("design:paramtypes", [Configuration])
|
|
31
29
|
], KetoRelationsService);
|
|
32
|
-
|
|
30
|
+
export { KetoRelationsService };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { RelationshipPatchActionEnum } from '@ory/keto-client';
|
|
2
|
-
import { Relationship } from '@ory/keto-client';
|
|
3
|
-
import { RelationShipTuple } from '../module';
|
|
4
|
-
import { KetoRelationsService } from './keto-relations.service';
|
|
1
|
+
import type { RelationshipPatchActionEnum } from '@ory/keto-client';
|
|
2
|
+
import type { Relationship } from '@ory/keto-client';
|
|
3
|
+
import type { RelationShipTuple } from '../module/index.js';
|
|
4
|
+
import { KetoRelationsService } from './keto-relations.service.js';
|
|
5
5
|
export declare class KetoWriteClientService {
|
|
6
6
|
private readonly relationsService;
|
|
7
7
|
constructor(relationsService: KetoRelationsService);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -11,14 +10,13 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
10
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
11
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
12
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const module_1 = require("../module");
|
|
20
|
-
const keto_relations_service_1 = require("./keto-relations.service");
|
|
13
|
+
import { Inject } from '@nestjs/common';
|
|
14
|
+
import { Injectable } from '@nestjs/common';
|
|
15
|
+
import { KetoGeneralException } from '../exceptions/index.js';
|
|
16
|
+
import { KETO_RELATIONS } from '../module/index.js';
|
|
17
|
+
import { KetoRelationsService } from './keto-relations.service.js';
|
|
21
18
|
let KetoWriteClientService = class KetoWriteClientService {
|
|
19
|
+
relationsService;
|
|
22
20
|
constructor(relationsService) {
|
|
23
21
|
this.relationsService = relationsService;
|
|
24
22
|
}
|
|
@@ -31,7 +29,7 @@ let KetoWriteClientService = class KetoWriteClientService {
|
|
|
31
29
|
return response.data;
|
|
32
30
|
}
|
|
33
31
|
catch (error) {
|
|
34
|
-
throw new
|
|
32
|
+
throw new KetoGeneralException(error.toString());
|
|
35
33
|
}
|
|
36
34
|
}
|
|
37
35
|
async removeRelationTuple(tuple) {
|
|
@@ -41,7 +39,7 @@ let KetoWriteClientService = class KetoWriteClientService {
|
|
|
41
39
|
return true;
|
|
42
40
|
}
|
|
43
41
|
catch (error) {
|
|
44
|
-
throw new
|
|
42
|
+
throw new KetoGeneralException(error.toString());
|
|
45
43
|
}
|
|
46
44
|
}
|
|
47
45
|
async patchRelationTuple(tuple, action) {
|
|
@@ -58,13 +56,13 @@ let KetoWriteClientService = class KetoWriteClientService {
|
|
|
58
56
|
return true;
|
|
59
57
|
}
|
|
60
58
|
catch (error) {
|
|
61
|
-
throw new
|
|
59
|
+
throw new KetoGeneralException(error.toString());
|
|
62
60
|
}
|
|
63
61
|
}
|
|
64
62
|
};
|
|
65
63
|
KetoWriteClientService = __decorate([
|
|
66
|
-
|
|
67
|
-
__param(0,
|
|
68
|
-
__metadata("design:paramtypes", [
|
|
64
|
+
Injectable(),
|
|
65
|
+
__param(0, Inject(KETO_RELATIONS)),
|
|
66
|
+
__metadata("design:paramtypes", [KetoRelationsService])
|
|
69
67
|
], KetoWriteClientService);
|
|
70
|
-
|
|
68
|
+
export { KetoWriteClientService };
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './relation-tuple-converter';
|
|
1
|
+
export * from './relation-tuple-converter.js';
|
package/dist/utils/index.js
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./relation-tuple-converter"), exports);
|
|
1
|
+
export * from "./relation-tuple-converter.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RelationShipTuple } from '../module';
|
|
2
|
-
|
|
1
|
+
import type { RelationShipTuple } from '../module/index.js';
|
|
2
|
+
type Tuple = string | ((...args: Array<string>) => string);
|
|
3
3
|
export declare class RelationTupleConverter {
|
|
4
4
|
private readonly tuple;
|
|
5
5
|
private readonly replacement;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { KetoRelationTupleInvalidException } from '../exceptions/index.js';
|
|
2
|
+
export class RelationTupleConverter {
|
|
3
|
+
tuple;
|
|
4
|
+
replacement;
|
|
5
|
+
tupleString;
|
|
6
|
+
result;
|
|
6
7
|
constructor(tuple, replacement = '') {
|
|
7
8
|
this.tuple = tuple;
|
|
8
9
|
this.replacement = replacement;
|
|
@@ -13,7 +14,7 @@ class RelationTupleConverter {
|
|
|
13
14
|
}
|
|
14
15
|
run() {
|
|
15
16
|
if (!this.isTupleCorrect()) {
|
|
16
|
-
throw new
|
|
17
|
+
throw new KetoRelationTupleInvalidException();
|
|
17
18
|
}
|
|
18
19
|
const namespace = this.getNamespace();
|
|
19
20
|
const object = this.getObject();
|
|
@@ -85,4 +86,3 @@ class RelationTupleConverter {
|
|
|
85
86
|
return this.tupleString.includes(':') || this.tupleString.includes('#');
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
|
-
exports.RelationTupleConverter = RelationTupleConverter;
|
package/package.json
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atls/nestjs-keto",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"license": "BSD-3-Clause",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
"./package.json": "./package.json",
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
5
14
|
"main": "dist/index.js",
|
|
6
15
|
"files": [
|
|
7
16
|
"dist"
|
|
@@ -15,32 +24,42 @@
|
|
|
15
24
|
"@ory/keto-client": "0.11.0-alpha.0"
|
|
16
25
|
},
|
|
17
26
|
"devDependencies": {
|
|
18
|
-
"@
|
|
19
|
-
"@nestjs/
|
|
20
|
-
"@nestjs/
|
|
21
|
-
"@nestjs/
|
|
22
|
-
"@
|
|
23
|
-
"@types/
|
|
27
|
+
"@jest/globals": "29.7.0",
|
|
28
|
+
"@nestjs/common": "10.4.1",
|
|
29
|
+
"@nestjs/core": "10.4.1",
|
|
30
|
+
"@nestjs/graphql": "12.2.0",
|
|
31
|
+
"@nestjs/testing": "10.4.1",
|
|
32
|
+
"@types/node": "22.5.5",
|
|
33
|
+
"@types/supertest": "6.0.2",
|
|
24
34
|
"apollo-server-core": "3.3.0",
|
|
25
|
-
"get-port": "
|
|
26
|
-
"graphql": "16.
|
|
27
|
-
"reflect-metadata": "0.2.
|
|
35
|
+
"get-port": "7.1.0",
|
|
36
|
+
"graphql": "16.9.0",
|
|
37
|
+
"reflect-metadata": "0.2.2",
|
|
28
38
|
"rimraf": "3.0.2",
|
|
29
39
|
"rxjs": "7.8.1",
|
|
30
|
-
"supertest": "6.3.
|
|
31
|
-
"testcontainers": "10.
|
|
40
|
+
"supertest": "6.3.4",
|
|
41
|
+
"testcontainers": "10.13.1",
|
|
32
42
|
"ts-morph": "21.0.1",
|
|
33
|
-
"typescript": "4.
|
|
43
|
+
"typescript": "5.4.2"
|
|
34
44
|
},
|
|
35
45
|
"peerDependencies": {
|
|
36
|
-
"@nestjs/common": "
|
|
37
|
-
"@nestjs/core": "
|
|
38
|
-
"reflect-metadata": "
|
|
39
|
-
"rxjs": "
|
|
46
|
+
"@nestjs/common": "10",
|
|
47
|
+
"@nestjs/core": "10",
|
|
48
|
+
"reflect-metadata": "0.2",
|
|
49
|
+
"rxjs": "7"
|
|
40
50
|
},
|
|
41
51
|
"publishConfig": {
|
|
52
|
+
"exports": {
|
|
53
|
+
"./package.json": "./package.json",
|
|
54
|
+
".": {
|
|
55
|
+
"import": "./dist/index.js",
|
|
56
|
+
"types": "./dist/index.d.ts",
|
|
57
|
+
"default": "./dist/index.js"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
42
60
|
"main": "dist/index.js",
|
|
43
61
|
"typings": "dist/index.d.ts"
|
|
44
62
|
},
|
|
63
|
+
"typecheckSkipLibCheck": true,
|
|
45
64
|
"typings": "dist/index.d.ts"
|
|
46
65
|
}
|