hunter-mate 0.1.12 → 0.1.14
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/assets/extension/background/service-worker.js +7 -0
- package/dist/assets/extension/build-info.json +1 -1
- package/dist/assets/extension/content/index.js +4 -3
- package/dist/assets/extension/manifest.json +1 -1
- package/dist/assets/extension/sidepanel/index.css +1 -1
- package/dist/assets/extension/sidepanel/index.js +30 -8
- package/dist/assets/server/app.module.js +4 -1
- package/dist/assets/server/app.module.js.map +1 -1
- package/dist/assets/server/auth/auth.controller.d.ts +14 -0
- package/dist/assets/server/auth/auth.controller.js +19 -0
- package/dist/assets/server/auth/auth.controller.js.map +1 -1
- package/dist/assets/server/auth/auth.module.js +4 -1
- package/dist/assets/server/auth/auth.module.js.map +1 -1
- package/dist/assets/server/auth/auth.service.d.ts +18 -1
- package/dist/assets/server/auth/auth.service.js +65 -2
- package/dist/assets/server/auth/auth.service.js.map +1 -1
- package/dist/assets/server/auth/saas-token.entity.d.ts +7 -0
- package/dist/assets/server/auth/saas-token.entity.js +46 -0
- package/dist/assets/server/auth/saas-token.entity.js.map +1 -0
- package/dist/assets/server/build-info.json +1 -1
- package/dist/assets/server/datasync/datasync.module.d.ts +2 -0
- package/dist/assets/server/datasync/datasync.module.js +26 -0
- package/dist/assets/server/datasync/datasync.module.js.map +1 -0
- package/dist/assets/server/datasync/datasync.service.d.ts +50 -0
- package/dist/assets/server/datasync/datasync.service.js +389 -0
- package/dist/assets/server/datasync/datasync.service.js.map +1 -0
- package/dist/assets/server/datasync/entities/sync-conflict.entity.d.ts +10 -0
- package/dist/assets/server/datasync/entities/sync-conflict.entity.js +61 -0
- package/dist/assets/server/datasync/entities/sync-conflict.entity.js.map +1 -0
- package/dist/assets/server/datasync/entities/sync-cursor.entity.d.ts +9 -0
- package/dist/assets/server/datasync/entities/sync-cursor.entity.js +56 -0
- package/dist/assets/server/datasync/entities/sync-cursor.entity.js.map +1 -0
- package/dist/assets/server/datasync/registry.d.ts +8 -0
- package/dist/assets/server/datasync/registry.js +55 -0
- package/dist/assets/server/datasync/registry.js.map +1 -0
- package/dist/assets/server/db/sqlite.module.js +6 -0
- package/dist/assets/server/db/sqlite.module.js.map +1 -1
- package/dist/assets/server/package.json +1 -0
- package/dist/commands/doctor.js +46 -0
- package/dist/commands/ops.js +45 -8
- package/dist/commands/update.js +5 -5
- package/dist/index.js +5 -1
- package/dist/updater.d.ts +95 -2
- package/dist/updater.js +372 -32
- package/dist/web/dist/404.html +1 -1
- package/dist/web/dist/_next/static/chunks/{539-5d0e8c5c238c56f8.js → 539-cd9d7c0ee78f8874.js} +1 -1
- package/dist/web/dist/_next/static/chunks/app/auth/verify/page-f13c66b48f7cf13e.js +1 -0
- package/dist/web/dist/_next/static/chunks/app/matching/jobs/[id]/talents/{page-f57f4b7529823601.js → page-cdf1ed0971999f35.js} +1 -1
- package/dist/web/dist/_next/static/chunks/app/matching/portraits/[id]/jobs/page-87f04f1d61b94cb2.js +1 -0
- package/dist/web/dist/_next/static/chunks/app/page-affa1ffde089f1dd.js +1 -0
- package/dist/web/dist/_next/static/chunks/app/parselog/{page-58d3acece95b4089.js → page-31d3630d611649f7.js} +1 -1
- package/dist/web/dist/_next/static/chunks/app/recordings/{page-e2e2e3c3a64083fb.js → page-9cdefceb2bff613f.js} +1 -1
- package/dist/web/dist/_next/static/chunks/app/snapshots/[id]/agent-prompt/page-6996f7f221b1a7eb.js +1 -0
- package/dist/web/dist/_next/static/chunks/{main-app-0af848156a5b13fc.js → main-app-cb4554c86eba200c.js} +1 -1
- package/dist/web/dist/_next/static/chunks/pages/{_app-3d844792ec91e4d1.js → _app-834b8a94a4a3c493.js} +2 -2
- package/dist/web/dist/_next/static/css/{db881c5b3072b88a.css → b7097b50a6497650.css} +1 -1
- package/dist/web/dist/auth/verify.html +1 -1
- package/dist/web/dist/auth/verify.txt +2 -2
- package/dist/web/dist/companies.html +1 -1
- package/dist/web/dist/companies.txt +2 -2
- package/dist/web/dist/entity.html +1 -1
- package/dist/web/dist/entity.txt +1 -1
- package/dist/web/dist/index.html +1 -1
- package/dist/web/dist/index.txt +2 -2
- package/dist/web/dist/jobs.html +1 -1
- package/dist/web/dist/jobs.txt +2 -2
- package/dist/web/dist/logs.html +1 -1
- package/dist/web/dist/logs.txt +1 -1
- package/dist/web/dist/matching/jobs/placeholder/talents.html +1 -1
- package/dist/web/dist/matching/jobs/placeholder/talents.txt +2 -2
- package/dist/web/dist/matching/portraits/placeholder/jobs.html +1 -1
- package/dist/web/dist/matching/portraits/placeholder/jobs.txt +2 -2
- package/dist/web/dist/parselog.html +1 -1
- package/dist/web/dist/parselog.txt +2 -2
- package/dist/web/dist/recordings.html +1 -1
- package/dist/web/dist/recordings.txt +2 -2
- package/dist/web/dist/snapshots/placeholder/agent-prompt.html +1 -1
- package/dist/web/dist/snapshots/placeholder/agent-prompt.txt +2 -2
- package/dist/web/dist/talents.html +1 -1
- package/dist/web/dist/talents.txt +2 -2
- package/package.json +3 -2
- package/dist/web/dist/_next/static/chunks/app/auth/verify/page-8e5cff53d6f7d8e1.js +0 -1
- package/dist/web/dist/_next/static/chunks/app/matching/portraits/[id]/jobs/page-614d1e62d7b9d215.js +0 -1
- package/dist/web/dist/_next/static/chunks/app/page-e3392de08ae81fba.js +0 -1
- package/dist/web/dist/_next/static/chunks/app/snapshots/[id]/agent-prompt/page-fd3b7d7373b8f8b7.js +0 -1
- /package/dist/web/dist/_next/static/{RSIT2tCOW5--9YD-rmuF7 → ZJtEh3uyN_mQhaXvrDYzJ}/_buildManifest.js +0 -0
- /package/dist/web/dist/_next/static/{RSIT2tCOW5--9YD-rmuF7 → ZJtEh3uyN_mQhaXvrDYzJ}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var DatasyncService_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.DatasyncService = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const config_1 = require("@nestjs/config");
|
|
19
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
20
|
+
const typeorm_2 = require("typeorm");
|
|
21
|
+
const crypto_1 = require("crypto");
|
|
22
|
+
const os = require("os");
|
|
23
|
+
const sync_cursor_entity_1 = require("./entities/sync-cursor.entity");
|
|
24
|
+
const sync_conflict_entity_1 = require("./entities/sync-conflict.entity");
|
|
25
|
+
const registry_1 = require("./registry");
|
|
26
|
+
const auth_service_1 = require("../auth/auth.service");
|
|
27
|
+
let DatasyncService = DatasyncService_1 = class DatasyncService {
|
|
28
|
+
config;
|
|
29
|
+
dataSource;
|
|
30
|
+
authService;
|
|
31
|
+
cursorRepo;
|
|
32
|
+
conflictRepo;
|
|
33
|
+
logger = new common_1.Logger(DatasyncService_1.name);
|
|
34
|
+
timer;
|
|
35
|
+
pushing = false;
|
|
36
|
+
pulling = false;
|
|
37
|
+
authFailed = false;
|
|
38
|
+
lastError = null;
|
|
39
|
+
constructor(config, dataSource, authService, cursorRepo, conflictRepo) {
|
|
40
|
+
this.config = config;
|
|
41
|
+
this.dataSource = dataSource;
|
|
42
|
+
this.authService = authService;
|
|
43
|
+
this.cursorRepo = cursorRepo;
|
|
44
|
+
this.conflictRepo = conflictRepo;
|
|
45
|
+
}
|
|
46
|
+
onApplicationBootstrap() {
|
|
47
|
+
if (!this.saasBaseUrl) {
|
|
48
|
+
this.logger.log('SaaS URL 未配置,数据同步停用(纯本地模式)');
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const first = Number(this.config.get('HM_SYNC_FIRST_DELAY_MS', 60_000));
|
|
52
|
+
const interval = Number(this.config.get('HM_SYNC_INTERVAL_MS', 10 * 60_000));
|
|
53
|
+
setTimeout(() => this.tick(), first);
|
|
54
|
+
this.timer = setInterval(() => this.tick(), interval);
|
|
55
|
+
this.timer.unref?.();
|
|
56
|
+
this.logger.log(`数据同步已调度:首延 ${first}ms,周期 ${interval}ms`);
|
|
57
|
+
}
|
|
58
|
+
async tick() {
|
|
59
|
+
await this.pushNow();
|
|
60
|
+
await this.pullNow();
|
|
61
|
+
}
|
|
62
|
+
onModuleDestroy() {
|
|
63
|
+
if (this.timer)
|
|
64
|
+
clearInterval(this.timer);
|
|
65
|
+
}
|
|
66
|
+
get saasBaseUrl() {
|
|
67
|
+
const base = this.config.get('HUNTER_MATE_SAAS_URL') ||
|
|
68
|
+
this.config.get('SAAS_URL') ||
|
|
69
|
+
'https://dev-ops.hiredchina.com';
|
|
70
|
+
return base ? base.replace(/\/$/, '') : undefined;
|
|
71
|
+
}
|
|
72
|
+
get syncUrl() {
|
|
73
|
+
return this.saasBaseUrl ? `${this.saasBaseUrl}/hunter-mate/sync/push` : undefined;
|
|
74
|
+
}
|
|
75
|
+
get deviceId() {
|
|
76
|
+
const override = this.config.get('HM_SYNC_DEVICE_ID');
|
|
77
|
+
return (override || `${os.userInfo().username}@${os.hostname()}`).slice(0, 64);
|
|
78
|
+
}
|
|
79
|
+
fingerprint(meta) {
|
|
80
|
+
const cols = meta.columns.map((c) => c.propertyName).sort().join(',');
|
|
81
|
+
return (0, crypto_1.createHash)('sha256')
|
|
82
|
+
.update(`${meta.tableName}:${cols}`)
|
|
83
|
+
.digest('hex')
|
|
84
|
+
.slice(0, 16);
|
|
85
|
+
}
|
|
86
|
+
getStatus() {
|
|
87
|
+
return {
|
|
88
|
+
enabled: Boolean(this.syncUrl),
|
|
89
|
+
authFailed: this.authFailed,
|
|
90
|
+
lastError: this.lastError,
|
|
91
|
+
entities: registry_1.SYNC_REGISTRY.length,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
async pushNow() {
|
|
95
|
+
if (!this.syncUrl || this.pushing)
|
|
96
|
+
return { skipped: 1 };
|
|
97
|
+
if (this.authFailed)
|
|
98
|
+
return { skipped: 'auth_failed' };
|
|
99
|
+
this.pushing = true;
|
|
100
|
+
const result = {};
|
|
101
|
+
try {
|
|
102
|
+
const token = await this.authService.getStoredSaasToken();
|
|
103
|
+
if (!token) {
|
|
104
|
+
this.lastError = 'no saas token stored; run `hunter-mate login --email`';
|
|
105
|
+
this.logger.warn(this.lastError);
|
|
106
|
+
result['skipped'] = 'no_token';
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
for (const cfg of registry_1.SYNC_REGISTRY) {
|
|
110
|
+
const table = this.tableOf(cfg);
|
|
111
|
+
try {
|
|
112
|
+
result[table] = await this.pushEntityNow(cfg, token.token);
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
const msg = err.message ?? String(err);
|
|
116
|
+
this.logger.warn(`push entity ${table} failed: ${msg}`);
|
|
117
|
+
result[table] = `ERR: ${msg}`;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
this.lastError = null;
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
catch (err) {
|
|
124
|
+
this.lastError = err.message ?? String(err);
|
|
125
|
+
this.logger.warn(`push failed: ${this.lastError}`);
|
|
126
|
+
result['error'] = this.lastError ?? 'unknown';
|
|
127
|
+
return result;
|
|
128
|
+
}
|
|
129
|
+
finally {
|
|
130
|
+
this.pushing = false;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
async pushEntityNow(cfg, jwt) {
|
|
134
|
+
return this.pushEntity(cfg, jwt);
|
|
135
|
+
}
|
|
136
|
+
tableOf(cfg) {
|
|
137
|
+
return this.dataSource.getMetadata(cfg.entity).tableName;
|
|
138
|
+
}
|
|
139
|
+
tsColumnOf(meta) {
|
|
140
|
+
const names = meta.columns.map((c) => c.propertyName);
|
|
141
|
+
if (names.includes('updatedAt'))
|
|
142
|
+
return 'updatedAt';
|
|
143
|
+
if (names.includes('createdAt'))
|
|
144
|
+
return 'createdAt';
|
|
145
|
+
const upd = meta.columns.find((c) => c.isUpdateDate);
|
|
146
|
+
if (upd)
|
|
147
|
+
return upd.propertyName;
|
|
148
|
+
const cre = meta.columns.find((c) => c.isCreateDate);
|
|
149
|
+
if (cre)
|
|
150
|
+
return cre.propertyName;
|
|
151
|
+
return 'createdAt';
|
|
152
|
+
}
|
|
153
|
+
tsOf(r, tsCol) {
|
|
154
|
+
const raw = r[tsCol] ?? r['createdAt'];
|
|
155
|
+
if (raw instanceof Date)
|
|
156
|
+
return raw;
|
|
157
|
+
const d = new Date(raw);
|
|
158
|
+
return Number.isNaN(d.getTime()) ? new Date(0) : d;
|
|
159
|
+
}
|
|
160
|
+
async ensureCursor(table) {
|
|
161
|
+
return ((await this.cursorRepo.findOne({ where: { entity: table } })) ??
|
|
162
|
+
(await this.cursorRepo.save({
|
|
163
|
+
entity: table,
|
|
164
|
+
pushedWatermark: null,
|
|
165
|
+
pushedIds: null,
|
|
166
|
+
pulledWatermark: null,
|
|
167
|
+
updatedAt: new Date(),
|
|
168
|
+
})));
|
|
169
|
+
}
|
|
170
|
+
async pushEntity(cfg, jwt) {
|
|
171
|
+
const meta = this.dataSource.getMetadata(cfg.entity);
|
|
172
|
+
const table = meta.tableName;
|
|
173
|
+
const pk = meta.primaryColumns[0]?.propertyName ?? 'id';
|
|
174
|
+
const tsCol = this.tsColumnOf(meta);
|
|
175
|
+
const fingerprint = this.fingerprint(meta);
|
|
176
|
+
const repo = this.dataSource.getRepository(cfg.entity);
|
|
177
|
+
const cursor = await this.ensureCursor(table);
|
|
178
|
+
let total = 0;
|
|
179
|
+
const BATCH = 200;
|
|
180
|
+
for (let page = 0; page < 10; page++) {
|
|
181
|
+
const qb = repo
|
|
182
|
+
.createQueryBuilder(table)
|
|
183
|
+
.orderBy(`${table}.${pk}`, 'ASC')
|
|
184
|
+
.take(BATCH);
|
|
185
|
+
if (cursor.pushedWatermark) {
|
|
186
|
+
qb.where(`datetime(${table}.${tsCol}) >= datetime(:wm)`, {
|
|
187
|
+
wm: cursor.pushedWatermark,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
const rows = await qb.getMany();
|
|
191
|
+
if (!rows.length)
|
|
192
|
+
break;
|
|
193
|
+
const pushedIds = cursor.pushedIds ? JSON.parse(cursor.pushedIds) : [];
|
|
194
|
+
const fresh = rows.filter((r) => !pushedIds.map(String).includes(String(r[pk])));
|
|
195
|
+
const items = fresh.map((r) => {
|
|
196
|
+
const ts = this.tsOf(r, tsCol);
|
|
197
|
+
return {
|
|
198
|
+
entity: table,
|
|
199
|
+
op: 'upsert',
|
|
200
|
+
clientRef: String(r[pk]),
|
|
201
|
+
payload: { ...r },
|
|
202
|
+
updatedAt: ts instanceof Date ? ts.toISOString() : new Date(ts).toISOString(),
|
|
203
|
+
schemaFingerprint: fingerprint,
|
|
204
|
+
};
|
|
205
|
+
});
|
|
206
|
+
if (items.length) {
|
|
207
|
+
const res = await fetch(this.syncUrl, {
|
|
208
|
+
method: 'POST',
|
|
209
|
+
headers: {
|
|
210
|
+
'Content-Type': 'application/json',
|
|
211
|
+
Authorization: `HMJWT ${jwt}`,
|
|
212
|
+
},
|
|
213
|
+
body: JSON.stringify({ deviceId: this.deviceId, items }),
|
|
214
|
+
});
|
|
215
|
+
if (res.status === 401) {
|
|
216
|
+
this.authFailed = true;
|
|
217
|
+
throw new Error('HMJWT rejected by dev-ops (expired?); re-run `hunter-mate login --email`');
|
|
218
|
+
}
|
|
219
|
+
if (!res.ok)
|
|
220
|
+
throw new Error(`HTTP ${res.status}`);
|
|
221
|
+
const body = await res.json();
|
|
222
|
+
if (body?.conflicts?.length) {
|
|
223
|
+
this.logger.warn(`${table}: ${body.conflicts.length} LWW conflicts (will resolve on pull)`);
|
|
224
|
+
}
|
|
225
|
+
total += body?.accepted ?? items.length;
|
|
226
|
+
}
|
|
227
|
+
const tsValues = rows
|
|
228
|
+
.map((r) => this.tsOf(r, tsCol))
|
|
229
|
+
.sort((a, b) => a.getTime() - b.getTime());
|
|
230
|
+
const maxTs = tsValues[tsValues.length - 1];
|
|
231
|
+
const maxIso = maxTs.toISOString();
|
|
232
|
+
const idsAtMax = rows
|
|
233
|
+
.filter((r) => this.tsOf(r, tsCol).toISOString() === maxIso)
|
|
234
|
+
.map((r) => r[pk]);
|
|
235
|
+
cursor.pushedWatermark = maxIso;
|
|
236
|
+
cursor.pushedIds = JSON.stringify(idsAtMax);
|
|
237
|
+
cursor.updatedAt = new Date();
|
|
238
|
+
await this.cursorRepo.save(cursor);
|
|
239
|
+
if (rows.length < BATCH)
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
return total;
|
|
243
|
+
}
|
|
244
|
+
async pullNow() {
|
|
245
|
+
if (!this.saasBaseUrl || this.pulling)
|
|
246
|
+
return { skipped: 1 };
|
|
247
|
+
if (this.authFailed)
|
|
248
|
+
return { skipped: 'auth_failed' };
|
|
249
|
+
this.pulling = true;
|
|
250
|
+
const result = {};
|
|
251
|
+
try {
|
|
252
|
+
const token = await this.authService.getStoredSaasToken();
|
|
253
|
+
if (!token) {
|
|
254
|
+
result['skipped'] = 'no_token';
|
|
255
|
+
return result;
|
|
256
|
+
}
|
|
257
|
+
for (const cfg of registry_1.SYNC_REGISTRY) {
|
|
258
|
+
if (cfg.direction !== 'both')
|
|
259
|
+
continue;
|
|
260
|
+
const table = this.tableOf(cfg);
|
|
261
|
+
try {
|
|
262
|
+
const r = await this.pullEntity(cfg, token.token);
|
|
263
|
+
result[table] = `${r.applied}u/${r.conflicts}c/${r.deleted}d`;
|
|
264
|
+
}
|
|
265
|
+
catch (err) {
|
|
266
|
+
const msg = err.message ?? String(err);
|
|
267
|
+
this.logger.warn(`pull entity ${table} failed: ${msg}`);
|
|
268
|
+
result[table] = `ERR: ${msg}`;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return result;
|
|
272
|
+
}
|
|
273
|
+
finally {
|
|
274
|
+
this.pulling = false;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
async pullEntityNow(cfg, jwt) {
|
|
278
|
+
return this.pullEntity(cfg, jwt);
|
|
279
|
+
}
|
|
280
|
+
async pullEntity(cfg, jwt) {
|
|
281
|
+
const meta = this.dataSource.getMetadata(cfg.entity);
|
|
282
|
+
const table = meta.tableName;
|
|
283
|
+
const pk = meta.primaryColumns[0]?.propertyName ?? 'id';
|
|
284
|
+
const tsCol = this.tsColumnOf(meta);
|
|
285
|
+
const repo = this.dataSource.getRepository(cfg.entity);
|
|
286
|
+
const cursor = await this.ensureCursor(table);
|
|
287
|
+
let applied = 0;
|
|
288
|
+
let conflicts = 0;
|
|
289
|
+
let deleted = 0;
|
|
290
|
+
let since = cursor.pulledWatermark ?? undefined;
|
|
291
|
+
const LIMIT = 500;
|
|
292
|
+
for (let page = 0; page < 20; page++) {
|
|
293
|
+
const url = new URL(`${this.saasBaseUrl}/hunter-mate/sync/pull`);
|
|
294
|
+
url.searchParams.set('entity', table);
|
|
295
|
+
url.searchParams.set('limit', String(LIMIT));
|
|
296
|
+
url.searchParams.set('excludeDeviceId', this.deviceId);
|
|
297
|
+
if (since)
|
|
298
|
+
url.searchParams.set('since', since);
|
|
299
|
+
const res = await fetch(url.toString(), {
|
|
300
|
+
headers: { Authorization: `HMJWT ${jwt}` },
|
|
301
|
+
});
|
|
302
|
+
if (res.status === 401) {
|
|
303
|
+
this.authFailed = true;
|
|
304
|
+
throw new Error('HMJWT rejected by dev-ops (expired?); re-run `hunter-mate login --email`');
|
|
305
|
+
}
|
|
306
|
+
if (!res.ok)
|
|
307
|
+
throw new Error(`HTTP ${res.status}`);
|
|
308
|
+
const body = await res.json();
|
|
309
|
+
for (const it of body.items ?? []) {
|
|
310
|
+
const outcome = await this.applyPullItem(table, pk, tsCol, repo, it);
|
|
311
|
+
if (outcome === 'applied')
|
|
312
|
+
applied++;
|
|
313
|
+
else if (outcome === 'conflict')
|
|
314
|
+
conflicts++;
|
|
315
|
+
else if (outcome === 'deleted')
|
|
316
|
+
deleted++;
|
|
317
|
+
}
|
|
318
|
+
const batchMax = (body.items ?? [])
|
|
319
|
+
.map((i) => i.updatedAt)
|
|
320
|
+
.sort()
|
|
321
|
+
.at(-1);
|
|
322
|
+
if (batchMax) {
|
|
323
|
+
since = batchMax;
|
|
324
|
+
if (!cursor.pulledWatermark || batchMax > cursor.pulledWatermark) {
|
|
325
|
+
cursor.pulledWatermark = batchMax;
|
|
326
|
+
cursor.updatedAt = new Date();
|
|
327
|
+
await this.cursorRepo.save(cursor);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (!body.hasMore)
|
|
331
|
+
break;
|
|
332
|
+
}
|
|
333
|
+
return { applied, conflicts, deleted };
|
|
334
|
+
}
|
|
335
|
+
async applyPullItem(table, pk, tsCol, repo, it) {
|
|
336
|
+
const local = await repo.findOne({ where: { [pk]: it.clientRef } });
|
|
337
|
+
const localIso = local ? this.tsOf(local, tsCol).toISOString() : null;
|
|
338
|
+
if (it.deleted) {
|
|
339
|
+
if (!local)
|
|
340
|
+
return 'skipped';
|
|
341
|
+
if (localIso && localIso > it.updatedAt) {
|
|
342
|
+
await this.logConflict(table, it, localIso);
|
|
343
|
+
return 'conflict';
|
|
344
|
+
}
|
|
345
|
+
await repo.delete({ [pk]: it.clientRef });
|
|
346
|
+
return 'deleted';
|
|
347
|
+
}
|
|
348
|
+
if (!it.payload)
|
|
349
|
+
return 'skipped';
|
|
350
|
+
const payload = typeof it.payload === 'string' ? JSON.parse(it.payload) : it.payload;
|
|
351
|
+
if (local && localIso && localIso > it.updatedAt) {
|
|
352
|
+
await this.logConflict(table, it, localIso);
|
|
353
|
+
return 'conflict';
|
|
354
|
+
}
|
|
355
|
+
await repo.save(repo.create(payload));
|
|
356
|
+
return 'applied';
|
|
357
|
+
}
|
|
358
|
+
async logConflict(table, it, localIso) {
|
|
359
|
+
const existing = await this.conflictRepo.findOne({
|
|
360
|
+
where: {
|
|
361
|
+
entity: table,
|
|
362
|
+
clientRef: String(it.clientRef),
|
|
363
|
+
remoteUpdatedAt: it.updatedAt,
|
|
364
|
+
},
|
|
365
|
+
});
|
|
366
|
+
if (existing)
|
|
367
|
+
return;
|
|
368
|
+
await this.conflictRepo.save({
|
|
369
|
+
entity: table,
|
|
370
|
+
clientRef: String(it.clientRef),
|
|
371
|
+
localUpdatedAt: localIso,
|
|
372
|
+
remoteUpdatedAt: it.updatedAt,
|
|
373
|
+
remoteDeviceId: it.deviceId ?? '',
|
|
374
|
+
resolution: 'local_wins',
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
exports.DatasyncService = DatasyncService;
|
|
379
|
+
exports.DatasyncService = DatasyncService = DatasyncService_1 = __decorate([
|
|
380
|
+
(0, common_1.Injectable)(),
|
|
381
|
+
__param(3, (0, typeorm_1.InjectRepository)(sync_cursor_entity_1.SyncCursor)),
|
|
382
|
+
__param(4, (0, typeorm_1.InjectRepository)(sync_conflict_entity_1.SyncConflict)),
|
|
383
|
+
__metadata("design:paramtypes", [config_1.ConfigService,
|
|
384
|
+
typeorm_2.DataSource,
|
|
385
|
+
auth_service_1.AuthService,
|
|
386
|
+
typeorm_2.Repository,
|
|
387
|
+
typeorm_2.Repository])
|
|
388
|
+
], DatasyncService);
|
|
389
|
+
//# sourceMappingURL=datasync.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datasync.service.js","sourceRoot":"","sources":["../../src/datasync/datasync.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA4E;AAC5E,2CAA+C;AAC/C,6CAAmD;AACnD,qCAAiD;AACjD,mCAAoC;AACpC,yBAAyB;AACzB,sEAA2D;AAC3D,0EAA+D;AAC/D,yCAA6D;AAC7D,uDAAmD;AAiB5C,IAAM,eAAe,uBAArB,MAAM,eAAe;IAUP;IACA;IACA;IAEA;IAEA;IAfF,MAAM,GAAG,IAAI,eAAM,CAAC,iBAAe,CAAC,IAAI,CAAC,CAAC;IACnD,KAAK,CAAkB;IACvB,OAAO,GAAG,KAAK,CAAC;IAChB,OAAO,GAAG,KAAK,CAAC;IAEhB,UAAU,GAAG,KAAK,CAAC;IACnB,SAAS,GAAkB,IAAI,CAAC;IAExC,YACmB,MAAqB,EACrB,UAAsB,EACtB,WAAwB,EAExB,UAAkC,EAElC,YAAsC;QANtC,WAAM,GAAN,MAAM,CAAe;QACrB,eAAU,GAAV,UAAU,CAAY;QACtB,gBAAW,GAAX,WAAW,CAAa;QAExB,eAAU,GAAV,UAAU,CAAwB;QAElC,iBAAY,GAAZ,YAAY,CAA0B;IACtD,CAAC;IAEJ,sBAAsB;QACpB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;YAC9C,OAAO;QACT,CAAC;QACD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC,CAAC;QACxE,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,qBAAqB,EAAE,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC;QAC7E,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CA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O,KAAK,CAAC,WAAW,CAAC,KAAa,EAAE,EAAO,EAAE,QAAgB;QAChE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC;YAC/C,KAAK,EAAE;gBACL,MAAM,EAAE,KAAK;gBACb,SAAS,EAAE,MAAM,CAAC,EAAE,CAAC,SAAS,CAAC;gBAC/B,eAAe,EAAE,EAAE,CAAC,SAAS;aAC9B;SACF,CAAC,CAAC;QACH,IAAI,QAAQ;YAAE,OAAO;QACrB,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC;YAC3B,MAAM,EAAE,KAAK;YACb,SAAS,EAAE,MAAM,CAAC,EAAE,CAAC,SAAS,CAAC;YAC/B,cAAc,EAAE,QAAQ;YACxB,eAAe,EAAE,EAAE,CAAC,SAAS;YAC7B,cAAc,EAAE,EAAE,CAAC,QAAQ,IAAI,EAAE;YACjC,UAAU,EAAE,YAAY;SACzB,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AA1YY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;IAcR,WAAA,IAAA,0BAAgB,EAAC,+BAAU,CAAC,CAAA;IAE5B,WAAA,IAAA,0BAAgB,EAAC,mCAAY,CAAC,CAAA;qCALN,sBAAa;QACT,oBAAU;QACT,0BAAW;QAEZ,oBAAU;QAER,oBAAU;GAhBhC,eAAe,CA0Y3B"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SyncConflict = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
let SyncConflict = class SyncConflict {
|
|
15
|
+
id;
|
|
16
|
+
entity;
|
|
17
|
+
clientRef;
|
|
18
|
+
localUpdatedAt;
|
|
19
|
+
remoteUpdatedAt;
|
|
20
|
+
remoteDeviceId;
|
|
21
|
+
resolution;
|
|
22
|
+
createdAt;
|
|
23
|
+
};
|
|
24
|
+
exports.SyncConflict = SyncConflict;
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, typeorm_1.PrimaryGeneratedColumn)(),
|
|
27
|
+
__metadata("design:type", Number)
|
|
28
|
+
], SyncConflict.prototype, "id", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 64 }),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], SyncConflict.prototype, "entity", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, typeorm_1.Column)({ name: 'client_ref', type: 'varchar', length: 64 }),
|
|
35
|
+
__metadata("design:type", String)
|
|
36
|
+
], SyncConflict.prototype, "clientRef", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, typeorm_1.Column)({ name: 'local_updated_at', type: 'varchar', length: 32 }),
|
|
39
|
+
__metadata("design:type", String)
|
|
40
|
+
], SyncConflict.prototype, "localUpdatedAt", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, typeorm_1.Column)({ name: 'remote_updated_at', type: 'varchar', length: 32 }),
|
|
43
|
+
__metadata("design:type", String)
|
|
44
|
+
], SyncConflict.prototype, "remoteUpdatedAt", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, typeorm_1.Column)({ name: 'remote_device_id', type: 'varchar', length: 64 }),
|
|
47
|
+
__metadata("design:type", String)
|
|
48
|
+
], SyncConflict.prototype, "remoteDeviceId", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 16 }),
|
|
51
|
+
__metadata("design:type", String)
|
|
52
|
+
], SyncConflict.prototype, "resolution", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, typeorm_1.CreateDateColumn)({ name: 'created_at' }),
|
|
55
|
+
__metadata("design:type", Date)
|
|
56
|
+
], SyncConflict.prototype, "createdAt", void 0);
|
|
57
|
+
exports.SyncConflict = SyncConflict = __decorate([
|
|
58
|
+
(0, typeorm_1.Entity)('sync_conflicts'),
|
|
59
|
+
(0, typeorm_1.Index)(['entity', 'clientRef'])
|
|
60
|
+
], SyncConflict);
|
|
61
|
+
//# sourceMappingURL=sync-conflict.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-conflict.entity.js","sourceRoot":"","sources":["../../../src/datasync/entities/sync-conflict.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA0F;AAUnF,IAAM,YAAY,GAAlB,MAAM,YAAY;IAEvB,EAAE,CAAS;IAIX,MAAM,CAAS;IAIf,SAAS,CAAS;IAIlB,cAAc,CAAS;IAIvB,eAAe,CAAS;IAIxB,cAAc,CAAS;IAIvB,UAAU,CAAS;IAGnB,SAAS,CAAO;CACjB,CAAA;AA9BY,oCAAY;AAEvB;IADC,IAAA,gCAAsB,GAAE;;wCACd;AAIX;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;;4CACzB;AAIf;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;;+CAC1C;AAIlB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;;oDAC3C;AAIvB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;;qDAC3C;AAIxB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;;oDAC3C;AAIvB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;;gDACrB;AAGnB;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;8BAC9B,IAAI;+CAAC;uBA7BL,YAAY;IAFxB,IAAA,gBAAM,EAAC,gBAAgB,CAAC;IACxB,IAAA,eAAK,EAAC,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;GAClB,YAAY,CA8BxB"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SyncCursor = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
let SyncCursor = class SyncCursor {
|
|
15
|
+
id;
|
|
16
|
+
entity;
|
|
17
|
+
pushedWatermark;
|
|
18
|
+
pushedIds;
|
|
19
|
+
pulledWatermark;
|
|
20
|
+
createdAt;
|
|
21
|
+
updatedAt;
|
|
22
|
+
};
|
|
23
|
+
exports.SyncCursor = SyncCursor;
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, typeorm_1.PrimaryGeneratedColumn)(),
|
|
26
|
+
__metadata("design:type", Number)
|
|
27
|
+
], SyncCursor.prototype, "id", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 64 }),
|
|
30
|
+
__metadata("design:type", String)
|
|
31
|
+
], SyncCursor.prototype, "entity", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, typeorm_1.Column)({ name: 'pushed_watermark', type: 'varchar', length: 32, nullable: true }),
|
|
34
|
+
__metadata("design:type", Object)
|
|
35
|
+
], SyncCursor.prototype, "pushedWatermark", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, typeorm_1.Column)({ name: 'pushed_ids', type: 'text', nullable: true }),
|
|
38
|
+
__metadata("design:type", Object)
|
|
39
|
+
], SyncCursor.prototype, "pushedIds", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, typeorm_1.Column)({ name: 'pulled_watermark', type: 'varchar', length: 32, nullable: true }),
|
|
42
|
+
__metadata("design:type", Object)
|
|
43
|
+
], SyncCursor.prototype, "pulledWatermark", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, typeorm_1.CreateDateColumn)({ name: 'created_at' }),
|
|
46
|
+
__metadata("design:type", Date)
|
|
47
|
+
], SyncCursor.prototype, "createdAt", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, typeorm_1.Column)({ name: 'updated_at', type: 'datetime' }),
|
|
50
|
+
__metadata("design:type", Date)
|
|
51
|
+
], SyncCursor.prototype, "updatedAt", void 0);
|
|
52
|
+
exports.SyncCursor = SyncCursor = __decorate([
|
|
53
|
+
(0, typeorm_1.Entity)('sync_cursors'),
|
|
54
|
+
(0, typeorm_1.Index)(['entity'], { unique: true })
|
|
55
|
+
], SyncCursor);
|
|
56
|
+
//# sourceMappingURL=sync-cursor.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-cursor.entity.js","sourceRoot":"","sources":["../../../src/datasync/entities/sync-cursor.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA0F;AAUnF,IAAM,UAAU,GAAhB,MAAM,UAAU;IAErB,EAAE,CAAS;IAIX,MAAM,CAAS;IAIf,eAAe,CAAgB;IAI/B,SAAS,CAAgB;IAIzB,eAAe,CAAgB;IAG/B,SAAS,CAAO;IAGhB,SAAS,CAAO;CACjB,CAAA;AAzBY,gCAAU;AAErB;IADC,IAAA,gCAAsB,GAAE;;sCACd;AAIX;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;;0CACzB;AAIf;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;mDACnD;AAI/B;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACpC;AAIzB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;mDACnD;AAG/B;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;8BAC9B,IAAI;6CAAC;AAGhB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;8BACtC,IAAI;6CAAC;qBAxBL,UAAU;IAFtB,IAAA,gBAAM,EAAC,cAAc,CAAC;IACtB,IAAA,eAAK,EAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;GACvB,UAAU,CAyBtB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SyncDirection } from '@hunter-mate/sync-entities';
|
|
2
|
+
type SyncEntityTarget = import('typeorm').EntityTarget<import('typeorm').ObjectLiteral>;
|
|
3
|
+
export interface SyncEntityConfig {
|
|
4
|
+
entity: SyncEntityTarget;
|
|
5
|
+
direction: SyncDirection;
|
|
6
|
+
}
|
|
7
|
+
export declare const SYNC_REGISTRY: SyncEntityConfig[];
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SYNC_REGISTRY = void 0;
|
|
4
|
+
const sync_entities_1 = require("@hunter-mate/sync-entities");
|
|
5
|
+
const jobcase_entity_1 = require("../jobcase/jobcase.entity");
|
|
6
|
+
const communication_record_entity_1 = require("../communication/communication-record.entity");
|
|
7
|
+
const remark_entity_1 = require("../remark/remark.entity");
|
|
8
|
+
const parsed_resume_entity_1 = require("../parsed-resume/parsed-resume.entity");
|
|
9
|
+
const talent_portrait_entity_1 = require("../talent-portrait/talent-portrait.entity");
|
|
10
|
+
const talent_fingerprint_entity_1 = require("../talent-fingerprint/talent-fingerprint.entity");
|
|
11
|
+
const talent_job_match_entity_1 = require("../talent-job-match/talent-job-match.entity");
|
|
12
|
+
const parse_error_report_entity_1 = require("../parsing/parse-error-report.entity");
|
|
13
|
+
const site_registry_entity_1 = require("../site/entities/site-registry.entity");
|
|
14
|
+
const talent_profile_entity_1 = require("../extraction/entities/talent-profile.entity");
|
|
15
|
+
const job_posting_entity_1 = require("../extraction/entities/job-posting.entity");
|
|
16
|
+
const company_profile_entity_1 = require("../extraction/entities/company-profile.entity");
|
|
17
|
+
const adapter_rule_entity_1 = require("../extraction/entities/adapter-rule.entity");
|
|
18
|
+
const extraction_rule_entity_1 = require("../extraction/extraction-rule.entity");
|
|
19
|
+
const customer_entity_1 = require("../customer/customer.entity");
|
|
20
|
+
const preference_entity_1 = require("../preference/preference.entity");
|
|
21
|
+
const recording_snapshot_entity_1 = require("../recording/entities/recording-snapshot.entity");
|
|
22
|
+
const recording_event_entity_1 = require("../recording/entities/recording-event.entity");
|
|
23
|
+
const raw_snapshot_entity_1 = require("../snapshot/raw-snapshot.entity");
|
|
24
|
+
const CLASS_MAP = {
|
|
25
|
+
job_cases: jobcase_entity_1.JobCase,
|
|
26
|
+
communication_records: communication_record_entity_1.CommunicationRecord,
|
|
27
|
+
remarks: remark_entity_1.Remark,
|
|
28
|
+
parsed_resumes: parsed_resume_entity_1.ParsedResume,
|
|
29
|
+
talent_portraits: talent_portrait_entity_1.TalentPortrait,
|
|
30
|
+
talent_fingerprints: talent_fingerprint_entity_1.TalentFingerprint,
|
|
31
|
+
talent_job_matches: talent_job_match_entity_1.TalentJobMatch,
|
|
32
|
+
parse_error_reports: parse_error_report_entity_1.ParseErrorReport,
|
|
33
|
+
site_registry: site_registry_entity_1.SiteRegistry,
|
|
34
|
+
talent_profiles: talent_profile_entity_1.TalentProfile,
|
|
35
|
+
job_postings: job_posting_entity_1.JobPosting,
|
|
36
|
+
company_profiles: company_profile_entity_1.CompanyProfile,
|
|
37
|
+
adapter_rules: adapter_rule_entity_1.AdapterRule,
|
|
38
|
+
extraction_rules: extraction_rule_entity_1.ExtractionRule,
|
|
39
|
+
customers: customer_entity_1.Customer,
|
|
40
|
+
preferences: preference_entity_1.Preference,
|
|
41
|
+
recording_snapshots: recording_snapshot_entity_1.RecordingSnapshot,
|
|
42
|
+
recording_events: recording_event_entity_1.RecordingEvent,
|
|
43
|
+
raw_snapshots: raw_snapshot_entity_1.RawSnapshot,
|
|
44
|
+
};
|
|
45
|
+
const pkgKeys = sync_entities_1.SYNC_ENTITIES.map((d) => d.key);
|
|
46
|
+
const missingClass = pkgKeys.filter((k) => !CLASS_MAP[k]);
|
|
47
|
+
const missingDef = Object.keys(CLASS_MAP).filter((k) => !pkgKeys.includes(k));
|
|
48
|
+
if (missingClass.length || missingDef.length) {
|
|
49
|
+
throw new Error(`SYNC_REGISTRY 与 @hunter-mate/sync-entities 漂移:缺类映射=${missingClass.join(',') || '无'};缺包定义=${missingDef.join(',') || '无'}`);
|
|
50
|
+
}
|
|
51
|
+
exports.SYNC_REGISTRY = sync_entities_1.SYNC_ENTITIES.map((def) => ({
|
|
52
|
+
entity: CLASS_MAP[def.key],
|
|
53
|
+
direction: def.direction,
|
|
54
|
+
}));
|
|
55
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/datasync/registry.ts"],"names":[],"mappings":";;;AAAA,8DAA0E;AAC1E,8DAAoD;AACpD,8FAAmF;AACnF,2DAAiD;AACjD,gFAAqE;AACrE,sFAA2E;AAC3E,+FAAoF;AACpF,yFAA6E;AAC7E,oFAAwE;AACxE,gFAAqE;AACrE,wFAA6E;AAC7E,kFAAuE;AACvE,0FAA+E;AAC/E,oFAAyE;AACzE,iFAAsE;AACtE,iEAAuD;AACvD,uEAA6D;AAC7D,+FAAoF;AACpF,yFAA8E;AAC9E,yEAA8D;AA4B9D,MAAM,SAAS,GAAqC;IAClD,SAAS,EAAE,wBAAO;IAClB,qBAAqB,EAAE,iDAAmB;IAC1C,OAAO,EAAE,sBAAM;IACf,cAAc,EAAE,mCAAY;IAC5B,gBAAgB,EAAE,uCAAc;IAChC,mBAAmB,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+33,9 @@ const recording_snapshot_entity_1 = require("../recording/entities/recording-sna
|
|
|
33
33
|
const adapter_rule_entity_1 = require("../extraction/entities/adapter-rule.entity");
|
|
34
34
|
const schema_version_entity_1 = require("./schema-version.entity");
|
|
35
35
|
const schema_validator_service_1 = require("./schema-validator.service");
|
|
36
|
+
const saas_token_entity_1 = require("../auth/saas-token.entity");
|
|
37
|
+
const sync_cursor_entity_1 = require("../datasync/entities/sync-cursor.entity");
|
|
38
|
+
const sync_conflict_entity_1 = require("../datasync/entities/sync-conflict.entity");
|
|
36
39
|
const customer_entity_1 = require("../customer/customer.entity");
|
|
37
40
|
const preference_entity_1 = require("../preference/preference.entity");
|
|
38
41
|
const action_audit_entity_1 = require("../governance/action-audit.entity");
|
|
@@ -80,6 +83,9 @@ exports.SqliteModule = SqliteModule = __decorate([
|
|
|
80
83
|
preference_entity_1.Preference,
|
|
81
84
|
action_audit_entity_1.ActionAudit,
|
|
82
85
|
nestjs_1.LogEntryEntity,
|
|
86
|
+
saas_token_entity_1.SaasToken,
|
|
87
|
+
sync_cursor_entity_1.SyncCursor,
|
|
88
|
+
sync_conflict_entity_1.SyncConflict,
|
|
83
89
|
],
|
|
84
90
|
};
|
|
85
91
|
},
|