@stamhoofd/backend 2.50.0 → 2.51.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.
@@ -24,7 +24,8 @@
24
24
  },
25
25
  "legacyWebshop": "shop.stamhoofd",
26
26
  "api": "api.stamhoofd",
27
- "rendererApi": "renderer.stamhoofd"
27
+ "rendererApi": "renderer.stamhoofd",
28
+ "webshopCname": "shop.stamhoofd"
28
29
  },
29
30
  "translationNamespace": "stamhoofd",
30
31
  "platformName": "stamhoofd",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stamhoofd/backend",
3
- "version": "2.50.0",
3
+ "version": "2.51.0",
4
4
  "main": "./dist/index.js",
5
5
  "exports": {
6
6
  ".": {
@@ -33,17 +33,17 @@
33
33
  "dependencies": {
34
34
  "@mollie/api-client": "3.7.0",
35
35
  "@simonbackx/simple-database": "1.25.0",
36
- "@simonbackx/simple-encoding": "2.16.5",
36
+ "@simonbackx/simple-encoding": "2.16.6",
37
37
  "@simonbackx/simple-endpoints": "1.14.0",
38
38
  "@simonbackx/simple-logging": "^1.0.1",
39
- "@stamhoofd/backend-i18n": "2.50.0",
40
- "@stamhoofd/backend-middleware": "2.50.0",
41
- "@stamhoofd/email": "2.50.0",
42
- "@stamhoofd/models": "2.50.0",
43
- "@stamhoofd/queues": "2.50.0",
44
- "@stamhoofd/sql": "2.50.0",
45
- "@stamhoofd/structures": "2.50.0",
46
- "@stamhoofd/utility": "2.50.0",
39
+ "@stamhoofd/backend-i18n": "2.51.0",
40
+ "@stamhoofd/backend-middleware": "2.51.0",
41
+ "@stamhoofd/email": "2.51.0",
42
+ "@stamhoofd/models": "2.51.0",
43
+ "@stamhoofd/queues": "2.51.0",
44
+ "@stamhoofd/sql": "2.51.0",
45
+ "@stamhoofd/structures": "2.51.0",
46
+ "@stamhoofd/utility": "2.51.0",
47
47
  "archiver": "^7.0.1",
48
48
  "aws-sdk": "^2.885.0",
49
49
  "axios": "1.6.8",
@@ -60,5 +60,8 @@
60
60
  "postmark": "^4.0.5",
61
61
  "stripe": "^16.6.0"
62
62
  },
63
- "gitHead": "809b483cc6e98291fca589b1ac39aaa3a7fcf6f2"
63
+ "publishConfig": {
64
+ "access": "public"
65
+ },
66
+ "gitHead": "5db656e50ded9b65076cd2d0d864f7fb65a4b7fb"
64
67
  }
@@ -1,6 +1,6 @@
1
1
  import { DecodedRequest, Endpoint, Request, Response } from '@simonbackx/simple-endpoints';
2
2
  import { Document } from '@stamhoofd/models';
3
- import { assertSort, CountFilteredRequest, Document as DocumentStruct, getSortFilter, LimitedFilteredRequest, PaginatedResponse } from '@stamhoofd/structures';
3
+ import { assertSort, CountFilteredRequest, Document as DocumentStruct, getSortFilter, LimitedFilteredRequest, PaginatedResponse, SearchFilterFactory, StamhoofdFilter } from '@stamhoofd/structures';
4
4
 
5
5
  import { Decoder } from '@simonbackx/simple-encoding';
6
6
  import { compileToSQLFilter, compileToSQLSorter, SQL, SQLFilterDefinitions, SQLSortDefinitions } from '@stamhoofd/sql';
@@ -55,12 +55,11 @@ export class GetDocumentsEndpoint extends Endpoint<Params, Query, Body, Response
55
55
  }
56
56
 
57
57
  if (q.search) {
58
- // todo
59
- // const searchFilter: StamhoofdFilter | null = getOrderSearchFilter(q.search, parsePhoneNumber);
58
+ const searchFilter: StamhoofdFilter | null = getDocumentSearchFilter(q.search);
60
59
 
61
- // if (searchFilter) {
62
- // query.where(compileToSQLFilter(searchFilter, filterCompilers));
63
- // }
60
+ if (searchFilter) {
61
+ query.where(compileToSQLFilter(searchFilter, filterCompilers));
62
+ }
64
63
  }
65
64
 
66
65
  if (q instanceof LimitedFilteredRequest) {
@@ -126,3 +125,33 @@ export class GetDocumentsEndpoint extends Endpoint<Params, Query, Body, Response
126
125
  );
127
126
  }
128
127
  }
128
+
129
+ function getDocumentSearchFilter(search: string | null): StamhoofdFilter | null {
130
+ if (search === null || search === undefined) {
131
+ return null;
132
+ }
133
+
134
+ const numberFilter = SearchFilterFactory.getIntegerFilter(search);
135
+
136
+ if (numberFilter) {
137
+ return {
138
+ number: numberFilter,
139
+ };
140
+ }
141
+
142
+ return {
143
+ $or: [
144
+ {
145
+ description: {
146
+ $contains: search,
147
+ },
148
+ },
149
+ {
150
+ id: {
151
+ $contains: search,
152
+ },
153
+ },
154
+ ]
155
+ ,
156
+ };
157
+ }
@@ -1,7 +1,7 @@
1
1
  import { DecodedRequest, Endpoint, Request, Response } from '@simonbackx/simple-endpoints';
2
2
  import { SimpleError } from '@simonbackx/simple-errors';
3
3
  import { signInternal } from '@stamhoofd/backend-env';
4
- import { Document } from '@stamhoofd/models';
4
+ import { Document, Organization } from '@stamhoofd/models';
5
5
 
6
6
  import { Context } from '../../../helpers/Context';
7
7
  type Params = { id: string };
@@ -24,7 +24,7 @@ export class GetDocumentHtml extends Endpoint<Params, Query, Body, ResponseBody>
24
24
  }
25
25
 
26
26
  async handle(request: DecodedRequest<Params, Query, Body>) {
27
- const organization = await Context.setOrganizationScope();
27
+ await Context.setOptionalOrganizationScope();
28
28
  await Context.authenticate();
29
29
 
30
30
  const document = await Document.getByID(request.params.id);
@@ -35,6 +35,15 @@ export class GetDocumentHtml extends Endpoint<Params, Query, Body, ResponseBody>
35
35
  });
36
36
  }
37
37
 
38
+ const organization = await Organization.getByID(document.organizationId);
39
+
40
+ if (!organization) {
41
+ throw new SimpleError({
42
+ code: 'not_found',
43
+ message: 'Organization not found',
44
+ });
45
+ }
46
+
38
47
  const html = await document.getRenderedHtml(organization);
39
48
  if (!html) {
40
49
  throw new SimpleError({
package/tsconfig.json CHANGED
@@ -33,7 +33,8 @@
33
33
  ],
34
34
  "exclude": [
35
35
  "node_modules",
36
- "dist"
36
+ "dist",
37
+ "dist/**/*"
37
38
  ],
38
39
  "ts-node": {
39
40
  "files": true