Skip to content
Draft
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:iron
FROM node:jod

ARG BUILDING_SERVICE

Expand Down
8 changes: 7 additions & 1 deletion libraries/grpc-sdk/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ for FILE in ./*.ts; do
if [ "$FILENAME" != "index.ts" ]; then
# Remove the file extension and create an export statement
BASENAME="${FILENAME%.ts}"
EXPORT_STATEMENT="export * from './$BASENAME.js';"

# Replace underscores with dashes for consistent word separation
BASENAME_WITH_DASHES=$(echo "$BASENAME" | tr '_' '-')
# Convert the BASENAME to PascalCase
PASCALCASE_BASENAME=$(echo "$BASENAME_WITH_DASHES" | awk -F'-' '{ for (i=1; i<=NF; i++) $i = toupper(substr($i, 1, 1)) tolower(substr($i, 2)) } 1' OFS='')

EXPORT_STATEMENT="export * as ${PASCALCASE_BASENAME}Proto from './$BASENAME.js';"

# Append the export statement to the index.ts content
INDEX_CONTENT="$INDEX_CONTENT$EXPORT_STATEMENT\n"
Expand Down
37 changes: 15 additions & 22 deletions libraries/grpc-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,16 @@
{
"name": "@conduitplatform/grpc-sdk",
"version": "1.1.3",
"main": "dist/index.cjs",
"module": "dist/index.esm.js",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.esm.js"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.cjs"
},
"default": "./dist/index.esm.js"
}
},
"engines": {
"node": ">=14"
"node": ">=22"
},
"type": "module",
"scripts": {
"prepublish": "npm run build",
"prebuild": "npm run protoc",
"build": "rimraf dist && rollup -c",
"build": "rimraf dist && tsc",
"postbuild": "copyfiles -u 1 src/*.proto src/**/*.json ./dist/",
"protoc": "sh build.sh"
},
Expand All @@ -44,7 +30,6 @@
"nice-grpc": "^2.1.7",
"nice-grpc-client-middleware-retry": "^3",
"prom-client": "^15.1.3",
"protobufjs": "^7.2.6",
"winston": "^3.12.0",
"winston-loki": "^6.0.8"
},
Expand All @@ -61,6 +46,9 @@
"directory": "libraries/grpc-sdk"
},
"devDependencies": {
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.5.0",
"@commitlint/config-lerna-scopes": "^19.0.0",
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-replace": "^5.0.7",
Expand All @@ -71,14 +59,19 @@
"@types/google-protobuf": "^3.15.12",
"@types/lodash": "^4.17.12",
"@types/lodash-es": "^4.17.12",
"@types/node": "20.11.24",
"@types/node": "22.10.2",
"copyfiles": "^2.4.1",
"rimraf": "^5.0.5",
"husky": "^9.0.11",
"lerna": "^8.1.8",
"lint-staged": ">=15.3.0",
"prettier": "^3.0.3",
"rimraf": "^6.0.1",
"rollup": "^4.22.4",
"ts-node": "^10.9.2",
"ts-proto": "^1.167.1",
"ts-proto": "^2.6.1",
"tslib": "^2.6.3",
"typescript": "~5.6.2"
"turbo": "^1.12.4",
"typescript": "~5.7.2"
},
"peerDependencies": {
"@grpc/grpc-js": "^1.10.9"
Expand Down
29 changes: 0 additions & 29 deletions libraries/grpc-sdk/rollup.config.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Resource_Permission, Resource_Relation } from '../protoUtils/index.js';
import { Resource_Permission, Resource_Relation } from '../protoUtils/authorization.js';

