@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.
@@ -316,3 +316,4 @@ export interface SharedBookContactPermissionParamsDto extends ReturnType<typeof
316
316
  export interface UpdateSharedBookContactPermissionDto extends CreateSharedBookContactPermissionDto {
317
317
  }
318
318
  export {};
319
+ export const DB_ACTUAL_VERSION = '1';
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"}
@@ -316,3 +316,4 @@ export interface SharedBookContactPermissionParamsDto extends ReturnType<typeof
316
316
  export interface UpdateSharedBookContactPermissionDto extends CreateSharedBookContactPermissionDto {
317
317
  }
318
318
  export {};
319
+ export const DB_ACTUAL_VERSION = '1';
package/dist/esm/index.js CHANGED
@@ -30,3 +30,4 @@ export var SharedBookStatus;
30
30
  SharedBookStatus["deletedFromTarget"] = "deletedFromTarget";
31
31
  SharedBookStatus["deletedFromSource"] = "deletedFromSource";
32
32
  })(SharedBookStatus || (SharedBookStatus = {}));
33
+ export var DB_ACTUAL_VERSION = '1';
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.5",
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:types": "pnpm generate && pnpm 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
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "module": "commonjs",
5
+ "preserveSymlinks": true
6
+ },
7
+ "include": [
8
+ "./scripts/inject-versions.ts"
9
+ ],
10
+ "ts-node": {
11
+ "skipIgnore": true
12
+ }
13
+ }
14
+