@onereach/types-contacts-api 5.18.5 → 5.18.6-beta.2830.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.
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/db-versions.json +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/package.json +5 -4
- package/scripts/inject-versions.ts +44 -0
- package/tsconfig.scripts.json +14 -0
package/dist/cjs/index.d.ts
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -33,3 +33,4 @@ var SharedBookStatus;
|
|
|
33
33
|
SharedBookStatus["deletedFromTarget"] = "deletedFromTarget";
|
|
34
34
|
SharedBookStatus["deletedFromSource"] = "deletedFromSource";
|
|
35
35
|
})(SharedBookStatus = exports.SharedBookStatus || (exports.SharedBookStatus = {}));
|
|
36
|
+
exports.DB_ACTUAL_VERSION = '1';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"actual":"1","description":"While upgrading the actual db version value add `previous` key to DB_VERSIONS, as an array of objects describing \"previous\" version. Example: DB_VERSIONS:\n actual : '3'\n previous:\n - dbVersion : '2'\n contactsVersion : '5.16.1'\n - dbVersion : '1'\n contactsVersion : '5.0.0'\n"}
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onereach/types-contacts-api",
|
|
3
3
|
"description": "Generated types for Contacts Api",
|
|
4
|
-
"version": "5.18.
|
|
4
|
+
"version": "5.18.6-beta.2830.0",
|
|
5
5
|
"author": "OneReach.ai",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
7
7
|
"module": "dist/esm/index.js",
|
|
@@ -15,13 +15,14 @@
|
|
|
15
15
|
"build:esm": "tsc --project tsconfig.build.esm.json",
|
|
16
16
|
"build:cjs": "tsc --project tsconfig.build.cjs.json",
|
|
17
17
|
"generate": "ts-node ./src/generate-types.ts",
|
|
18
|
-
"build:
|
|
18
|
+
"build:db-versions": "ts-node --project tsconfig.scripts.json ./scripts/inject-versions.ts",
|
|
19
|
+
"build:types": "pnpm generate && pnpm build && pnpm build:db-versions"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
|
21
22
|
"@types/node": "18.11.10",
|
|
23
|
+
"js-yaml": "^4.1.0",
|
|
22
24
|
"rimraf": "5.0.1",
|
|
23
25
|
"ts-morph": "17.0.1",
|
|
24
26
|
"ts-node": "10.9.1"
|
|
25
|
-
}
|
|
26
|
-
"gitHead": "25d78c80c9ef046239b8c6d70643b576ea4558fa"
|
|
27
|
+
}
|
|
27
28
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* script should be launched from the contacts-mono project root
|
|
3
|
+
*/
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import yaml from 'js-yaml';
|
|
6
|
+
|
|
7
|
+
const fileName = 'contacts_api.yaml';
|
|
8
|
+
const pathToFile = 'packages/api/config';
|
|
9
|
+
const dbVersionsPath = 'DB_VERSIONS';
|
|
10
|
+
const actualDbKey = 'actual';
|
|
11
|
+
const varName = 'DB_ACTUAL_VERSION';
|
|
12
|
+
|
|
13
|
+
const appendLineToFile = (file: string, line: string) => {
|
|
14
|
+
const doc = fs.readFileSync(file, 'utf-8');
|
|
15
|
+
const searchFor = line.slice(-3);
|
|
16
|
+
const cleanDoc = doc
|
|
17
|
+
.split(/\r?\n/)
|
|
18
|
+
.filter((l) => l.indexOf(searchFor) === -1)
|
|
19
|
+
.join('\n');
|
|
20
|
+
fs.writeFileSync(file, cleanDoc + line + '\n');
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
const doc = yaml.load(fs.readFileSync('../api/config/contacts_api.yaml', 'utf8'));
|
|
25
|
+
|
|
26
|
+
if (!(dbVersionsPath in doc)) {
|
|
27
|
+
throw new Error(`${dbVersionsPath} property has not been found in ${fileName}`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const actualDbVersion = doc[dbVersionsPath][actualDbKey];
|
|
31
|
+
if (!actualDbKey) {
|
|
32
|
+
throw new Error(`${
|
|
33
|
+
actualDbKey
|
|
34
|
+
} property has not been found in ${fileName} document, under the ${dbVersionsPath} path`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
appendLineToFile('dist/cjs/index.d.ts', `export const ${varName} = '${actualDbVersion}';`);
|
|
38
|
+
appendLineToFile('dist/cjs/index.js', `exports.${varName} = '${actualDbVersion}';`);
|
|
39
|
+
appendLineToFile('dist/esm/index.d.ts', `export const ${varName} = '${actualDbVersion}';`);
|
|
40
|
+
appendLineToFile('dist/esm/index.js', `export var ${varName} = '${actualDbVersion}';`);
|
|
41
|
+
fs.writeFileSync('dist/db-versions.json', JSON.stringify(doc[dbVersionsPath]));
|
|
42
|
+
} catch (e) {
|
|
43
|
+
console.error(`Could not read ${fileName} file in the from the ${pathToFile} due to the following error: ${e}`);
|
|
44
|
+
}
|