@glissandoo/lib 1.104.1 → 1.104.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/helpers/communicationTemplate/index.d.ts +32 -0
- package/helpers/communicationTemplate/index.js +45 -0
- package/helpers/communicationTemplate/newGroup.d.ts +3 -0
- package/helpers/communicationTemplate/newGroup.js +611 -0
- package/helpers/communicationTemplate/newMember.d.ts +3 -0
- package/helpers/communicationTemplate/newMember.js +176 -0
- package/lang/ca.json +2 -0
- package/lang/de.json +2 -0
- package/lang/en.json +2 -0
- package/lang/es.json +2 -0
- package/lang/eu.json +2 -0
- package/lang/fr.json +2 -0
- package/lang/gl.json +2 -0
- package/lang/it.json +2 -0
- package/lang/nl.json +2 -0
- package/lang/pt.json +2 -0
- package/models/Communication/index.d.ts +5 -2
- package/models/Communication/index.js +5 -5
- package/models/Communication/types.d.ts +6 -0
- package/models/Evento/index.js +3 -2
- package/models/Group/index.d.ts +1 -1
- package/models/Group/index.js +3 -3
- package/models/Notification/types.d.ts +1 -0
- package/models/Notification/types.js +1 -0
- package/package.json +2 -2
- package/types/supabase/generated.d.ts +208 -0
- package/types/supabase/generated.ts +196 -86
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { LanguagesTypes } from '../../lang';
|
|
2
|
+
export declare enum CommunicationTemplateType {
|
|
3
|
+
NewGroup = "newGroup",
|
|
4
|
+
NewMember = "newMember"
|
|
5
|
+
}
|
|
6
|
+
export interface CommunicationTemplateData {
|
|
7
|
+
title: string;
|
|
8
|
+
message: any;
|
|
9
|
+
}
|
|
10
|
+
export type CommunicationTemplateLangs = Record<LanguagesTypes, CommunicationTemplateData>;
|
|
11
|
+
export interface CommunicationTemplatesVars {
|
|
12
|
+
[CommunicationTemplateType.NewGroup]: {
|
|
13
|
+
title: {
|
|
14
|
+
name: string;
|
|
15
|
+
};
|
|
16
|
+
message: Record<string, never>;
|
|
17
|
+
};
|
|
18
|
+
[CommunicationTemplateType.NewMember]: {
|
|
19
|
+
title: {
|
|
20
|
+
userName: string;
|
|
21
|
+
};
|
|
22
|
+
message: {
|
|
23
|
+
userDisplayName: string;
|
|
24
|
+
userInstrument: string;
|
|
25
|
+
groupDisplayName: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
declare const templates: Record<CommunicationTemplateType, CommunicationTemplateLangs>;
|
|
30
|
+
export declare const replaceKeysVarsString: <T extends string, D extends Record<string, string>>(text: T, meta: D) => string;
|
|
31
|
+
export declare function replaceKeysVarsInNodes<T extends Record<string, any>, D extends Record<string, string>>(nodes: T[], meta: D): T[];
|
|
32
|
+
export default templates;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.replaceKeysVarsInNodes = exports.replaceKeysVarsString = exports.CommunicationTemplateType = void 0;
|
|
7
|
+
const newGroup_1 = __importDefault(require("./newGroup"));
|
|
8
|
+
const newMember_1 = __importDefault(require("./newMember"));
|
|
9
|
+
var CommunicationTemplateType;
|
|
10
|
+
(function (CommunicationTemplateType) {
|
|
11
|
+
CommunicationTemplateType["NewGroup"] = "newGroup";
|
|
12
|
+
CommunicationTemplateType["NewMember"] = "newMember";
|
|
13
|
+
})(CommunicationTemplateType = exports.CommunicationTemplateType || (exports.CommunicationTemplateType = {}));
|
|
14
|
+
const templates = {
|
|
15
|
+
newGroup: newGroup_1.default,
|
|
16
|
+
newMember: newMember_1.default,
|
|
17
|
+
};
|
|
18
|
+
const replaceKeysVarsString = (text, meta) => {
|
|
19
|
+
const matches = text.match(/(\{).+?(\})/g);
|
|
20
|
+
if (!matches || matches.length === 0)
|
|
21
|
+
return text;
|
|
22
|
+
return matches.reduce((text, match) => {
|
|
23
|
+
const key = match.slice(1, -1);
|
|
24
|
+
if (!(key in meta))
|
|
25
|
+
return text;
|
|
26
|
+
return text.replace(match, meta[key]);
|
|
27
|
+
}, text);
|
|
28
|
+
};
|
|
29
|
+
exports.replaceKeysVarsString = replaceKeysVarsString;
|
|
30
|
+
function replaceKeysVarsInNodes(nodes, meta) {
|
|
31
|
+
return nodes.map((node) => {
|
|
32
|
+
const newNode = { ...node };
|
|
33
|
+
for (const key in newNode) {
|
|
34
|
+
if (typeof newNode[key] === 'string') {
|
|
35
|
+
newNode[key] = (0, exports.replaceKeysVarsString)(newNode[key], meta);
|
|
36
|
+
}
|
|
37
|
+
else if (Array.isArray(newNode[key])) {
|
|
38
|
+
newNode[key] = replaceKeysVarsInNodes(newNode[key], meta);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return newNode;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
exports.replaceKeysVarsInNodes = replaceKeysVarsInNodes;
|
|
45
|
+
exports.default = templates;
|