Skip to content

Commit

Permalink
feat: v0.4.5 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
tolgaOzen committed Jun 13, 2023
1 parent d64a73e commit 6e142f7
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 102 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@permify/permify-node",
"version": "0.3.4",
"version": "0.3.5",
"description": "permify nodejs client",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
Expand Down
25 changes: 7 additions & 18 deletions proto/base/v1/base.proto
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ message Tuple {

// Tuples
message Tuples {
repeated Tuple tuples = 1;
repeated Tuple tuples = 1 [json_name = "tuples"];
}

// Entity
Expand All @@ -155,9 +155,9 @@ message Entity {
}

message EntityAndRelation {
Entity entity = 1 [(validate.rules).message.required = true];
Entity entity = 1 [json_name = "entity", (validate.rules).message.required = true];

string relation = 2 [(validate.rules).string = {
string relation = 2 [json_name = "relation", (validate.rules).string = {
pattern : "^([a-z][a-z0-9_]{1,64}[a-z0-9])$",
max_bytes : 64,
}];
Expand Down Expand Up @@ -186,9 +186,9 @@ message Subject {

// TupleFilter is used to filter tuples
message TupleFilter {
EntityFilter entity = 1 [(validate.rules).message.required = true];
EntityFilter entity = 1 [json_name = "entity", (validate.rules).message.required = true];

string relation = 2 [(validate.rules).string = {
string relation = 2 [json_name = "relation", (validate.rules).string = {
pattern : "^([a-z][a-z0-9_]{1,62}[a-z0-9])$",
max_bytes : 64,
ignore_empty: true,
Expand All @@ -197,17 +197,6 @@ message TupleFilter {
SubjectFilter subject = 3 [json_name = "subject"];
}

// EntityAndRelationFilter is used to filter entities and relations
message EntityAndRelationFilter {
EntityFilter entity = 1 [(validate.rules).message.required = true];

string relation = 2 [(validate.rules).string = {
pattern : "^([a-z][a-z0-9_]{1,64}[a-z0-9])$",
max_bytes : 64,
ignore_empty: true,
}];
}

// EntityFilter is used to filter entities
message EntityFilter {
string type = 1 [json_name = "type"];
Expand All @@ -221,7 +210,7 @@ message SubjectFilter {

repeated string ids = 2 [json_name = "ids"];

string relation = 3 [(validate.rules).string = {
string relation = 3 [json_name = "relation", (validate.rules).string = {
pattern : "^([.&a-z][.&a-z0-9_]{1,62}[.&a-z0-9])$",
max_bytes : 64,
ignore_empty: true,
Expand Down Expand Up @@ -254,7 +243,7 @@ message Expand {

// Result
message Subjects {
repeated Subject subjects = 1;
repeated Subject subjects = 1 [json_name = "subjects"];
}

// Tenant
Expand Down
4 changes: 3 additions & 1 deletion proto/base/v1/errors.proto
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ enum ErrorCode {
ERROR_CODE_SUBJECT_RELATION_CANNOT_BE_EMPTY = 2018;
ERROR_CODE_SCHEMA_MUST_HAVE_USER_ENTITY_DEFINITION = 2019;
ERROR_CODE_UNIQUE_CONSTRAINT = 2020;
ERROR_CODE_INVALID_CONTINUOUS_TOKEN = 2021;
ERROR_CODE_INVALID_KEY = 2022;
ERROR_CODE_ENTITY_TYPE_REQUIRED = 2023;

// not found
ERROR_CODE_NOT_FOUND = 4000;
Expand All @@ -43,7 +46,6 @@ enum ErrorCode {
ERROR_CODE_RELATION_DEFINITION_NOT_FOUND = 4007;
ERROR_CODE_RECORD_NOT_FOUND = 4008;
ERROR_CODE_TENANT_NOT_FOUND = 4009;
ERROR_CODE_INVALID_CONTINUOUS_TOKEN = 4010;

// internal
ERROR_CODE_INTERNAL = 5000;
Expand Down
2 changes: 1 addition & 1 deletion proto/base/v1/openapi.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
info: {
title: "Permify API";
description: "Permify is an open-source authorization service for creating and maintaining fine-grained authorizations across your individual applications and services. Permify converts authorization data as relational tuples into a database you point at. We called that database a Write Database (WriteDB) and it behaves as a centralized data source for your authorization system. You can model of your authorization with Permify's DSL - Permify Schema - and perform access checks with a single API call anywhere on your stack. Access decisions made according to stored relational tuples.";
version: "v0.4.4";
version: "v0.4.5";
contact: {
name: "API Support";
url: "https://github.com/Permify/permify/issues";
Expand Down
16 changes: 13 additions & 3 deletions proto/base/v1/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ message PermissionCheckRequest {
}];

Subject subject = 5 [json_name = "subject", (validate.rules).message.required = true];

repeated Tuple contextual_tuples = 6 [json_name = "contextual_tuples"];
}

// PermissionCheckRequestMetadata
Expand Down Expand Up @@ -158,6 +160,8 @@ message PermissionExpandRequest {
max_bytes : 64,
ignore_empty: true,
}];

repeated Tuple contextual_tuples = 5 [json_name = "contextual_tuples"];
}

// PermissionExpandRequestMetadata
Expand Down Expand Up @@ -196,6 +200,8 @@ message PermissionLookupEntityRequest {
}];

Subject subject = 5 [json_name = "subject", (validate.rules).message.required = true];

repeated Tuple contextual_tuples = 6 [json_name = "contextual_tuples"];
}

// PermissionLookupEntityRequestMetadata
Expand Down Expand Up @@ -228,9 +234,11 @@ message PermissionEntityFilterRequest {
RelationReference entity_reference = 3 [json_name = "entity_reference"];

Subject subject = 4 [json_name = "subject"];

repeated Tuple contextual_tuples = 5 [json_name = "contextual_tuples"];
}

// PermissionLookupEntityRequestMetadata
// PermissionEntityFilterRequestMetadata
message PermissionEntityFilterRequestMetadata {
string schema_version = 1 [json_name = "schema_version"];
string snap_token = 2 [json_name = "snap_token"];
Expand All @@ -257,6 +265,8 @@ message PermissionLookupSubjectRequest {
}];

RelationReference subject_reference = 5 [json_name = "subject_reference"];

repeated Tuple contextual_tuples = 6 [json_name = "contextual_tuples"];
}

// PermissionLookupSubjectRequestMetadata
Expand Down Expand Up @@ -473,7 +483,7 @@ message RelationshipReadRequest {

RelationshipReadRequestMetadata metadata = 2 [json_name = "metadata", (validate.rules).message.required = true];

TupleFilter filter = 3 [json_name = "filter"];
TupleFilter filter = 3 [json_name = "filter", (validate.rules).message.required = true];

uint32 page_size = 4 [
json_name = "page_size",
Expand Down Expand Up @@ -502,7 +512,7 @@ message RelationshipDeleteRequest {
ignore_empty: false,
}];

TupleFilter filter = 2 [json_name = "filter"];
TupleFilter filter = 2 [json_name = "filter", (validate.rules).message.required = true];
}

// RelationshipDeleteResponse
Expand Down
66 changes: 0 additions & 66 deletions src/grpc/generated/base/v1/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,6 @@ export interface TupleFilter {
subject: SubjectFilter | undefined;
}

/** EntityAndRelationFilter is used to filter entities and relations */
export interface EntityAndRelationFilter {
entity: EntityFilter | undefined;
relation: string;
}

/** EntityFilter is used to filter entities */
export interface EntityFilter {
type: string;
Expand Down Expand Up @@ -1730,66 +1724,6 @@ export const TupleFilter = {
},
};

function createBaseEntityAndRelationFilter(): EntityAndRelationFilter {
return { entity: undefined, relation: "" };
}

export const EntityAndRelationFilter = {
encode(message: EntityAndRelationFilter, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.entity !== undefined) {
EntityFilter.encode(message.entity, writer.uint32(10).fork()).ldelim();
}
if (message.relation !== "") {
writer.uint32(18).string(message.relation);
}
return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): EntityAndRelationFilter {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseEntityAndRelationFilter();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.entity = EntityFilter.decode(reader, reader.uint32());
break;
case 2:
message.relation = reader.string();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},

fromJSON(object: any): EntityAndRelationFilter {
return {
entity: isSet(object.entity) ? EntityFilter.fromJSON(object.entity) : undefined,
relation: isSet(object.relation) ? String(object.relation) : "",
};
},

toJSON(message: EntityAndRelationFilter): unknown {
const obj: any = {};
message.entity !== undefined && (obj.entity = message.entity ? EntityFilter.toJSON(message.entity) : undefined);
message.relation !== undefined && (obj.relation = message.relation);
return obj;
},

fromPartial(object: DeepPartial<EntityAndRelationFilter>): EntityAndRelationFilter {
const message = createBaseEntityAndRelationFilter();
message.entity = (object.entity !== undefined && object.entity !== null)
? EntityFilter.fromPartial(object.entity)
: undefined;
message.relation = object.relation ?? "";
return message;
},
};

function createBaseEntityFilter(): EntityFilter {
return { type: "", ids: [] };
}
Expand Down
24 changes: 18 additions & 6 deletions src/grpc/generated/base/v1/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export enum ErrorCode {
ERROR_CODE_SUBJECT_RELATION_CANNOT_BE_EMPTY = 2018,
ERROR_CODE_SCHEMA_MUST_HAVE_USER_ENTITY_DEFINITION = 2019,
ERROR_CODE_UNIQUE_CONSTRAINT = 2020,
ERROR_CODE_INVALID_CONTINUOUS_TOKEN = 2021,
ERROR_CODE_INVALID_KEY = 2022,
ERROR_CODE_ENTITY_TYPE_REQUIRED = 2023,
/** ERROR_CODE_NOT_FOUND - not found */
ERROR_CODE_NOT_FOUND = 4000,
ERROR_CODE_ENTITY_TYPE_NOT_FOUND = 4001,
Expand All @@ -40,7 +43,6 @@ export enum ErrorCode {
ERROR_CODE_RELATION_DEFINITION_NOT_FOUND = 4007,
ERROR_CODE_RECORD_NOT_FOUND = 4008,
ERROR_CODE_TENANT_NOT_FOUND = 4009,
ERROR_CODE_INVALID_CONTINUOUS_TOKEN = 4010,
/** ERROR_CODE_INTERNAL - internal */
ERROR_CODE_INTERNAL = 5000,
ERROR_CODE_CANCELLED = 5001,
Expand Down Expand Up @@ -125,6 +127,15 @@ export function errorCodeFromJSON(object: any): ErrorCode {
case 2020:
case "ERROR_CODE_UNIQUE_CONSTRAINT":
return ErrorCode.ERROR_CODE_UNIQUE_CONSTRAINT;
case 2021:
case "ERROR_CODE_INVALID_CONTINUOUS_TOKEN":
return ErrorCode.ERROR_CODE_INVALID_CONTINUOUS_TOKEN;
case 2022:
case "ERROR_CODE_INVALID_KEY":
return ErrorCode.ERROR_CODE_INVALID_KEY;
case 2023:
case "ERROR_CODE_ENTITY_TYPE_REQUIRED":
return ErrorCode.ERROR_CODE_ENTITY_TYPE_REQUIRED;
case 4000:
case "ERROR_CODE_NOT_FOUND":
return ErrorCode.ERROR_CODE_NOT_FOUND;
Expand Down Expand Up @@ -155,9 +166,6 @@ export function errorCodeFromJSON(object: any): ErrorCode {
case 4009:
case "ERROR_CODE_TENANT_NOT_FOUND":
return ErrorCode.ERROR_CODE_TENANT_NOT_FOUND;
case 4010:
case "ERROR_CODE_INVALID_CONTINUOUS_TOKEN":
return ErrorCode.ERROR_CODE_INVALID_CONTINUOUS_TOKEN;
case 5000:
case "ERROR_CODE_INTERNAL":
return ErrorCode.ERROR_CODE_INTERNAL;
Expand Down Expand Up @@ -247,6 +255,12 @@ export function errorCodeToJSON(object: ErrorCode): string {
return "ERROR_CODE_SCHEMA_MUST_HAVE_USER_ENTITY_DEFINITION";
case ErrorCode.ERROR_CODE_UNIQUE_CONSTRAINT:
return "ERROR_CODE_UNIQUE_CONSTRAINT";
case ErrorCode.ERROR_CODE_INVALID_CONTINUOUS_TOKEN:
return "ERROR_CODE_INVALID_CONTINUOUS_TOKEN";
case ErrorCode.ERROR_CODE_INVALID_KEY:
return "ERROR_CODE_INVALID_KEY";
case ErrorCode.ERROR_CODE_ENTITY_TYPE_REQUIRED:
return "ERROR_CODE_ENTITY_TYPE_REQUIRED";
case ErrorCode.ERROR_CODE_NOT_FOUND:
return "ERROR_CODE_NOT_FOUND";
case ErrorCode.ERROR_CODE_ENTITY_TYPE_NOT_FOUND:
Expand All @@ -267,8 +281,6 @@ export function errorCodeToJSON(object: ErrorCode): string {
return "ERROR_CODE_RECORD_NOT_FOUND";
case ErrorCode.ERROR_CODE_TENANT_NOT_FOUND:
return "ERROR_CODE_TENANT_NOT_FOUND";
case ErrorCode.ERROR_CODE_INVALID_CONTINUOUS_TOKEN:
return "ERROR_CODE_INVALID_CONTINUOUS_TOKEN";
case ErrorCode.ERROR_CODE_INTERNAL:
return "ERROR_CODE_INTERNAL";
case ErrorCode.ERROR_CODE_CANCELLED:
Expand Down
Loading

0 comments on commit 6e142f7

Please sign in to comment.