@fraym/projections 0.15.0 → 0.17.0

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.
@@ -1,4 +1,4 @@
1
- import { AuthData as PbAuthData } from "@fraym/projections-proto";
1
+ import { AuthData as PbAuthData } from "@fraym/proto/freym/projections/delivery";
2
2
  export interface AuthData {
3
3
  tenantId: string;
4
4
  scopes: string[];
@@ -5,8 +5,9 @@ import { Order } from "./order";
5
5
  import { AuthData } from "./auth";
6
6
  import { UpsertResponse } from "./upsert";
7
7
  import { EventMetadata } from "./eventMetadata";
8
+ import { Wait } from "./wait";
8
9
  export interface DeliveryClient {
9
- getData: <T extends {}>(projection: string, authData: AuthData, id: string, filter?: Filter, returnEmptyDataIfNotFound?: boolean) => Promise<T | null>;
10
+ getData: <T extends {}>(projection: string, authData: AuthData, id: string, filter?: Filter, returnEmptyDataIfNotFound?: boolean, wait?: Wait) => Promise<T | null>;
10
11
  getDataList: <T extends {}>(projection: string, authData: AuthData, limit?: number, page?: number, filter?: Filter, order?: Order[]) => Promise<GetProjectionDataList<T> | null>;
11
12
  upsertData: <T extends {}>(projection: string, authData: AuthData, dataId: string, payload: Record<string, any>, eventMetadata?: EventMetadata) => Promise<UpsertResponse<T>>;
12
13
  deleteDataById: (projection: string, authData: AuthData, dataId: string, eventMetadata?: EventMetadata) => Promise<number>;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.newDeliveryClient = void 0;
4
- const projections_proto_1 = require("@fraym/projections-proto");
4
+ const delivery_1 = require("@fraym/proto/freym/projections/delivery");
5
5
  const grpc_js_1 = require("@grpc/grpc-js");
6
6
  const config_1 = require("../config/config");
7
7
  const getData_1 = require("./getData");
@@ -10,13 +10,13 @@ const upsert_1 = require("./upsert");
10
10
  const delete_1 = require("./delete");
11
11
  const newDeliveryClient = async (config) => {
12
12
  config = (0, config_1.useDeliveryConfigDefaults)(config);
13
- const serviceClient = new projections_proto_1.DeliveryServiceClient(config.serverAddress, grpc_js_1.credentials.createInsecure(), {
13
+ const serviceClient = new delivery_1.ServiceClient(config.serverAddress, grpc_js_1.credentials.createInsecure(), {
14
14
  "grpc.keepalive_time_ms": config.keepaliveInterval,
15
15
  "grpc.keepalive_timeout_ms": config.keepaliveTimeout,
16
16
  "grpc.keepalive_permit_without_calls": 1,
17
17
  });
18
- const getData = async (projection, auth, id, filter = { fields: {}, and: [], or: [] }, returnEmptyDataIfNotFound = false) => {
19
- return await (0, getData_1.getProjectionData)(projection, auth, id, filter, returnEmptyDataIfNotFound, serviceClient);
18
+ const getData = async (projection, auth, id, filter = { fields: {}, and: [], or: [] }, returnEmptyDataIfNotFound = false, wait) => {
19
+ return await (0, getData_1.getProjectionData)(projection, auth, id, filter, returnEmptyDataIfNotFound, serviceClient, wait);
20
20
  };
21
21
  const getDataList = async (projection, auth, limit = 0, page = 1, filter = { fields: {}, and: [], or: [] }, order = []) => {
22
22
  return await (0, getDataList_1.getProjectionDataList)(projection, auth, limit, page, filter, order, serviceClient);
@@ -1,5 +1,5 @@
1
- import { DeliveryServiceClient } from "@fraym/projections-proto";
1
+ import { ServiceClient } from "@fraym/proto/freym/projections/delivery";
2
2
  import { AuthData } from "./auth";
3
3
  import { EventMetadata } from "./eventMetadata";
4
4
  import { Filter } from "./filter";
5
- export declare const deleteProjectionData: (projection: string, auth: AuthData, dataId: string, filter: Filter, eventMetadata: EventMetadata, serviceClient: DeliveryServiceClient) => Promise<number>;
5
+ export declare const deleteProjectionData: (projection: string, auth: AuthData, dataId: string, filter: Filter, eventMetadata: EventMetadata, serviceClient: ServiceClient) => Promise<number>;
@@ -1,4 +1,4 @@
1
- import { DataFilter } from "@fraym/projections-proto";
1
+ import { DataFilter } from "@fraym/proto/freym/projections/delivery";
2
2
  export interface Filter {
3
3
  fields: Record<string, FieldFilter>;
4
4
  and: Filter[];
@@ -1,4 +1,5 @@
1
- import { DeliveryServiceClient } from "@fraym/projections-proto";
1
+ import { ServiceClient } from "@fraym/proto/freym/projections/delivery";
2
2
  import { AuthData } from "./auth";
3
3
  import { Filter } from "./filter";
4
- export declare const getProjectionData: <T extends {}>(projection: string, auth: AuthData, dataId: string, filter: Filter, returnEmptyDataIfNotFound: boolean, serviceClient: DeliveryServiceClient) => Promise<T | null>;
4
+ import { Wait } from "./wait";
5
+ export declare const getProjectionData: <T extends {}>(projection: string, auth: AuthData, dataId: string, filter: Filter, returnEmptyDataIfNotFound: boolean, serviceClient: ServiceClient, wait?: Wait) => Promise<T | null>;
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getProjectionData = void 0;
4
4
  const auth_1 = require("./auth");
5
5
  const filter_1 = require("./filter");
6
- const getProjectionData = async (projection, auth, dataId, filter, returnEmptyDataIfNotFound, serviceClient) => {
6
+ const wait_1 = require("./wait");
7
+ const getProjectionData = async (projection, auth, dataId, filter, returnEmptyDataIfNotFound, serviceClient, wait) => {
7
8
  return new Promise((resolve, reject) => {
8
9
  serviceClient.getData({
9
10
  projection,
@@ -11,6 +12,7 @@ const getProjectionData = async (projection, auth, dataId, filter, returnEmptyDa
11
12
  dataId,
12
13
  filter: (0, filter_1.getProtobufDataFilter)(filter),
13
14
  returnEmptyDataIfNotFound,
15
+ wait: (0, wait_1.getProtobufDataWait)(wait),
14
16
  }, (error, response) => {
15
17
  if (error) {
16
18
  reject(error.message);
@@ -1,4 +1,4 @@
1
- import { DeliveryServiceClient } from "@fraym/projections-proto";
1
+ import { ServiceClient } from "@fraym/proto/freym/projections/delivery";
2
2
  import { AuthData } from "./auth";
3
3
  import { Filter } from "./filter";
4
4
  import { Order } from "./order";
@@ -8,4 +8,4 @@ export interface GetProjectionDataList<T extends {}> {
8
8
  total: number;
9
9
  data: T[];
10
10
  }
11
- export declare const getProjectionDataList: <T extends {}>(projection: string, auth: AuthData, limit: number, page: number, filter: Filter, order: Order[], serviceClient: DeliveryServiceClient) => Promise<GetProjectionDataList<T> | null>;
11
+ export declare const getProjectionDataList: <T extends {}>(projection: string, auth: AuthData, limit: number, page: number, filter: Filter, order: Order[], serviceClient: ServiceClient) => Promise<GetProjectionDataList<T> | null>;
@@ -1,4 +1,4 @@
1
- import { DataOrder } from "@fraym/projections-proto";
1
+ import { DataOrder } from "@fraym/proto/freym/projections/delivery";
2
2
  export interface Order {
3
3
  field: string;
4
4
  descending?: boolean;
@@ -1,4 +1,4 @@
1
- import { DeliveryServiceClient } from "@fraym/projections-proto";
1
+ import { ServiceClient } from "@fraym/proto/freym/projections/delivery";
2
2
  import { AuthData } from "./auth";
3
3
  import { EventMetadata } from "./eventMetadata";
4
4
  export type UpsertResponse<T extends {}> = UpsertSuccessResponse<T> | UpsertValidationResponse;
@@ -12,4 +12,4 @@ export interface UpsertValidationResponse {
12
12
  }
13
13
  export declare const isUpsertSuccessResponse: <T extends {}>(response: UpsertResponse<T>) => response is UpsertSuccessResponse<T>;
14
14
  export declare const isUpsertValidationResponse: <T extends {}>(response: UpsertResponse<T>) => response is UpsertValidationResponse;
15
- export declare const upsertProjectionData: <T extends {}>(projection: string, auth: AuthData, dataId: string, payload: Record<string, any>, eventMetadata: EventMetadata, serviceClient: DeliveryServiceClient) => Promise<UpsertResponse<T>>;
15
+ export declare const upsertProjectionData: <T extends {}>(projection: string, auth: AuthData, dataId: string, payload: Record<string, any>, eventMetadata: EventMetadata, serviceClient: ServiceClient) => Promise<UpsertResponse<T>>;
@@ -0,0 +1,7 @@
1
+ import { DataWait } from "@fraym/proto/freym/projections/delivery";
2
+ import { Filter } from "./filter";
3
+ export interface Wait {
4
+ timeout?: number;
5
+ conditionFilter: Filter;
6
+ }
7
+ export declare const getProtobufDataWait: (wait?: Wait) => DataWait | undefined;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getProtobufDataWait = void 0;
4
+ const filter_1 = require("./filter");
5
+ const getProtobufDataWait = (wait) => {
6
+ var _a;
7
+ if (!wait) {
8
+ return undefined;
9
+ }
10
+ return {
11
+ conditionFilter: (0, filter_1.getProtobufDataFilter)(wait.conditionFilter),
12
+ timeout: (_a = wait.timeout) !== null && _a !== void 0 ? _a : 0,
13
+ };
14
+ };
15
+ exports.getProtobufDataWait = getProtobufDataWait;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fraym/projections",
3
- "version": "0.15.0",
3
+ "version": "0.17.0",
4
4
  "license": "MIT",
5
5
  "homepage": "https://github.com/fraym/projections-nodejs",
6
6
  "repository": {
@@ -20,24 +20,27 @@
20
20
  "files": [
21
21
  "dist/**/*"
22
22
  ],
23
+ "engines": {
24
+ "node": ">=16"
25
+ },
23
26
  "main": "dist/index.js",
24
27
  "types": "dist/index.d.ts",
25
28
  "dependencies": {
26
- "@fraym/projections-proto": "^1.0.0-alpha.17",
27
- "@graphql-tools/graphql-file-loader": "^7.5.16",
28
- "@graphql-tools/load": "^7.8.13",
29
- "@grpc/grpc-js": "^1.8.13",
30
- "dotenv": "^16.0.3",
31
- "graphql": "^16.6.0",
32
- "yargs": "^17.7.1"
29
+ "@fraym/proto": "^0.3.0",
30
+ "@graphql-tools/graphql-file-loader": "^7.5.17",
31
+ "@graphql-tools/load": "^7.8.14",
32
+ "@grpc/grpc-js": "^1.9.7",
33
+ "dotenv": "^16.3.1",
34
+ "graphql": "^16.8.1",
35
+ "yargs": "^17.7.2"
33
36
  },
34
37
  "devDependencies": {
35
38
  "@becklyn/prettier": "^1.0.2",
36
- "@types/uuid": "^9.0.1",
37
- "@types/yargs": "^17.0.24",
38
- "prettier": "^2.8.7",
39
- "typescript": "^5.0.3",
40
- "uuid": "^9.0.0"
39
+ "@types/uuid": "^9.0.6",
40
+ "@types/yargs": "^17.0.29",
41
+ "prettier": "^2.8.8",
42
+ "typescript": "^5.2.2",
43
+ "uuid": "^9.0.1"
41
44
  },
42
45
  "prettier": "@becklyn/prettier"
43
46
  }