@fraym/projections 0.14.0 → 0.14.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/LICENSE +21 -0
- package/README.md +3 -3
- package/dist/delivery/client.d.ts +1 -1
- package/dist/delivery/upsert.d.ts +2 -1
- package/dist/delivery/upsert.js +6 -1
- package/package.json +7 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Becklyn Studios
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -85,7 +85,7 @@ const managementClient = await newManagementClient();
|
|
|
85
85
|
|
|
86
86
|
### Create one or multipe projections
|
|
87
87
|
|
|
88
|
-
Projectionw are defined by schemas. A schema can contain more than one projection definition. See [SCHEMA.md](
|
|
88
|
+
Projectionw are defined by schemas. A schema can contain more than one projection definition. See [SCHEMA.md](SCHEMA.md) for a reference.
|
|
89
89
|
|
|
90
90
|
```typescript
|
|
91
91
|
await managementClient.create("your schema here");
|
|
@@ -93,7 +93,7 @@ await managementClient.create("your schema here");
|
|
|
93
93
|
|
|
94
94
|
### Update one or multipe projections
|
|
95
95
|
|
|
96
|
-
Projectionw are defined by schemas. A schema can contain more than one projection definition. See [SCHEMA.md](
|
|
96
|
+
Projectionw are defined by schemas. A schema can contain more than one projection definition. See [SCHEMA.md](SCHEMA.md) for a reference.
|
|
97
97
|
|
|
98
98
|
```typescript
|
|
99
99
|
await managementClient.update("your schema here");
|
|
@@ -211,7 +211,7 @@ const data = await deliveryClient.getData(
|
|
|
211
211
|
);
|
|
212
212
|
```
|
|
213
213
|
|
|
214
|
-
### Get (paginated / filtered) data
|
|
214
|
+
### Get (paginated / filtered / ordered) data
|
|
215
215
|
|
|
216
216
|
The name of `YourProjection` has to equal your type name in your schema (also in casing).
|
|
217
217
|
|
|
@@ -8,7 +8,7 @@ import { EventMetadata } from "./eventMetadata";
|
|
|
8
8
|
export interface DeliveryClient {
|
|
9
9
|
getData: <T extends {}>(projection: string, authData: AuthData, id: string, filter?: Filter, returnEmptyDataIfNotFound?: boolean) => Promise<T | null>;
|
|
10
10
|
getDataList: <T extends {}>(projection: string, authData: AuthData, limit?: number, page?: number, filter?: Filter, order?: Order[]) => Promise<GetProjectionDataList<T> | null>;
|
|
11
|
-
upsertData: <T extends {}>(projection: string, authData: AuthData, dataId: string, payload:
|
|
11
|
+
upsertData: <T extends {}>(projection: string, authData: AuthData, dataId: string, payload: Record<string, any>, eventMetadata?: EventMetadata) => Promise<UpsertResponse<T>>;
|
|
12
12
|
deleteDataById: (projection: string, authData: AuthData, dataId: string, eventMetadata?: EventMetadata) => Promise<number>;
|
|
13
13
|
deleteDataByFilter: (projection: string, authData: AuthData, filter?: Filter, eventMetadata?: EventMetadata) => Promise<number>;
|
|
14
14
|
close: () => Promise<void>;
|
|
@@ -4,6 +4,7 @@ import { EventMetadata } from "./eventMetadata";
|
|
|
4
4
|
export type UpsertResponse<T extends {}> = UpsertSuccessResponse<T> | UpsertValidationResponse;
|
|
5
5
|
export interface UpsertSuccessResponse<T extends {}> {
|
|
6
6
|
data: T;
|
|
7
|
+
id: string;
|
|
7
8
|
}
|
|
8
9
|
export interface UpsertValidationResponse {
|
|
9
10
|
validationErrors: string[];
|
|
@@ -11,4 +12,4 @@ export interface UpsertValidationResponse {
|
|
|
11
12
|
}
|
|
12
13
|
export declare const isUpsertSuccessResponse: <T extends {}>(response: UpsertResponse<T>) => response is UpsertSuccessResponse<T>;
|
|
13
14
|
export declare const isUpsertValidationResponse: <T extends {}>(response: UpsertResponse<T>) => response is UpsertValidationResponse;
|
|
14
|
-
export declare const upsertProjectionData: <T extends {}>(projection: string, auth: AuthData, dataId: string, payload:
|
|
15
|
+
export declare const upsertProjectionData: <T extends {}>(projection: string, auth: AuthData, dataId: string, payload: Record<string, any>, eventMetadata: EventMetadata, serviceClient: DeliveryServiceClient) => Promise<UpsertResponse<T>>;
|
package/dist/delivery/upsert.js
CHANGED
|
@@ -11,12 +11,16 @@ const isUpsertValidationResponse = (response) => {
|
|
|
11
11
|
};
|
|
12
12
|
exports.isUpsertValidationResponse = isUpsertValidationResponse;
|
|
13
13
|
const upsertProjectionData = async (projection, auth, dataId, payload, eventMetadata, serviceClient) => {
|
|
14
|
+
const usedPayload = {};
|
|
15
|
+
for (const key in payload) {
|
|
16
|
+
usedPayload[key] = JSON.stringify(payload[key]);
|
|
17
|
+
}
|
|
14
18
|
return new Promise((resolve, reject) => {
|
|
15
19
|
serviceClient.upsertData({
|
|
16
20
|
projection,
|
|
17
21
|
auth: (0, auth_1.getProtobufAuthData)(auth),
|
|
18
22
|
dataId,
|
|
19
|
-
payload,
|
|
23
|
+
payload: usedPayload,
|
|
20
24
|
eventMetadata,
|
|
21
25
|
}, (error, response) => {
|
|
22
26
|
if (error) {
|
|
@@ -36,6 +40,7 @@ const upsertProjectionData = async (projection, auth, dataId, payload, eventMeta
|
|
|
36
40
|
}
|
|
37
41
|
resolve({
|
|
38
42
|
data,
|
|
43
|
+
id: response.id,
|
|
39
44
|
});
|
|
40
45
|
});
|
|
41
46
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fraym/projections",
|
|
3
|
-
"version": "0.14.
|
|
4
|
-
"license": "
|
|
3
|
+
"version": "0.14.2",
|
|
4
|
+
"license": "MIT",
|
|
5
5
|
"homepage": "https://github.com/fraym/projections-nodejs",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"projections": "dist/cmd/projections.js"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@fraym/projections-proto": "^1.0.0-alpha.
|
|
30
|
+
"@fraym/projections-proto": "^1.0.0-alpha.17",
|
|
31
31
|
"@graphql-tools/graphql-file-loader": "^7.5.16",
|
|
32
32
|
"@graphql-tools/load": "^7.8.13",
|
|
33
|
-
"@grpc/grpc-js": "^1.8.
|
|
33
|
+
"@grpc/grpc-js": "^1.8.13",
|
|
34
34
|
"dotenv": "^16.0.3",
|
|
35
35
|
"graphql": "^16.6.0",
|
|
36
36
|
"yargs": "^17.7.1"
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@becklyn/prettier": "^1.0.2",
|
|
40
40
|
"@types/uuid": "^9.0.1",
|
|
41
|
-
"@types/yargs": "^17.0.
|
|
42
|
-
"prettier": "^2.8.
|
|
43
|
-
"typescript": "^5.0.
|
|
41
|
+
"@types/yargs": "^17.0.24",
|
|
42
|
+
"prettier": "^2.8.7",
|
|
43
|
+
"typescript": "^5.0.3",
|
|
44
44
|
"uuid": "^9.0.0"
|
|
45
45
|
},
|
|
46
46
|
"prettier": "@becklyn/prettier"
|