export class ConduitAuthorizedResource {
readonly name: string;
Expand Down
6 changes: 4 additions & 2 deletions libraries/grpc-sdk/src/classes/ConduitModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import {
import { CompatServiceDefinition } from 'nice-grpc/lib/service-definitions';
import { Channel, Client, createChannel, createClientFactory } from 'nice-grpc';
import { retryMiddleware } from 'nice-grpc-client-middleware-retry';
import { ConduitModuleDefinition } from '../protoUtils/module.js';
import {
ConduitModuleDefinition,
HealthCheckResponse,
HealthDefinition,
} from '../protoUtils/index.js';
} from '../protoUtils/grpc_health_check.js';
import { EventEmitter } from 'events';
import { ConduitGrpcSdk } from '../index.js';

Expand Down Expand Up @@ -73,7 +73,9 @@ export class ConduitModule<T extends CompatServiceDefinition> {
this.channel = createChannel(this._serviceUrl, undefined, {
'grpc.max_receive_message_length': 1024 * 1024 * 100,
'grpc.max_send_message_length': 1024 * 1024 * 100,
'grpc.service_config': '{"loadBalancingConfig":[{"round_robin":{}}]}',
});

let clientFactory = createClientFactory()
.use(
this._grpcToken
Expand Down
5 changes: 4 additions & 1 deletion libraries/grpc-sdk/src/classes/HealthCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import {
getModuleNameInterceptor,
} from '../interceptors/index.js';
import { createChannel, createClientFactory } from 'nice-grpc';
import { HealthCheckResponse, HealthDefinition } from '../protoUtils/index.js';
import {
HealthCheckResponse,
HealthDefinition,
} from '../protoUtils/grpc_health_check.js';
import { ConduitGrpcSdk } from '../index.js';

export async function checkModuleHealth(
Expand Down
6 changes: 3 additions & 3 deletions libraries/grpc-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ import { GrpcError, HealthCheckStatus } from './types/index.js';
import { createSigner } from 'fast-jwt';
import { ClusterOptions, RedisOptions } from 'ioredis';
import { IConduitLogger, IConduitMetrics } from './interfaces/index.js';
import { ModuleListResponse_ModuleResponse } from './protoUtils/core.js';
import { ConduitModuleDefinition } from './protoUtils/module.js';
import {
ConduitModuleDefinition,
HealthCheckResponse_ServingStatus,
HealthDefinition,
ModuleListResponse_ModuleResponse,
} from './protoUtils/index.js';
} from './protoUtils/grpc_health_check.js';

type UrlRemap = { [url: string]: string };

Expand Down
22 changes: 9 additions & 13 deletions libraries/grpc-sdk/src/interfaces/IConduitLogger.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
import winston, { LogCallback, Logger } from 'winston';
import winston, { Logger } from 'winston';
import { Indexable } from './Indexable.js';

export interface IConduitLogger {
get winston(): winston.Logger;
log(message: string, level?: string, cb?: LogCallback): Logger;

logObject(
object: Indexable,
message?: string,
level?: string,
cb?: LogCallback,
): Logger;
log(message: string, level?: string): Logger;

info(message: string, cb?: LogCallback): Logger;
logObject(object: Indexable, message?: string, level?: string): Logger;

warn(message: string, cb?: LogCallback): Logger;
info(message: string): Logger;

error(message: string | Error, cb?: LogCallback): Logger;
warn(message: string): Logger;

http(message: string, cb?: LogCallback): Logger;
error(messageOrError: string | Error, originalError?: Error): Logger;

verbose(message: string, cb?: LogCallback): Logger;
http(message: string): Logger;

verbose(message: string): Logger;

addTransport(transport: winston.transport): void;
}
2 changes: 1 addition & 1 deletion libraries/grpc-sdk/src/modules/admin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
AdminDefinition,
RegisterAdminRouteRequest,
RegisterAdminRouteRequest_PathDefinition,
} from '../../protoUtils/index.js';
} from '../../protoUtils/core.js';
import { ConduitRouteActions } from '../../interfaces/index.js';

export class Admin extends ConduitModule<typeof AdminDefinition> {
Expand Down
2 changes: 1 addition & 1 deletion libraries/grpc-sdk/src/modules/authentication/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Team,
ValidateAccessTokenResponse,
UserModifyStatusResponse,
} from '../../protoUtils/index.js';
} from '../../protoUtils/authentication.js';

