@imqueue/rpc 3.1.1 → 3.2.1
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/index.d.ts +1 -1
- package/index.js +2 -18
- package/package.json +9 -5
- package/src/IMQCache.d.ts +1 -24
- package/src/IMQCache.js +37 -6
- package/src/IMQClient.d.ts +2 -2
- package/src/IMQClient.js +53 -86
- package/src/IMQDelay.js +1 -5
- package/src/IMQLock.d.ts +2 -2
- package/src/IMQLock.js +26 -6
- package/src/IMQMetadata.d.ts +1 -1
- package/src/IMQMetadata.js +25 -5
- package/src/IMQRPCDescription.js +1 -5
- package/src/IMQRPCError.d.ts +1 -1
- package/src/IMQRPCError.js +27 -7
- package/src/IMQRPCOptions.d.ts +5 -5
- package/src/IMQRPCOptions.js +10 -9
- package/src/IMQRPCRequest.d.ts +2 -2
- package/src/IMQRPCRequest.js +25 -2
- package/src/IMQRPCResponse.d.ts +2 -2
- package/src/IMQRPCResponse.js +25 -2
- package/src/IMQRequestContext.d.ts +2 -2
- package/src/IMQRequestContext.js +6 -8
- package/src/IMQService.d.ts +2 -2
- package/src/IMQService.js +36 -75
- package/src/cache/ICache.js +1 -2
- package/src/cache/RedisCache.d.ts +3 -23
- package/src/cache/RedisCache.js +14 -17
- package/src/cache/index.d.ts +2 -2
- package/src/cache/index.js +2 -18
- package/src/decorators/cache.d.ts +1 -1
- package/src/decorators/cache.js +14 -15
- package/src/decorators/classType.js +3 -6
- package/src/decorators/expose.js +6 -9
- package/src/decorators/index.d.ts +9 -9
- package/src/decorators/index.js +9 -25
- package/src/decorators/indexed.d.ts +1 -1
- package/src/decorators/indexed.js +6 -9
- package/src/decorators/lock.js +8 -11
- package/src/decorators/logged.d.ts +1 -1
- package/src/decorators/logged.js +25 -4
- package/src/decorators/metadata.js +1 -2
- package/src/decorators/property.js +7 -11
- package/src/decorators/remote.js +1 -4
- package/src/helpers/fs.js +7 -12
- package/src/helpers/index.d.ts +4 -4
- package/src/helpers/index.js +4 -20
- package/src/helpers/os-uuid.js +5 -8
- package/src/helpers/pid.d.ts +1 -1
- package/src/helpers/pid.js +12 -16
- package/src/helpers/signature.js +3 -6
- package/src/index.d.ts +14 -14
- package/src/index.js +14 -30
- package/tsconfig.json +5 -2
package/src/cache/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
1
|
/*!
|
|
18
2
|
* Copyright (C) 2025 imqueue.com <support@imqueue.com>
|
|
19
3
|
*
|
|
@@ -37,6 +21,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
37
21
|
* purchase a proprietary commercial license. Please contact us at
|
|
38
22
|
* <support@imqueue.com> to get commercial licensing options.
|
|
39
23
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
24
|
+
export * from './ICache.js';
|
|
25
|
+
export * from './RedisCache.js';
|
|
42
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* purchase a proprietary commercial license. Please contact us at
|
|
22
22
|
* <support@imqueue.com> to get commercial licensing options.
|
|
23
23
|
*/
|
|
24
|
-
import { ICache, ICacheConstructor } from '
|
|
24
|
+
import { type ICache, type ICacheConstructor } from '../cache/index.js';
|
|
25
25
|
export interface CacheDecoratorOptions {
|
|
26
26
|
adapter?: string | ICache | ICacheConstructor;
|
|
27
27
|
ttl?: number;
|
package/src/decorators/cache.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cache = void 0;
|
|
4
1
|
/*!
|
|
5
2
|
* IMQ-RPC Decorators: cache
|
|
6
3
|
*
|
|
@@ -24,8 +21,11 @@ exports.cache = void 0;
|
|
|
24
21
|
* purchase a proprietary commercial license. Please contact us at
|
|
25
22
|
* <support@imqueue.com> to get commercial licensing options.
|
|
26
23
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
// cache classes are imported from their defining modules (not the package
|
|
25
|
+
// barrel) to avoid a circular-import TDZ on the module-scope default options
|
|
26
|
+
import { RedisCache, } from '../cache/index.js';
|
|
27
|
+
import { IMQCache } from '../IMQCache.js';
|
|
28
|
+
import { signature } from '../helpers/index.js';
|
|
29
29
|
/**
|
|
30
30
|
* Creates a `@cache()` method decorator that memoizes the decorated method's
|
|
31
31
|
* result in a cache adapter (RedisCache by default). On each call the cache is
|
|
@@ -38,16 +38,16 @@ const helpers_1 = require("../helpers");
|
|
|
38
38
|
* ttl, nx); merged over `cache.globalOptions`
|
|
39
39
|
* @return {Function} - a dual-mode method decorator
|
|
40
40
|
*/
|
|
41
|
-
const cache = function (options) {
|
|
41
|
+
export const cache = function (options) {
|
|
42
42
|
const cacheOptions = {
|
|
43
|
-
...
|
|
43
|
+
...cache.globalOptions,
|
|
44
44
|
...options,
|
|
45
45
|
};
|
|
46
|
-
let Adapter = cacheOptions.adapter ||
|
|
46
|
+
let Adapter = cacheOptions.adapter || RedisCache;
|
|
47
47
|
const wrap = (original, methodName) => async function (...args) {
|
|
48
48
|
const className = this.constructor.name;
|
|
49
49
|
if (!this.cache) {
|
|
50
|
-
let cache =
|
|
50
|
+
let cache = IMQCache.get(Adapter);
|
|
51
51
|
if (cache && cache.ready) {
|
|
52
52
|
this.cache = cache;
|
|
53
53
|
}
|
|
@@ -60,12 +60,12 @@ const cache = function (options) {
|
|
|
60
60
|
if (logger) {
|
|
61
61
|
opts = { ...opts, logger };
|
|
62
62
|
}
|
|
63
|
-
await
|
|
64
|
-
this.cache =
|
|
63
|
+
await IMQCache.register(Adapter, opts).init();
|
|
64
|
+
this.cache = IMQCache.get(Adapter);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
try {
|
|
68
|
-
const key =
|
|
68
|
+
const key = signature(className, methodName, args);
|
|
69
69
|
let result = await this.cache.get(key);
|
|
70
70
|
if (result === undefined) {
|
|
71
71
|
result = original.apply(this, args);
|
|
@@ -88,8 +88,7 @@ const cache = function (options) {
|
|
|
88
88
|
return descriptor;
|
|
89
89
|
};
|
|
90
90
|
};
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
adapter: __1.RedisCache,
|
|
91
|
+
cache.globalOptions = {
|
|
92
|
+
adapter: RedisCache,
|
|
94
93
|
};
|
|
95
94
|
//# sourceMappingURL=cache.js.map
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.classType = classType;
|
|
4
1
|
/*!
|
|
5
2
|
* IMQ-RPC Decorators: classType
|
|
6
3
|
*
|
|
@@ -24,7 +21,7 @@ exports.classType = classType;
|
|
|
24
21
|
* purchase a proprietary commercial license. Please contact us at
|
|
25
22
|
* <support@imqueue.com> to get commercial licensing options.
|
|
26
23
|
*/
|
|
27
|
-
|
|
24
|
+
import { registerType } from './property.js';
|
|
28
25
|
/**
|
|
29
26
|
* Implements the '@classType' decorator factory.
|
|
30
27
|
*
|
|
@@ -67,14 +64,14 @@ const property_1 = require("./property");
|
|
|
67
64
|
*
|
|
68
65
|
* @return {(value: Function, context: ClassDecoratorContext) => void}
|
|
69
66
|
*/
|
|
70
|
-
function classType() {
|
|
67
|
+
export function classType() {
|
|
71
68
|
// Dual-mode: standard (TC39) class decorators pass a context object with a
|
|
72
69
|
// `kind` property; legacy ones pass only the constructor. In legacy mode
|
|
73
70
|
// @property already registers each field directly, so there is nothing to
|
|
74
71
|
// flush and the class is returned unchanged.
|
|
75
72
|
return function (value, context) {
|
|
76
73
|
if (context && typeof context === 'object' && 'kind' in context) {
|
|
77
|
-
|
|
74
|
+
registerType(value, context.metadata);
|
|
78
75
|
return;
|
|
79
76
|
}
|
|
80
77
|
return value;
|
package/src/decorators/expose.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.expose = expose;
|
|
4
1
|
/*!
|
|
5
2
|
* IMQ-RPC Decorators: expose
|
|
6
3
|
*
|
|
@@ -24,8 +21,8 @@ exports.expose = expose;
|
|
|
24
21
|
* purchase a proprietary commercial license. Please contact us at
|
|
25
22
|
* <support@imqueue.com> to get commercial licensing options.
|
|
26
23
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
import { parse } from 'acorn';
|
|
25
|
+
import { IMQRPCDescription, } from '../index.js';
|
|
29
26
|
const descriptions = {};
|
|
30
27
|
const RX_ARG_NAMES = /^(\S+)([=\s]+.*?)?$/;
|
|
31
28
|
const RX_COMMA_SPLIT = /\s*,\s*/;
|
|
@@ -143,7 +140,7 @@ function parseDescriptions(name, src) {
|
|
|
143
140
|
};
|
|
144
141
|
let body;
|
|
145
142
|
try {
|
|
146
|
-
body =
|
|
143
|
+
body = parse(src, options).body;
|
|
147
144
|
}
|
|
148
145
|
catch {
|
|
149
146
|
// tolerate unparseable sources (e.g. bound or native functions) the
|
|
@@ -259,12 +256,12 @@ function buildMethodDescription(ctor, methodName, fn) {
|
|
|
259
256
|
// to a helper (e.g. `extends _classSuper`), so the source name is unusable
|
|
260
257
|
const parent = Object.getPrototypeOf(ctor);
|
|
261
258
|
const inherits = parent && parent.name ? parent.name : 'Function';
|
|
262
|
-
|
|
259
|
+
IMQRPCDescription.serviceDescription[className] = IMQRPCDescription
|
|
263
260
|
.serviceDescription[className] || {
|
|
264
261
|
inherits,
|
|
265
262
|
methods: {},
|
|
266
263
|
};
|
|
267
|
-
|
|
264
|
+
IMQRPCDescription.serviceDescription[className].methods[methodName] = {
|
|
268
265
|
description: get('description', className, methodName, ''),
|
|
269
266
|
arguments: args,
|
|
270
267
|
returns: ret,
|
|
@@ -277,7 +274,7 @@ function buildMethodDescription(ctor, methodName, fn) {
|
|
|
277
274
|
*
|
|
278
275
|
* @return {(value: any, context: ClassMethodDecoratorContext) => void}
|
|
279
276
|
*/
|
|
280
|
-
function expose() {
|
|
277
|
+
export function expose() {
|
|
281
278
|
// Dual-mode: standard (TC39) invocations pass a context object with a
|
|
282
279
|
// `kind` property; legacy ones pass (target, propertyKey, descriptor).
|
|
283
280
|
return function exposeDecorator(target, context, descriptor) {
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
* purchase a proprietary commercial license. Please contact us at
|
|
22
22
|
* <support@imqueue.com> to get commercial licensing options.
|
|
23
23
|
*/
|
|
24
|
-
import './metadata';
|
|
25
|
-
export * from './expose';
|
|
26
|
-
export * from './classType';
|
|
27
|
-
export * from './remote';
|
|
28
|
-
export * from './lock';
|
|
29
|
-
export * from './cache';
|
|
30
|
-
export * from './property';
|
|
31
|
-
export * from './indexed';
|
|
32
|
-
export * from './logged';
|
|
24
|
+
import './metadata.js';
|
|
25
|
+
export * from './expose.js';
|
|
26
|
+
export * from './classType.js';
|
|
27
|
+
export * from './remote.js';
|
|
28
|
+
export * from './lock.js';
|
|
29
|
+
export * from './cache.js';
|
|
30
|
+
export * from './property.js';
|
|
31
|
+
export * from './indexed.js';
|
|
32
|
+
export * from './logged.js';
|
package/src/decorators/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
1
|
/*!
|
|
18
2
|
* Copyright (C) 2025 imqueue.com <support@imqueue.com>
|
|
19
3
|
*
|
|
@@ -39,13 +23,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
23
|
*/
|
|
40
24
|
// must load first: installs the Symbol.metadata polyfill required by the
|
|
41
25
|
// standard-decorator metadata used across the decorators below
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
26
|
+
import './metadata.js';
|
|
27
|
+
export * from './expose.js';
|
|
28
|
+
export * from './classType.js';
|
|
29
|
+
export * from './remote.js';
|
|
30
|
+
export * from './lock.js';
|
|
31
|
+
export * from './cache.js';
|
|
32
|
+
export * from './property.js';
|
|
33
|
+
export * from './indexed.js';
|
|
34
|
+
export * from './logged.js';
|
|
51
35
|
//# sourceMappingURL=index.js.map
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* purchase a proprietary commercial license. Please contact us at
|
|
22
22
|
* <support@imqueue.com> to get commercial licensing options.
|
|
23
23
|
*/
|
|
24
|
-
import { Thunk } from '
|
|
24
|
+
import { type Thunk } from '../index.js';
|
|
25
25
|
/**
|
|
26
26
|
* Implements '@indexed' decorator factory
|
|
27
27
|
* This is used to specify complex service types which are need to expose
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.indexed = indexed;
|
|
4
1
|
/*!
|
|
5
2
|
* IMQ-RPC Decorators: property
|
|
6
3
|
*
|
|
@@ -24,8 +21,8 @@ exports.indexed = indexed;
|
|
|
24
21
|
* purchase a proprietary commercial license. Please contact us at
|
|
25
22
|
* <support@imqueue.com> to get commercial licensing options.
|
|
26
23
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
import { IMQRPCDescription } from '../index.js';
|
|
25
|
+
import { registerType } from './property.js';
|
|
29
26
|
/**
|
|
30
27
|
* Implements '@indexed' decorator factory
|
|
31
28
|
* This is used to specify complex service types which are need to expose
|
|
@@ -43,7 +40,7 @@ const property_1 = require("./property");
|
|
|
43
40
|
*
|
|
44
41
|
* @return {(constructor: Function) => void}
|
|
45
42
|
*/
|
|
46
|
-
function indexed(indexTypedef) {
|
|
43
|
+
export function indexed(indexTypedef) {
|
|
47
44
|
// Dual-mode: standard (TC39) class decorators pass a context object with a
|
|
48
45
|
// `kind` property; legacy ones pass only the constructor.
|
|
49
46
|
return function (value, context) {
|
|
@@ -59,18 +56,18 @@ function indexed(indexTypedef) {
|
|
|
59
56
|
}
|
|
60
57
|
if (isStandard) {
|
|
61
58
|
// registers any @property fields on this class plus the index type
|
|
62
|
-
|
|
59
|
+
registerType(value, context.metadata, indexTypedef);
|
|
63
60
|
return;
|
|
64
61
|
}
|
|
65
62
|
// legacy: @property already registered the fields directly, so only
|
|
66
63
|
// the index type needs to be attached to the existing description
|
|
67
64
|
const typeName = value.name;
|
|
68
|
-
|
|
65
|
+
IMQRPCDescription.typesDescription[typeName] = IMQRPCDescription
|
|
69
66
|
.typesDescription[typeName] || {
|
|
70
67
|
properties: {},
|
|
71
68
|
inherits: Object.getPrototypeOf(value).name,
|
|
72
69
|
};
|
|
73
|
-
|
|
70
|
+
IMQRPCDescription.typesDescription[typeName].indexType =
|
|
74
71
|
indexTypedef;
|
|
75
72
|
return value;
|
|
76
73
|
};
|
package/src/decorators/lock.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.lock = lock;
|
|
4
1
|
/*!
|
|
5
2
|
* IMQ-RPC Decorators: lock
|
|
6
3
|
*
|
|
@@ -24,8 +21,8 @@ exports.lock = lock;
|
|
|
24
21
|
* purchase a proprietary commercial license. Please contact us at
|
|
25
22
|
* <support@imqueue.com> to get commercial licensing options.
|
|
26
23
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
import { IMQLock } from '../index.js';
|
|
25
|
+
import { signature } from '../helpers/index.js';
|
|
29
26
|
/**
|
|
30
27
|
* Creates a `@lock()` method decorator. Concurrent calls to the decorated
|
|
31
28
|
* method that share the same arguments are coalesced: only the first call is
|
|
@@ -38,7 +35,7 @@ const helpers_1 = require("../helpers");
|
|
|
38
35
|
* or the lock options
|
|
39
36
|
* @return {Function} - a dual-mode method decorator
|
|
40
37
|
*/
|
|
41
|
-
function lock(enabledOrOptions = true) {
|
|
38
|
+
export function lock(enabledOrOptions = true) {
|
|
42
39
|
const enabled = typeof enabledOrOptions === 'boolean'
|
|
43
40
|
? enabledOrOptions
|
|
44
41
|
: !enabledOrOptions.disabled;
|
|
@@ -53,15 +50,15 @@ function lock(enabledOrOptions = true) {
|
|
|
53
50
|
let lock;
|
|
54
51
|
let sig = '';
|
|
55
52
|
if (withLocks) {
|
|
56
|
-
sig =
|
|
53
|
+
sig = signature(className, methodName, skipArgs
|
|
57
54
|
? args.filter((_, index) => !~skipArgs.indexOf(index))
|
|
58
55
|
: args);
|
|
59
|
-
lock = await
|
|
56
|
+
lock = await IMQLock.acquire(sig, undefined, {
|
|
60
57
|
className,
|
|
61
58
|
methodName,
|
|
62
59
|
args,
|
|
63
60
|
});
|
|
64
|
-
if (!
|
|
61
|
+
if (!IMQLock.locked(sig)) {
|
|
65
62
|
return lock;
|
|
66
63
|
}
|
|
67
64
|
}
|
|
@@ -75,13 +72,13 @@ function lock(enabledOrOptions = true) {
|
|
|
75
72
|
result = await result;
|
|
76
73
|
}
|
|
77
74
|
if (withLocks) {
|
|
78
|
-
|
|
75
|
+
IMQLock.release(sig, result);
|
|
79
76
|
}
|
|
80
77
|
return result;
|
|
81
78
|
}
|
|
82
79
|
catch (err) {
|
|
83
80
|
if (withLocks) {
|
|
84
|
-
|
|
81
|
+
IMQLock.release(sig, null, err);
|
|
85
82
|
}
|
|
86
83
|
throw err;
|
|
87
84
|
}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* purchase a proprietary commercial license. Please contact us at
|
|
22
22
|
* <support@imqueue.com> to get commercial licensing options.
|
|
23
23
|
*/
|
|
24
|
-
import { ILogger } from '@imqueue/core';
|
|
24
|
+
import { type ILogger } from '@imqueue/core';
|
|
25
25
|
export type LoggedLogLevel = 'info' | 'log' | 'warn' | 'error';
|
|
26
26
|
export interface LoggedDecoratorOptions {
|
|
27
27
|
level?: LoggedLogLevel;
|
package/src/decorators/logged.js
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/*!
|
|
2
|
+
* IMQ-RPC Decorators: logged
|
|
3
|
+
*
|
|
4
|
+
* I'm Queue Software Project
|
|
5
|
+
* Copyright (C) 2025 imqueue.com <support@imqueue.com>
|
|
6
|
+
*
|
|
7
|
+
* This program is free software: you can redistribute it and/or modify
|
|
8
|
+
* it under the terms of the GNU General Public License as published by
|
|
9
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
* (at your option) any later version.
|
|
11
|
+
*
|
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
* GNU General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* You should have received a copy of the GNU General Public License
|
|
18
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
*
|
|
20
|
+
* If you want to use this code in a closed source (commercial) project, you can
|
|
21
|
+
* purchase a proprietary commercial license. Please contact us at
|
|
22
|
+
* <support@imqueue.com> to get commercial licensing options.
|
|
23
|
+
*/
|
|
24
|
+
import {} from '@imqueue/core';
|
|
4
25
|
/**
|
|
5
26
|
* Creates a `@logged()` method decorator that wraps the decorated method in a
|
|
6
27
|
* try/catch and logs any error it throws. The logger is resolved in this
|
|
@@ -14,7 +35,7 @@ exports.logged = logged;
|
|
|
14
35
|
* logged-decorator options
|
|
15
36
|
* @return {Function} - a dual-mode method decorator
|
|
16
37
|
*/
|
|
17
|
-
function logged(options) {
|
|
38
|
+
export function logged(options) {
|
|
18
39
|
const level = options && options.level
|
|
19
40
|
? options.level
|
|
20
41
|
: 'error';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*!
|
|
3
2
|
* IMQ-RPC Decorators: Symbol.metadata polyfill
|
|
4
3
|
*
|
|
@@ -22,7 +21,6 @@
|
|
|
22
21
|
* purchase a proprietary commercial license. Please contact us at
|
|
23
22
|
* <support@imqueue.com> to get commercial licensing options.
|
|
24
23
|
*/
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
24
|
/**
|
|
27
25
|
* Standard (TC39) decorator metadata relies on the well-known
|
|
28
26
|
* `Symbol.metadata`. Node.js does not implement it natively yet, so without
|
|
@@ -42,4 +40,5 @@ if (!Symbol.metadata) {
|
|
|
42
40
|
configurable: true,
|
|
43
41
|
});
|
|
44
42
|
}
|
|
43
|
+
export {};
|
|
45
44
|
//# sourceMappingURL=metadata.js.map
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.registerType = registerType;
|
|
4
|
-
exports.property = property;
|
|
5
1
|
/*!
|
|
6
2
|
* IMQ-RPC Decorators: property
|
|
7
3
|
*
|
|
@@ -25,7 +21,7 @@ exports.property = property;
|
|
|
25
21
|
* purchase a proprietary commercial license. Please contact us at
|
|
26
22
|
* <support@imqueue.com> to get commercial licensing options.
|
|
27
23
|
*/
|
|
28
|
-
|
|
24
|
+
import { IMQRPCDescription } from '../index.js';
|
|
29
25
|
/**
|
|
30
26
|
* Per-class store of collected @property definitions, keyed off the shared
|
|
31
27
|
* decorator metadata object. Standard field decorators cannot see their
|
|
@@ -70,17 +66,17 @@ function resolveTypeDef(input) {
|
|
|
70
66
|
* @param {DecoratorMetadata | undefined} metadata - shared decorator metadata
|
|
71
67
|
* @param {string} [indexType] - optional index signature definition
|
|
72
68
|
*/
|
|
73
|
-
function registerType(ctor, metadata, indexType) {
|
|
69
|
+
export function registerType(ctor, metadata, indexType) {
|
|
74
70
|
const typeName = ctor.name;
|
|
75
71
|
const collected = metadata && Object.prototype.hasOwnProperty.call(metadata, PROPERTIES)
|
|
76
72
|
? metadata[PROPERTIES]
|
|
77
73
|
: {};
|
|
78
|
-
|
|
74
|
+
IMQRPCDescription.typesDescription[typeName] = IMQRPCDescription
|
|
79
75
|
.typesDescription[typeName] || {
|
|
80
76
|
properties: {},
|
|
81
77
|
inherits: Object.getPrototypeOf(ctor).name,
|
|
82
78
|
};
|
|
83
|
-
const description =
|
|
79
|
+
const description = IMQRPCDescription.typesDescription[typeName];
|
|
84
80
|
description.inherits = Object.getPrototypeOf(ctor).name;
|
|
85
81
|
for (const key of Object.keys(collected)) {
|
|
86
82
|
const { rawType, isOptional } = collected[key];
|
|
@@ -107,7 +103,7 @@ function registerType(ctor, metadata, indexType) {
|
|
|
107
103
|
description.indexType = indexType;
|
|
108
104
|
}
|
|
109
105
|
}
|
|
110
|
-
function property(type, isOptional = false) {
|
|
106
|
+
export function property(type, isOptional = false) {
|
|
111
107
|
if (!type) {
|
|
112
108
|
return;
|
|
113
109
|
}
|
|
@@ -139,12 +135,12 @@ function property(type, isOptional = false) {
|
|
|
139
135
|
// property straight into the RPC type description (no @classType flush
|
|
140
136
|
// is required in this mode)
|
|
141
137
|
const typeName = target.constructor.name;
|
|
142
|
-
|
|
138
|
+
IMQRPCDescription.typesDescription[typeName] = IMQRPCDescription
|
|
143
139
|
.typesDescription[typeName] || {
|
|
144
140
|
properties: {},
|
|
145
141
|
inherits: Object.getPrototypeOf(target.constructor).name,
|
|
146
142
|
};
|
|
147
|
-
|
|
143
|
+
IMQRPCDescription.typesDescription[typeName].properties[String(context)] = {
|
|
148
144
|
type: resolveTypeDef(type),
|
|
149
145
|
isOptional,
|
|
150
146
|
};
|
package/src/decorators/remote.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.remote = remote;
|
|
4
1
|
/*!
|
|
5
2
|
* IMQ-RPC Decorators: remote
|
|
6
3
|
*
|
|
@@ -33,7 +30,7 @@ exports.remote = remote;
|
|
|
33
30
|
*
|
|
34
31
|
* @return {Function} - a dual-mode method decorator
|
|
35
32
|
*/
|
|
36
|
-
function remote() {
|
|
33
|
+
export function remote() {
|
|
37
34
|
const wrap = (original, methodName) => function (...args) {
|
|
38
35
|
args.push(methodName);
|
|
39
36
|
// istanbul ignore next
|
package/src/helpers/fs.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fileExists = fileExists;
|
|
4
|
-
exports.mkdir = mkdir;
|
|
5
|
-
exports.writeFile = writeFile;
|
|
6
1
|
/*!
|
|
7
2
|
* IMQ-RPC helpers: fs
|
|
8
3
|
*
|
|
@@ -26,15 +21,15 @@ exports.writeFile = writeFile;
|
|
|
26
21
|
* purchase a proprietary commercial license. Please contact us at
|
|
27
22
|
* <support@imqueue.com> to get commercial licensing options.
|
|
28
23
|
*/
|
|
29
|
-
|
|
24
|
+
import { access, mkdir as fsMkdir, writeFile as fsWriteFile } from 'node:fs';
|
|
30
25
|
/**
|
|
31
26
|
* Checks whether a file exists at the given path.
|
|
32
27
|
*
|
|
33
28
|
* @param {string} path - path to the file to check
|
|
34
29
|
* @return {Promise<boolean>} - true if the file exists, false otherwise
|
|
35
30
|
*/
|
|
36
|
-
function fileExists(path) {
|
|
37
|
-
return new Promise(resolve =>
|
|
31
|
+
export function fileExists(path) {
|
|
32
|
+
return new Promise(resolve => access(path, err => resolve(!err)));
|
|
38
33
|
}
|
|
39
34
|
/**
|
|
40
35
|
* Asynchronously creates a directory at the given path.
|
|
@@ -42,8 +37,8 @@ function fileExists(path) {
|
|
|
42
37
|
* @param {string} path - path of the directory to create
|
|
43
38
|
* @return {Promise<void>}
|
|
44
39
|
*/
|
|
45
|
-
function mkdir(path) {
|
|
46
|
-
return new Promise((resolve, reject) => (
|
|
40
|
+
export function mkdir(path) {
|
|
41
|
+
return new Promise((resolve, reject) => fsMkdir(path, generalCallback.bind(null, resolve, reject)));
|
|
47
42
|
}
|
|
48
43
|
/**
|
|
49
44
|
* Asynchronously writes the given content to a file at the given path.
|
|
@@ -52,8 +47,8 @@ function mkdir(path) {
|
|
|
52
47
|
* @param {string} content - content to write to the file
|
|
53
48
|
* @return {Promise<void>}
|
|
54
49
|
*/
|
|
55
|
-
function writeFile(path, content) {
|
|
56
|
-
return new Promise((resolve, reject) => (
|
|
50
|
+
export function writeFile(path, content) {
|
|
51
|
+
return new Promise((resolve, reject) => fsWriteFile(path, content, { encoding: 'utf8' }, generalCallback.bind(null, resolve, reject)));
|
|
57
52
|
}
|
|
58
53
|
/**
|
|
59
54
|
* Constructs a callback that settles a promise using the given resolve and
|
package/src/helpers/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* purchase a proprietary commercial license. Please contact us at
|
|
21
21
|
* <support@imqueue.com> to get commercial licensing options.
|
|
22
22
|
*/
|
|
23
|
-
export * from './signature';
|
|
24
|
-
export * from './os-uuid';
|
|
25
|
-
export * from './pid';
|
|
26
|
-
export * from './fs';
|
|
23
|
+
export * from './signature.js';
|
|
24
|
+
export * from './os-uuid.js';
|
|
25
|
+
export * from './pid.js';
|
|
26
|
+
export * from './fs.js';
|
package/src/helpers/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
1
|
/*!
|
|
18
2
|
*
|
|
19
3
|
* I'm Queue Software Project
|
|
@@ -36,8 +20,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
20
|
* purchase a proprietary commercial license. Please contact us at
|
|
37
21
|
* <support@imqueue.com> to get commercial licensing options.
|
|
38
22
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
23
|
+
export * from './signature.js';
|
|
24
|
+
export * from './os-uuid.js';
|
|
25
|
+
export * from './pid.js';
|
|
26
|
+
export * from './fs.js';
|
|
43
27
|
//# sourceMappingURL=index.js.map
|
package/src/helpers/os-uuid.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.osUuid = osUuid;
|
|
4
1
|
/*!
|
|
5
2
|
* IMQ-RPC helpers: osUuid
|
|
6
3
|
*
|
|
@@ -24,8 +21,8 @@ exports.osUuid = osUuid;
|
|
|
24
21
|
* purchase a proprietary commercial license. Please contact us at
|
|
25
22
|
* <support@imqueue.com> to get commercial licensing options.
|
|
26
23
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
import { execSync } from 'node:child_process';
|
|
25
|
+
import { createHash } from 'node:crypto';
|
|
29
26
|
/**
|
|
30
27
|
* Returns the base path to the Windows registry query tool, accounting for
|
|
31
28
|
* 32-bit processes running on 64-bit Windows (which must go through the
|
|
@@ -97,8 +94,8 @@ function parseId(raw) {
|
|
|
97
94
|
* @returns {string}
|
|
98
95
|
*/
|
|
99
96
|
function machineIdSync(original) {
|
|
100
|
-
const id = parseId(
|
|
101
|
-
return original ? id :
|
|
97
|
+
const id = parseId(execSync(idCommand()).toString());
|
|
98
|
+
return original ? id : createHash('sha256').update(id).digest('hex');
|
|
102
99
|
}
|
|
103
100
|
// The machine id cannot change while the process is running, so it is
|
|
104
101
|
// resolved once and memoized: osUuid() is called from every client
|
|
@@ -110,7 +107,7 @@ let cachedUuid;
|
|
|
110
107
|
*
|
|
111
108
|
* @returns {string}
|
|
112
109
|
*/
|
|
113
|
-
function osUuid() {
|
|
110
|
+
export function osUuid() {
|
|
114
111
|
if (cachedUuid === undefined) {
|
|
115
112
|
cachedUuid = machineIdSync(true);
|
|
116
113
|
}
|