@fraym/crud 0.17.0 → 0.17.2

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/README.md CHANGED
@@ -90,6 +90,30 @@ await managementClient.removeTypes(["YourCrudType"]);
90
90
  const list = await managementClient.getAllTypes();
91
91
  ```
92
92
 
93
+ ### Authorization
94
+
95
+ All delivery client functions make use of the `AuthData` object.
96
+ This data is used to check access for the desired action.
97
+
98
+ You can add the `FRAYM_AUTH_OWNER` scope in case you are performing an action that is no subject to restrictions.
99
+
100
+ Fields:
101
+
102
+ - `tenantId`: Id of the tenant to use
103
+ - `scopes`: Slice of scopes to use for the action
104
+ - `data`: Data that is used in directives like `@filterFromJwtData`
105
+
106
+ ### Event Metadata
107
+
108
+ You can specify the correlation and causation IDs for the upsert and delete functions. The `eventMetadata` parameter is optional for all these functions and has the following structure:
109
+
110
+ ```typescript
111
+ const eventMetadata = {
112
+ correlationId: "some-correlation-id",
113
+ causationId: "some-causation-id",
114
+ };
115
+ ```
116
+
93
117
  ### Create data
94
118
 
95
119
  The name of `YourCrudType` has to equal your type name in your schema (also in casing).
@@ -1,7 +1,7 @@
1
- import { AuthData as PbAuthData } from "@fraym/crud-proto";
1
+ import { CrudAuthData } from "@fraym/crud-proto";
2
2
  export interface AuthData {
3
3
  tenantId: string;
4
4
  scopes: string[];
5
5
  data: Record<string, any>;
6
6
  }
7
- export declare const getProtobufAuthData: (auth: AuthData) => PbAuthData;
7
+ export declare const getProtobufAuthData: (auth: AuthData) => CrudAuthData;
@@ -27,7 +27,8 @@ const createCrudData = async (type, authData, data, id, eventMetadata, serviceCl
27
27
  reject(error.message);
28
28
  return;
29
29
  }
30
- if (response.validationErrors || response.fieldValidationErrors) {
30
+ if (response.validationErrors.length > 0 ||
31
+ Object.keys(response.fieldValidationErrors).length > 0) {
31
32
  resolve({
32
33
  validationErrors: response.validationErrors,
33
34
  fieldValidationErrors: response.fieldValidationErrors,
@@ -27,7 +27,8 @@ const updateCrudData = async (type, authData, id, data, eventMetadata, serviceCl
27
27
  reject(error.message);
28
28
  return;
29
29
  }
30
- if (response.validationErrors || response.fieldValidationErrors) {
30
+ if (response.validationErrors.length > 0 ||
31
+ Object.keys(response.fieldValidationErrors).length > 0) {
31
32
  resolve({
32
33
  validationErrors: response.validationErrors,
33
34
  fieldValidationErrors: response.fieldValidationErrors,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fraym/crud",
3
- "version": "0.17.0",
3
+ "version": "0.17.2",
4
4
  "license": "UNLICENSED",
5
5
  "homepage": "https://github.com/fraym/crud-nodejs",
6
6
  "repository": {
@@ -27,7 +27,7 @@
27
27
  "crud": "dist/cmd/crud.js"
28
28
  },
29
29
  "dependencies": {
30
- "@fraym/crud-proto": "1.0.0-alpha.14",
30
+ "@fraym/crud-proto": "1.0.0-alpha.17",
31
31
  "@graphql-tools/graphql-file-loader": "^7.5.14",
32
32
  "@graphql-tools/load": "^7.8.9",
33
33
  "@grpc/grpc-js": "^1.8.7",