generaltranslation 8.2.17 → 8.2.19
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/CHANGELOG.md +12 -0
- package/dist/id/hashSource.d.ts +1 -1
- package/dist/id/hashSource.js +2 -2
- package/dist/id/types.d.ts +1 -0
- package/dist/{id-DEaFhGqX.mjs → id-BS-dC63I.mjs} +3 -2
- package/dist/id-BS-dC63I.mjs.map +1 -0
- package/dist/{id-C2orn1MA.cjs → id-BrGkL9bC.cjs} +3 -2
- package/dist/id-BrGkL9bC.cjs.map +1 -0
- package/dist/id.cjs +1 -1
- package/dist/id.d.cts +2 -1
- package/dist/id.d.mts +2 -1
- package/dist/id.mjs +1 -1
- package/dist/index.cjs +28 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -2
- package/dist/index.d.mts +21 -2
- package/dist/index.d.ts +8 -0
- package/dist/index.js +20 -0
- package/dist/index.mjs +28 -5
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.mts +1 -1
- package/dist/translate/enqueueFiles.d.ts +0 -1
- package/dist/translate/enqueueFiles.js +0 -1
- package/dist/translate/getProjectInfo.d.ts +11 -0
- package/dist/translate/getProjectInfo.js +54 -0
- package/dist/translate/queryFileData.d.ts +0 -1
- package/dist/translate/utils/generateRequestHeaders.js +2 -7
- package/dist/{types-CdRgQtET.d.cts → types-Czjib__7.d.cts} +4 -7
- package/dist/{types-Db2Dn3oN.d.mts → types-Dr51dZ5s.d.mts} +4 -7
- package/dist/types-dir/api/checkFileTranslations.d.ts +0 -1
- package/dist/types-dir/api/enqueueEntries.d.ts +0 -2
- package/dist/types-dir/api/enqueueFiles.d.ts +1 -2
- package/dist/types.d.cts +1 -1
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
- package/dist/id-C2orn1MA.cjs.map +0 -1
- package/dist/id-DEaFhGqX.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# generaltranslation
|
|
2
2
|
|
|
3
|
+
## 8.2.19
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1786](https://github.com/generaltranslation/gt/pull/1786) [`6945a98`](https://github.com/generaltranslation/gt/commit/6945a9871ea260dd999dcb2246c48b21134721f6) Thanks [@fernando-aviles](https://github.com/fernando-aviles)! - Add `requiresReview`
|
|
8
|
+
|
|
9
|
+
## 8.2.18
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#1648](https://github.com/generaltranslation/gt/pull/1648) [`9709a2f`](https://github.com/generaltranslation/gt/commit/9709a2f2b97b9d8239298e39bb31e57692bbffd8) Thanks [@brian-lou](https://github.com/brian-lou)! - Use `gt-project-id` instead of `x-gt-project-id` for API request headers. Update the API key header to use standard `Authorization: Bearer <api-key>` prefix.
|
|
14
|
+
|
|
3
15
|
## 8.2.17
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/id/hashSource.d.ts
CHANGED
|
@@ -20,6 +20,6 @@ export declare function hashString(string: string): string;
|
|
|
20
20
|
* @param {function} [hashFunction] - Custom hash function.
|
|
21
21
|
* @returns {string} - The unique hash of the children.
|
|
22
22
|
*/
|
|
23
|
-
export declare function hashSource({ source, context, id, maxChars, dataFormat, }: {
|
|
23
|
+
export declare function hashSource({ source, context, id, maxChars, requiresReview, dataFormat, }: {
|
|
24
24
|
source: JsxChildren | string;
|
|
25
25
|
} & HashMetadata, hashFunction?: (string: string) => string): string;
|
package/dist/id/hashSource.js
CHANGED
|
@@ -38,7 +38,7 @@ export function hashString(string) {
|
|
|
38
38
|
* @returns {string} - The unique hash of the children.
|
|
39
39
|
*/
|
|
40
40
|
export function hashSource(_a, hashFunction) {
|
|
41
|
-
var source = _a.source, context = _a.context, id = _a.id, maxChars = _a.maxChars, dataFormat = _a.dataFormat;
|
|
41
|
+
var source = _a.source, context = _a.context, id = _a.id, maxChars = _a.maxChars, requiresReview = _a.requiresReview, dataFormat = _a.dataFormat;
|
|
42
42
|
if (hashFunction === void 0) { hashFunction = hashString; }
|
|
43
43
|
var sanitizedSource;
|
|
44
44
|
if (dataFormat === 'JSX') {
|
|
@@ -47,7 +47,7 @@ export function hashSource(_a, hashFunction) {
|
|
|
47
47
|
else {
|
|
48
48
|
sanitizedSource = source;
|
|
49
49
|
}
|
|
50
|
-
var sanitizedData = __assign(__assign(__assign(__assign({ source: sanitizedSource }, (id && { id: id })), (context && { context: context })), (maxChars != null && { maxChars: Math.abs(maxChars) })), (dataFormat && { dataFormat: dataFormat }));
|
|
50
|
+
var sanitizedData = __assign(__assign(__assign(__assign(__assign({ source: sanitizedSource }, (id && { id: id })), (context && { context: context })), (maxChars != null && { maxChars: Math.abs(maxChars) })), (requiresReview === true && { requiresReview: true })), (dataFormat && { dataFormat: dataFormat }));
|
|
51
51
|
var stringifiedData = stringify(sanitizedData);
|
|
52
52
|
return hashFunction(stringifiedData);
|
|
53
53
|
}
|
package/dist/id/types.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ function hashString(string) {
|
|
|
24
24
|
* @param {function} [hashFunction] - Custom hash function.
|
|
25
25
|
* @returns {string} - The unique hash of the children.
|
|
26
26
|
*/
|
|
27
|
-
function hashSource({ source, context, id, maxChars, dataFormat }, hashFunction = hashString) {
|
|
27
|
+
function hashSource({ source, context, id, maxChars, requiresReview, dataFormat }, hashFunction = hashString) {
|
|
28
28
|
let sanitizedSource;
|
|
29
29
|
if (dataFormat === "JSX") sanitizedSource = sanitizeJsxChildren(source);
|
|
30
30
|
else sanitizedSource = source;
|
|
@@ -33,6 +33,7 @@ function hashSource({ source, context, id, maxChars, dataFormat }, hashFunction
|
|
|
33
33
|
...id && { id },
|
|
34
34
|
...context && { context },
|
|
35
35
|
...maxChars != null && { maxChars: Math.abs(maxChars) },
|
|
36
|
+
...requiresReview === true && { requiresReview: true },
|
|
36
37
|
...dataFormat && { dataFormat }
|
|
37
38
|
}));
|
|
38
39
|
}
|
|
@@ -71,4 +72,4 @@ function hashTemplate(template, hashFunction = hashString) {
|
|
|
71
72
|
//#endregion
|
|
72
73
|
export { hashSource as n, hashString as r, hashTemplate as t };
|
|
73
74
|
|
|
74
|
-
//# sourceMappingURL=id-
|
|
75
|
+
//# sourceMappingURL=id-BS-dC63I.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id-BS-dC63I.mjs","names":["stringify","stringify"],"sources":["../src/id/hashSource.ts","../src/id/hashTemplate.ts"],"sourcesContent":["// Functions provided to other GT libraries\n\nimport { JsxChild, JsxChildren, Variable } from '../types';\nimport { stableStringify as stringify } from '../utils/stableStringify';\nimport { sha256 } from '@noble/hashes/sha2.js';\nimport { bytesToHex, utf8ToBytes } from '@noble/hashes/utils.js';\nimport isVariable from '../utils/isVariable';\nimport { HashMetadata } from './types';\n\n// ----- FUNCTIONS ----- //\n/**\n * Calculates a unique hash for a given string using SHA-256.\n *\n * First 16 characters of hash, hex encoded.\n *\n * @param {string} string - The string to be hashed.\n * @returns {string} The resulting hash as a hexadecimal string.\n */\nexport function hashString(string: string): string {\n return bytesToHex(sha256(utf8ToBytes(string))).slice(0, 16);\n}\n\n/**\n * Calculates a unique ID for the given children objects by hashing their sanitized JSON string representation.\n *\n * @param {any} childrenAsObjects - The children objects to be hashed.\n * @param {string} [context] - The context for the children.\n * @param {string} [id] - The ID for the JSX children object.\n * @param {number} [maxChars] - The maxChars limit for the JSX children object.\n * @param {string} [dataFormat] - The data format of the sources.\n * @param {function} [hashFunction] - Custom hash function.\n * @returns {string} - The unique hash of the children.\n */\nexport function hashSource(\n {\n source,\n context,\n id,\n maxChars,\n requiresReview,\n dataFormat,\n }: {\n source: JsxChildren | string;\n } & HashMetadata,\n hashFunction: (string: string) => string = hashString\n): string {\n let sanitizedSource: SanitizedChildren | string;\n if (dataFormat === 'JSX') {\n sanitizedSource = sanitizeJsxChildren(source);\n } else {\n sanitizedSource = source as string;\n }\n const sanitizedData: {\n source?: SanitizedChildren;\n } & HashMetadata = {\n source: sanitizedSource,\n ...(id && { id }),\n ...(context && { context }),\n ...(maxChars != null && { maxChars: Math.abs(maxChars) }),\n // Only mixed in when true: false/absent must hash identically to\n // pre-requiresReview versions so existing projects keep their hashes\n ...(requiresReview === true && { requiresReview: true }),\n ...(dataFormat && { dataFormat }),\n };\n const stringifiedData = stringify(sanitizedData);\n return hashFunction(stringifiedData);\n}\n\ntype SanitizedVariable = Omit<Variable, 'i'>;\n\ntype SanitizedElement = {\n b?: {\n [k: string]: SanitizedChildren; // Branches\n };\n c?: SanitizedChildren; // Children\n t?: string; // Branch Transformation\n};\ntype SanitizedChild = SanitizedElement | SanitizedVariable | string;\ntype SanitizedChildren = SanitizedChild | SanitizedChild[];\n\n/**\n * Sanitizes a child object by removing the data-_gt attribute and its branches.\n *\n * @param child - The child object to sanitize.\n * @returns The sanitized child object.\n *\n */\nconst sanitizeChild = (child: JsxChild): SanitizedChild => {\n if (child && typeof child === 'object') {\n const newChild: SanitizedChild = {};\n if ('c' in child && child.c) {\n newChild.c = sanitizeJsxChildren(child.c);\n }\n if ('d' in child) {\n const generaltranslation = child?.d;\n if (generaltranslation?.b) {\n // The only thing that prevents sanitizeJsx from being stable is\n // the order of the keys in the branches object.\n // We don't sort them because stable-stringify sorts them anyways\n newChild.b = Object.fromEntries(\n Object.entries(generaltranslation.b).map(([key, value]) => [\n key,\n sanitizeJsxChildren(value as JsxChildren),\n ])\n );\n }\n if (generaltranslation?.t) {\n newChild.t = generaltranslation.t;\n }\n }\n if (isVariable(child)) {\n return {\n k: child.k,\n ...(child.v && {\n v: child.v,\n }),\n };\n }\n return newChild;\n }\n return child;\n};\n\nfunction sanitizeJsxChildren(\n childrenAsObjects: JsxChildren\n): SanitizedChildren {\n return Array.isArray(childrenAsObjects)\n ? childrenAsObjects.map(sanitizeChild)\n : sanitizeChild(childrenAsObjects);\n}\n","import { hashString } from './hashSource';\nimport { stableStringify as stringify } from '../utils/stableStringify';\n\nexport default function hashTemplate(\n template: {\n [key: string]: string;\n },\n hashFunction = hashString\n): string {\n return hashFunction(stringify(template));\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,SAAgB,WAAW,QAAwB;AACjD,QAAO,WAAW,OAAO,YAAY,OAAO,CAAC,CAAC,CAAC,MAAM,GAAG,GAAG;;;;;;;;;;;;;AAc7D,SAAgB,WACd,EACE,QACA,SACA,IACA,UACA,gBACA,cAIF,eAA2C,YACnC;CACR,IAAI;AACJ,KAAI,eAAe,MACjB,mBAAkB,oBAAoB,OAAO;KAE7C,mBAAkB;AAepB,QAAO,aADiBA,gBAAU;EAThC,QAAQ;EACR,GAAI,MAAM,EAAE,IAAI;EAChB,GAAI,WAAW,EAAE,SAAS;EAC1B,GAAI,YAAY,QAAQ,EAAE,UAAU,KAAK,IAAI,SAAS,EAAE;EAGxD,GAAI,mBAAmB,QAAQ,EAAE,gBAAgB,MAAM;EACvD,GAAI,cAAc,EAAE,YAAY;EAEa,CACZ,CAAC;;;;;;;;;AAsBtC,MAAM,iBAAiB,UAAoC;AACzD,KAAI,SAAS,OAAO,UAAU,UAAU;EACtC,MAAM,WAA2B,EAAE;AACnC,MAAI,OAAO,SAAS,MAAM,EACxB,UAAS,IAAI,oBAAoB,MAAM,EAAE;AAE3C,MAAI,OAAO,OAAO;GAChB,MAAM,qBAAqB,OAAO;AAClC,OAAI,oBAAoB,EAItB,UAAS,IAAI,OAAO,YAClB,OAAO,QAAQ,mBAAmB,EAAE,CAAC,KAAK,CAAC,KAAK,WAAW,CACzD,KACA,oBAAoB,MAAqB,CAC1C,CAAC,CACH;AAEH,OAAI,oBAAoB,EACtB,UAAS,IAAI,mBAAmB;;AAGpC,MAAI,WAAW,MAAM,CACnB,QAAO;GACL,GAAG,MAAM;GACT,GAAI,MAAM,KAAK,EACb,GAAG,MAAM,GACV;GACF;AAEH,SAAO;;AAET,QAAO;;AAGT,SAAS,oBACP,mBACmB;AACnB,QAAO,MAAM,QAAQ,kBAAkB,GACnC,kBAAkB,IAAI,cAAc,GACpC,cAAc,kBAAkB;;;;AC7HtC,SAAwB,aACtB,UAGA,eAAe,YACP;AACR,QAAO,aAAaC,gBAAU,SAAS,CAAC"}
|
|
@@ -22,7 +22,7 @@ function hashString(string) {
|
|
|
22
22
|
* @param {function} [hashFunction] - Custom hash function.
|
|
23
23
|
* @returns {string} - The unique hash of the children.
|
|
24
24
|
*/
|
|
25
|
-
function hashSource({ source, context, id, maxChars, dataFormat }, hashFunction = hashString) {
|
|
25
|
+
function hashSource({ source, context, id, maxChars, requiresReview, dataFormat }, hashFunction = hashString) {
|
|
26
26
|
let sanitizedSource;
|
|
27
27
|
if (dataFormat === "JSX") sanitizedSource = sanitizeJsxChildren(source);
|
|
28
28
|
else sanitizedSource = source;
|
|
@@ -31,6 +31,7 @@ function hashSource({ source, context, id, maxChars, dataFormat }, hashFunction
|
|
|
31
31
|
...id && { id },
|
|
32
32
|
...context && { context },
|
|
33
33
|
...maxChars != null && { maxChars: Math.abs(maxChars) },
|
|
34
|
+
...requiresReview === true && { requiresReview: true },
|
|
34
35
|
...dataFormat && { dataFormat }
|
|
35
36
|
}));
|
|
36
37
|
}
|
|
@@ -86,4 +87,4 @@ Object.defineProperty(exports, "hashTemplate", {
|
|
|
86
87
|
}
|
|
87
88
|
});
|
|
88
89
|
|
|
89
|
-
//# sourceMappingURL=id-
|
|
90
|
+
//# sourceMappingURL=id-BrGkL9bC.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id-BrGkL9bC.cjs","names":["bytesToHex","sha256","utf8ToBytes","stringify","isVariable","stringify"],"sources":["../src/id/hashSource.ts","../src/id/hashTemplate.ts"],"sourcesContent":["// Functions provided to other GT libraries\n\nimport { JsxChild, JsxChildren, Variable } from '../types';\nimport { stableStringify as stringify } from '../utils/stableStringify';\nimport { sha256 } from '@noble/hashes/sha2.js';\nimport { bytesToHex, utf8ToBytes } from '@noble/hashes/utils.js';\nimport isVariable from '../utils/isVariable';\nimport { HashMetadata } from './types';\n\n// ----- FUNCTIONS ----- //\n/**\n * Calculates a unique hash for a given string using SHA-256.\n *\n * First 16 characters of hash, hex encoded.\n *\n * @param {string} string - The string to be hashed.\n * @returns {string} The resulting hash as a hexadecimal string.\n */\nexport function hashString(string: string): string {\n return bytesToHex(sha256(utf8ToBytes(string))).slice(0, 16);\n}\n\n/**\n * Calculates a unique ID for the given children objects by hashing their sanitized JSON string representation.\n *\n * @param {any} childrenAsObjects - The children objects to be hashed.\n * @param {string} [context] - The context for the children.\n * @param {string} [id] - The ID for the JSX children object.\n * @param {number} [maxChars] - The maxChars limit for the JSX children object.\n * @param {string} [dataFormat] - The data format of the sources.\n * @param {function} [hashFunction] - Custom hash function.\n * @returns {string} - The unique hash of the children.\n */\nexport function hashSource(\n {\n source,\n context,\n id,\n maxChars,\n requiresReview,\n dataFormat,\n }: {\n source: JsxChildren | string;\n } & HashMetadata,\n hashFunction: (string: string) => string = hashString\n): string {\n let sanitizedSource: SanitizedChildren | string;\n if (dataFormat === 'JSX') {\n sanitizedSource = sanitizeJsxChildren(source);\n } else {\n sanitizedSource = source as string;\n }\n const sanitizedData: {\n source?: SanitizedChildren;\n } & HashMetadata = {\n source: sanitizedSource,\n ...(id && { id }),\n ...(context && { context }),\n ...(maxChars != null && { maxChars: Math.abs(maxChars) }),\n // Only mixed in when true: false/absent must hash identically to\n // pre-requiresReview versions so existing projects keep their hashes\n ...(requiresReview === true && { requiresReview: true }),\n ...(dataFormat && { dataFormat }),\n };\n const stringifiedData = stringify(sanitizedData);\n return hashFunction(stringifiedData);\n}\n\ntype SanitizedVariable = Omit<Variable, 'i'>;\n\ntype SanitizedElement = {\n b?: {\n [k: string]: SanitizedChildren; // Branches\n };\n c?: SanitizedChildren; // Children\n t?: string; // Branch Transformation\n};\ntype SanitizedChild = SanitizedElement | SanitizedVariable | string;\ntype SanitizedChildren = SanitizedChild | SanitizedChild[];\n\n/**\n * Sanitizes a child object by removing the data-_gt attribute and its branches.\n *\n * @param child - The child object to sanitize.\n * @returns The sanitized child object.\n *\n */\nconst sanitizeChild = (child: JsxChild): SanitizedChild => {\n if (child && typeof child === 'object') {\n const newChild: SanitizedChild = {};\n if ('c' in child && child.c) {\n newChild.c = sanitizeJsxChildren(child.c);\n }\n if ('d' in child) {\n const generaltranslation = child?.d;\n if (generaltranslation?.b) {\n // The only thing that prevents sanitizeJsx from being stable is\n // the order of the keys in the branches object.\n // We don't sort them because stable-stringify sorts them anyways\n newChild.b = Object.fromEntries(\n Object.entries(generaltranslation.b).map(([key, value]) => [\n key,\n sanitizeJsxChildren(value as JsxChildren),\n ])\n );\n }\n if (generaltranslation?.t) {\n newChild.t = generaltranslation.t;\n }\n }\n if (isVariable(child)) {\n return {\n k: child.k,\n ...(child.v && {\n v: child.v,\n }),\n };\n }\n return newChild;\n }\n return child;\n};\n\nfunction sanitizeJsxChildren(\n childrenAsObjects: JsxChildren\n): SanitizedChildren {\n return Array.isArray(childrenAsObjects)\n ? childrenAsObjects.map(sanitizeChild)\n : sanitizeChild(childrenAsObjects);\n}\n","import { hashString } from './hashSource';\nimport { stableStringify as stringify } from '../utils/stableStringify';\n\nexport default function hashTemplate(\n template: {\n [key: string]: string;\n },\n hashFunction = hashString\n): string {\n return hashFunction(stringify(template));\n}\n"],"mappings":";;;;;;;;;;AAkBA,SAAgB,WAAW,QAAwB;AACjD,QAAOA,mBAAAA,WAAWC,mBAAAA,OAAOC,mBAAAA,YAAY,OAAO,CAAC,CAAC,CAAC,MAAM,GAAG,GAAG;;;;;;;;;;;;;AAc7D,SAAgB,WACd,EACE,QACA,SACA,IACA,UACA,gBACA,cAIF,eAA2C,YACnC;CACR,IAAI;AACJ,KAAI,eAAe,MACjB,mBAAkB,oBAAoB,OAAO;KAE7C,mBAAkB;AAepB,QAAO,aADiBC,mBAAAA,gBAAU;EAThC,QAAQ;EACR,GAAI,MAAM,EAAE,IAAI;EAChB,GAAI,WAAW,EAAE,SAAS;EAC1B,GAAI,YAAY,QAAQ,EAAE,UAAU,KAAK,IAAI,SAAS,EAAE;EAGxD,GAAI,mBAAmB,QAAQ,EAAE,gBAAgB,MAAM;EACvD,GAAI,cAAc,EAAE,YAAY;EAEa,CACZ,CAAC;;;;;;;;;AAsBtC,MAAM,iBAAiB,UAAoC;AACzD,KAAI,SAAS,OAAO,UAAU,UAAU;EACtC,MAAM,WAA2B,EAAE;AACnC,MAAI,OAAO,SAAS,MAAM,EACxB,UAAS,IAAI,oBAAoB,MAAM,EAAE;AAE3C,MAAI,OAAO,OAAO;GAChB,MAAM,qBAAqB,OAAO;AAClC,OAAI,oBAAoB,EAItB,UAAS,IAAI,OAAO,YAClB,OAAO,QAAQ,mBAAmB,EAAE,CAAC,KAAK,CAAC,KAAK,WAAW,CACzD,KACA,oBAAoB,MAAqB,CAC1C,CAAC,CACH;AAEH,OAAI,oBAAoB,EACtB,UAAS,IAAI,mBAAmB;;AAGpC,MAAIC,mBAAAA,WAAW,MAAM,CACnB,QAAO;GACL,GAAG,MAAM;GACT,GAAI,MAAM,KAAK,EACb,GAAG,MAAM,GACV;GACF;AAEH,SAAO;;AAET,QAAO;;AAGT,SAAS,oBACP,mBACmB;AACnB,QAAO,MAAM,QAAQ,kBAAkB,GACnC,kBAAkB,IAAI,cAAc,GACpC,cAAc,kBAAkB;;;;AC7HtC,SAAwB,aACtB,UAGA,eAAe,YACP;AACR,QAAO,aAAaC,mBAAAA,gBAAU,SAAS,CAAC"}
|
package/dist/id.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_id = require("./id-
|
|
2
|
+
const require_id = require("./id-BrGkL9bC.cjs");
|
|
3
3
|
exports.hashSource = require_id.hashSource;
|
|
4
4
|
exports.hashString = require_id.hashString;
|
|
5
5
|
exports.hashTemplate = require_id.hashTemplate;
|
package/dist/id.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Nt as HashMetadata, g as JsxChildren } from "./types-
|
|
1
|
+
import { Nt as HashMetadata, g as JsxChildren } from "./types-Czjib__7.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/id/hashSource.d.ts
|
|
4
4
|
/**
|
|
@@ -26,6 +26,7 @@ declare function hashSource({
|
|
|
26
26
|
context,
|
|
27
27
|
id,
|
|
28
28
|
maxChars,
|
|
29
|
+
requiresReview,
|
|
29
30
|
dataFormat
|
|
30
31
|
}: {
|
|
31
32
|
source: JsxChildren | string;
|
package/dist/id.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Nt as HashMetadata, g as JsxChildren } from "./types-
|
|
1
|
+
import { Nt as HashMetadata, g as JsxChildren } from "./types-Dr51dZ5s.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/id/hashSource.d.ts
|
|
4
4
|
/**
|
|
@@ -26,6 +26,7 @@ declare function hashSource({
|
|
|
26
26
|
context,
|
|
27
27
|
id,
|
|
28
28
|
maxChars,
|
|
29
|
+
requiresReview,
|
|
29
30
|
dataFormat
|
|
30
31
|
}: {
|
|
31
32
|
source: JsxChildren | string;
|
package/dist/id.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as hashSource, r as hashString, t as hashTemplate } from "./id-
|
|
1
|
+
import { n as hashSource, r as hashString, t as hashTemplate } from "./id-BS-dC63I.mjs";
|
|
2
2
|
export { hashSource, hashString, hashTemplate };
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_base64 = require("./base64-YBGAXkqy.cjs");
|
|
3
3
|
const require_ApiError = require("./ApiError-D-IBuHj6.cjs");
|
|
4
|
-
const require_id = require("./id-
|
|
4
|
+
const require_id = require("./id-BrGkL9bC.cjs");
|
|
5
5
|
let _generaltranslation_format = require("@generaltranslation/format");
|
|
6
6
|
//#region src/logging/errors.ts
|
|
7
7
|
const GT_SOURCE = "GT";
|
|
@@ -330,10 +330,9 @@ const API_VERSION$1 = "2026-03-06.v1";
|
|
|
330
330
|
function generateRequestHeaders(config, excludeContentType = false) {
|
|
331
331
|
const authHeaders = {
|
|
332
332
|
...!excludeContentType && { "Content-Type": "application/json" },
|
|
333
|
-
"
|
|
333
|
+
"gt-project-id": config.projectId
|
|
334
334
|
};
|
|
335
|
-
if (config.apiKey)
|
|
336
|
-
else authHeaders["x-gt-api-key"] = config.apiKey;
|
|
335
|
+
if (config.apiKey) authHeaders["Authorization"] = `Bearer ${config.apiKey}`;
|
|
337
336
|
authHeaders["gt-api-version"] = API_VERSION$1;
|
|
338
337
|
return authHeaders;
|
|
339
338
|
}
|
|
@@ -565,7 +564,6 @@ async function _enqueueFiles(files, options, config) {
|
|
|
565
564
|
})),
|
|
566
565
|
targetLocales: options.targetLocales,
|
|
567
566
|
sourceLocale: options.sourceLocale,
|
|
568
|
-
requireApproval: options.requireApproval,
|
|
569
567
|
modelProvider: options.modelProvider,
|
|
570
568
|
force: options.force
|
|
571
569
|
},
|
|
@@ -849,6 +847,21 @@ async function _queryFileData(data, options = {}, config) {
|
|
|
849
847
|
});
|
|
850
848
|
}
|
|
851
849
|
//#endregion
|
|
850
|
+
//#region src/translate/getProjectInfo.ts
|
|
851
|
+
/**
|
|
852
|
+
* @internal
|
|
853
|
+
* Fetches project info (name, locales, review settings) for a project.
|
|
854
|
+
* @param options - The options for the API call.
|
|
855
|
+
* @param config - The configuration for the API call.
|
|
856
|
+
* @returns The project info.
|
|
857
|
+
*/
|
|
858
|
+
async function _getProjectInfo(options, config) {
|
|
859
|
+
return apiRequest(config, `/v2/project/info/${config.projectId}`, {
|
|
860
|
+
method: "GET",
|
|
861
|
+
timeout: options.timeout
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
//#endregion
|
|
852
865
|
//#region src/translate/queryBranchData.ts
|
|
853
866
|
/**
|
|
854
867
|
* @internal
|
|
@@ -1256,6 +1269,16 @@ var GT = class {
|
|
|
1256
1269
|
* });
|
|
1257
1270
|
*
|
|
1258
1271
|
*/
|
|
1272
|
+
/**
|
|
1273
|
+
* Fetches project info (name, locales, review settings) for the
|
|
1274
|
+
* authenticated project.
|
|
1275
|
+
* @param options - The options for the API call.
|
|
1276
|
+
* @returns The project info.
|
|
1277
|
+
*/
|
|
1278
|
+
async getProjectInfo(options = {}) {
|
|
1279
|
+
this._validateAuth("getProjectInfo");
|
|
1280
|
+
return await _getProjectInfo(options, this._getTranslationConfig());
|
|
1281
|
+
}
|
|
1259
1282
|
async queryFileData(data, options = {}) {
|
|
1260
1283
|
this._validateAuth("queryFileData");
|
|
1261
1284
|
data.translatedFiles = data.translatedFiles?.map((item) => ({
|