@onereach/billing-shared 30.7.9-beta.12302.0 → 30.7.9-beta.12330.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.
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=customer-account-actions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customer-account-actions.js","sourceRoot":"","sources":["../../../src/types/customer-account-actions.ts"],"names":[],"mappings":""}
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./common"), exports);
18
18
  __exportStar(require("./billing-domain"), exports);
19
+ __exportStar(require("./customer-account-actions"), exports);
19
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,mDAAiC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,mDAAiC;AACjC,6DAA2C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=customer-account-actions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customer-account-actions.js","sourceRoot":"","sources":["../../../src/types/customer-account-actions.ts"],"names":[],"mappings":""}
@@ -1,3 +1,4 @@
1
1
  export * from './common';
2
2
  export * from './billing-domain';
3
+ export * from './customer-account-actions';
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { CustomerAccountAction } from '../enums/customer-account-action';
2
+ export interface CustomerAccountActionQueuePayload {
3
+ accountId: string;
4
+ action: CustomerAccountAction;
5
+ environmentId: string;
6
+ jobId: string;
7
+ }
8
+ //# sourceMappingURL=customer-account-actions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customer-account-actions.d.ts","sourceRoot":"","sources":["../../../src/types/customer-account-actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAE9E,MAAM,WAAW,iCAAiC;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,qBAAqB,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf"}
@@ -1,3 +1,4 @@
1
1
  export * from './common';
2
2
  export * from './billing-domain';
3
+ export * from './customer-account-actions';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/billing-shared",
3
- "version": "30.7.9-beta.12302.0",
3
+ "version": "30.7.9-beta.12330.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -9,7 +9,14 @@ const __dirname = dirname(__filename);
9
9
  const lockDir = '/tmp/shared-esm-build.lock';
10
10
  const pidFile = resolve(lockDir, 'pid');
11
11
  let ownsLock = false;
12
- const startupDeadline = Date.now() + 1000;
12
+ let emptyLockObservedAt;
13
+ let stopRequested = false;
14
+
15
+ const requestStop = () => {
16
+ stopRequested = true;
17
+ };
18
+ process.on('SIGINT', requestStop);
19
+ process.on('SIGTERM', requestStop);
13
20
 
14
21
  const isAlive = (pid) => { try { process.kill(pid, 0);return true; } catch { return false; } };
15
22
  const reclaimLock = () => {
@@ -26,6 +33,8 @@ const reclaimLock = () => {
26
33
  });
27
34
  };
28
35
  while (!ownsLock) {
36
+ if (stopRequested) process.exit(0);
37
+
29
38
  try {
30
39
  mkdirSync(lockDir);
31
40
  ownsLock = true;
@@ -36,22 +45,29 @@ while (!ownsLock) {
36
45
  // eslint-disable-next-line no-empty
37
46
  try { oldPid = Number(readFileSync(pidFile, 'utf8').trim()); } catch {}
38
47
  if (!Number.isNaN(oldPid) && isAlive(oldPid)) {
48
+ emptyLockObservedAt = undefined;
39
49
  // eslint-disable-next-line no-console
40
- console.log(`shared already running (pid=${oldPid})`);
41
- process.exit(0);
50
+ console.log(`shared already running (pid=${oldPid}); waiting to take over`);
51
+ while (isAlive(oldPid) && !stopRequested) {
52
+ await new Promise(resolve => { setTimeout(resolve, 250); });
53
+ }
54
+ continue;
42
55
  }
43
56
 
44
57
  if (Number.isNaN(oldPid)) {
45
- if (Date.now() < startupDeadline) {
58
+ emptyLockObservedAt ??= Date.now();
59
+ if (Date.now() - emptyLockObservedAt < 1000) {
46
60
  await new Promise(resolve => { setTimeout(resolve, 25); });
47
61
  continue;
48
62
  }
49
63
 
50
64
  reclaimLock();
65
+ emptyLockObservedAt = undefined;
51
66
  continue;
52
67
  }
53
68
 
54
69
  reclaimLock();
70
+ emptyLockObservedAt = undefined;
55
71
  }
56
72
  }
57
73
 
@@ -77,6 +93,8 @@ const shutdown = (signal) => {
77
93
  shuttingDown = true;
78
94
  child.kill(signal);
79
95
  };
96
+ process.removeListener('SIGINT', requestStop);
97
+ process.removeListener('SIGTERM', requestStop);
80
98
  process.on('SIGINT', () => shutdown('SIGINT'));
81
99
  process.on('SIGTERM', () => shutdown('SIGTERM'));
82
100
 
@@ -0,0 +1,8 @@
1
+ import type { CustomerAccountAction } from '../enums/customer-account-action';
2
+
3
+ export interface CustomerAccountActionQueuePayload {
4
+ accountId: string;
5
+ action: CustomerAccountAction;
6
+ environmentId: string;
7
+ jobId: string;
8
+ }
@@ -1,2 +1,3 @@
1
1
  export * from './common';
2
2
  export * from './billing-domain';
3
+ export * from './customer-account-actions';