need4deed-sdk 0.0.190 → 0.0.192

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
@@ -1,3 +1,9 @@
1
1
  # sdk
2
2
 
3
3
  Shared types for need4deed.org
4
+
5
+ ## Translation field names
6
+
7
+ `TranslationFieldsByEntity` exports the registered translation fields for each entity. Backend registry validation can use this map to keep accepted fields aligned with the SDK.
8
+
9
+ Opportunity translation endpoints use `info` for the field exposed as `description` by `ApiOpportunityGet` and `ApiOpportunityPatch`. Translation requests must use `info`; ordinary opportunity requests use `description`.
@@ -215,7 +215,9 @@ export type ApiOpportunityPatch = VoidableProps<{
215
215
  name?: string;
216
216
  };
217
217
  accompanyingDetails: ApiOpportunityAccompanyingDetails;
218
- }>;
218
+ }> & {
219
+ originalLanguage?: Lang;
220
+ };
219
221
  export interface OpportunityVolunteer {
220
222
  id: number;
221
223
  status: OpportunityVolunteerStatusType;
@@ -1,4 +1,4 @@
1
- import { Lang } from "..";
1
+ import { EntityTableName, Lang } from "..";
2
2
  export declare enum TranslationOrigin {
3
3
  REFERENCE = "reference",
4
4
  MACHINE = "machine",
@@ -17,12 +17,37 @@ export interface ApiFieldTranslation {
17
17
  status: TranslationStatus;
18
18
  lastErrorCode?: TranslationErrorCode;
19
19
  }
20
- export interface ApiFieldTranslationGet {
21
- fieldName: string;
20
+ export interface ApiOriginalLanguagePut {
21
+ language: Lang;
22
+ }
23
+ export type TranslationFieldsByEntity = {
24
+ [EntityTableName.OPPORTUNITY]: "title" | "info";
25
+ [EntityTableName.LANGUAGE]: "title";
26
+ [EntityTableName.CATEGORY]: "title" | "description";
27
+ [EntityTableName.ACTIVITY]: "title";
28
+ [EntityTableName.SKILL]: "title";
29
+ [EntityTableName.AGENT_TYPE]: "title";
30
+ [EntityTableName.SERVICE]: "title";
31
+ [EntityTableName.LEAD]: "title";
32
+ };
33
+ export type TranslatedEntityType = keyof TranslationFieldsByEntity;
34
+ export interface ApiFieldTranslationGet<Entity extends TranslatedEntityType = TranslatedEntityType> {
35
+ fieldName: TranslationFieldsByEntity[Entity];
22
36
  original: string;
23
37
  originalLanguage?: Lang;
24
38
  translations: Partial<Record<Lang, ApiFieldTranslation>>;
25
39
  }
26
- export interface ApiOriginalLanguagePut {
27
- language: Lang;
40
+ export type ApiFieldTranslationPost = {
41
+ [Entity in TranslatedEntityType]: {
42
+ entityType: Entity;
43
+ entityId: number;
44
+ fieldName: TranslationFieldsByEntity[Entity];
45
+ language: Lang;
46
+ text: string;
47
+ original: string;
48
+ };
49
+ }[TranslatedEntityType];
50
+ export interface ApiFieldTranslationPatch {
51
+ text: string;
52
+ original: string;
28
53
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TranslationStatus = exports.TranslationOrigin = void 0;
4
+ const __1 = require("..");
4
5
  var TranslationOrigin;
5
6
  (function (TranslationOrigin) {
6
7
  TranslationOrigin["REFERENCE"] = "reference";
@@ -0,0 +1,7 @@
1
+ import { UserRole } from "../types/api/user";
2
+ export declare function canModifyCommunication(communication: {
3
+ userId?: number | null;
4
+ }, user?: {
5
+ id: number;
6
+ role: UserRole;
7
+ } | null): boolean;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.canModifyCommunication = canModifyCommunication;
4
+ const user_1 = require("../types/api/user");
5
+ function canModifyCommunication(communication, user) {
6
+ if (!user) {
7
+ return false;
8
+ }
9
+ return (user.role === user_1.UserRole.ADMIN ||
10
+ !communication.userId ||
11
+ communication.userId === user.id);
12
+ }
@@ -1,2 +1,3 @@
1
1
  export * from "./working-days";
2
+ export * from "./communication";
2
3
  export * from "./volunteer-types";
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./working-days"), exports);
18
+ __exportStar(require("./communication"), exports);
18
19
  __exportStar(require("./volunteer-types"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "need4deed-sdk",
3
- "version": "0.0.190",
3
+ "version": "0.0.192",
4
4
  "description": "Need4Deed.org SDK",
5
5
  "type": "commonjs",
6
6
  "main": "dist/index.js",