export class Authentication extends ConduitModule<typeof AuthenticationDefinition> {
constructor(
Expand Down
4 changes: 2 additions & 2 deletions libraries/grpc-sdk/src/modules/authorization/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {
Resource,
ResourceAccessListRequest,
ResourceAccessListResponse,
} from '../../protoUtils/index.js';
import { Empty } from '../../protoUtils/google/protobuf/empty.js';
Empty,
} from '../../protoUtils/authorization.js';

export class Authorization extends ConduitModule<typeof AuthorizationDefinition> {
constructor(
Expand Down
8 changes: 5 additions & 3 deletions libraries/grpc-sdk/src/modules/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
ConfigDefinition,
ModuleHealthRequest,
RegisterModuleRequest,
} from '../../protoUtils/index.js';
} from '../../protoUtils/core.js';
import { Indexable } from '../../interfaces/index.js';
import { ConduitGrpcSdk } from '../../index.js';
import { ClusterOptions, RedisOptions } from 'ioredis';
Expand Down Expand Up @@ -105,11 +105,13 @@ export class Config extends ConduitModule<typeof ConfigDefinition> {
name: string,
url: string,
healthStatus: Omit<HealthCheckStatus, HealthCheckStatus.SERVICE_UNKNOWN>,
instanceId: string,
) {
const request: RegisterModuleRequest = {
moduleName: name.toString(),
url: url.toString(),
healthStatus: healthStatus as number,
instanceId,
};
const self = this;
return this.client!.registerModule(request).then(res => {
Expand All @@ -118,13 +120,13 @@ export class Config extends ConduitModule<typeof ConfigDefinition> {
});
}

moduleHealthProbe(name: string, url: string) {
moduleHealthProbe(name: string, url: string, instanceId: string) {
const request: ModuleHealthRequest = {
moduleName: name.toString(),
url,
status: this._serviceHealthStatusGetter
? this._serviceHealthStatusGetter()
: HealthCheckStatus.SERVICE_UNKNOWN,
instanceId,
};
const self = this;
this.client!.moduleHealthProbe(request)
Expand Down
2 changes: 1 addition & 1 deletion libraries/grpc-sdk/src/modules/database/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { Query } from '../../types/db.js';
import { FindOneOptions, FindManyOptions } from './types.js';
import { AuthzOptions, PopulateAuthzOptions } from '../../types/options.js';
import { isNil } from 'lodash';
import { isNil } from 'lodash-es';
import {
normalizeAuthzOptions,
normalizePopulateAuthzOptions,
Expand Down
4 changes: 2 additions & 2 deletions libraries/grpc-sdk/src/modules/pushNotifications/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { ConduitModule } from '../../classes/index.js';
import {
PushNotificationsDefinition,
SendNotificationResponse,
} from '../../protoUtils/index.js';
} from '../../protoUtils/push-notifications.js';
import { SendNotificationOptions } from './types';
import { isNil } from 'lodash';
import { isNil } from 'lodash-es';

export class PushNotifications extends ConduitModule<typeof PushNotificationsDefinition> {
constructor(
Expand Down
4 changes: 2 additions & 2 deletions libraries/grpc-sdk/src/modules/storage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import {
StorageDefinition,
} from '../../protoUtils/storage.js';
import { AuthzOptions } from '../../types';
import { normalizeAuthzOptions } from '../../utilities/normalizeOptions';
import { normalizeAuthzOptions } from '../../utilities/normalizeOptions.js';
import {
CreateFileByURLOptions,
CreateFileOptions,
UpdateFileByURLOptions,
UpdateFileOptions,
} from './types';
import { isNil } from 'lodash';
import { isNil } from 'lodash-es';

export class Storage extends ConduitModule<typeof StorageDefinition> {
constructor(
Expand Down
2 changes: 1 addition & 1 deletion libraries/grpc-sdk/src/utilities/normalizeOptions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AuthzOptions, PopulateAuthzOptions } from '../types';
import { isNil } from 'lodash';
import { isNil } from 'lodash-es';

export function normalizeAuthzOptions(
userIdOrOptions?: string | AuthzOptions,
Expand Down
12 changes: 6 additions & 6 deletions libraries/hermes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"types": "dist/index.d.ts",
"private": true,
"engines": {
"node": ">=14"
"node": ">=22"
},
"type": "module",
"scripts": {
Expand All @@ -28,7 +28,7 @@
"body-parser": "^1.20.3",
"cookie-parser": "~1.4.7",
"cors": "^2.8.5",
"debug": "~4.3.4",
"debug": "~4.4.0",
"deep-object-diff": "^1.1.9",
"deepdash-es": "^5.3.9",
"express": "~4.21.1",
Expand All @@ -43,7 +43,7 @@
"moment": "^2.30.1",
"object-hash": "^3.0.0",
"socket.io": "^4.8.0",
"swagger-ui-express": "5.0.0",
"swagger-ui-express": "5.0.1",
"winston": "^3.12.0"
},
"peerDependencies": {
Expand All @@ -61,9 +61,9 @@
"@types/express": "~4.17.21",
"@types/graphql-type-json": "^0.3.5",
"@types/lodash-es": "^4.17.12",
"@types/node": "20.11.24",
"@types/node": "22.10.2",
"@types/object-hash": "^3.0.6",
"rimraf": "^5.0.5",
"typescript": "~5.6.2"
"rimraf": "^6.0.1",
"typescript": "~5.7.2"
}
}
2 changes: 2 additions & 0 deletions libraries/hermes/src/Rest/Rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,10 @@
}
this.createRouter();
const self = this;
//@ts-expect-error

Check warning on line 314 in libraries/hermes/src/Rest/Rest.ts

View check run for this annotation

codefactor.io / CodeFactor

libraries/hermes/src/Rest/Rest.ts#L314

Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 3 characters or longer. (@typescript-eslint/ban-ts-comment)
this._expressRouter!.use('/swagger', swaggerUi.serve);
this._expressRouter!.get('/swagger', (req, res, next) =>
//@ts-expect-error

Check warning on line 317 in libraries/hermes/src/Rest/Rest.ts

View check run for this annotation

codefactor.io / CodeFactor

libraries/hermes/src/Rest/Rest.ts#L317

Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 3 characters or longer. (@typescript-eslint/ban-ts-comment)
swaggerUi.setup(self._swagger!.swaggerDoc)(req, res, next),
);
this._expressRouter!.get(
Expand Down
1 change: 1 addition & 0 deletions libraries/hermes/src/utils/GrpcConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export function grpcToConduitRoute(
{
'grpc.max_receive_message_length': 1024 * 1024 * 100,
'grpc.max_send_message_length': 1024 * 1024 * 100,
'grpc.service_config': '{"loadBalancingConfig":[{"round_robin":{}}]}',
},
);

Expand Down
Loading