@acmekit/locking 2.13.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.
@@ -0,0 +1,8 @@
1
+ import "./types";
2
+ import LockingModuleService from "./services/locking-module";
3
+ declare const _default: import("@acmekit/types").ModuleExports<typeof LockingModuleService> & {
4
+ linkable: Record<string, any>;
5
+ };
6
+ export default _default;
7
+ export { LockingModuleOptions } from "./types";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,CAAA;AAGhB,OAAO,oBAAoB,MAAM,2BAA2B,CAAA;;;;AAE5D,wBAGE;AAGF,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ require("./types");
7
+ const utils_1 = require("@acmekit/framework/utils");
8
+ const providers_1 = __importDefault(require("./loaders/providers"));
9
+ const locking_module_1 = __importDefault(require("./services/locking-module"));
10
+ exports.default = (0, utils_1.Module)(utils_1.Modules.LOCKING, {
11
+ service: locking_module_1.default,
12
+ loaders: [providers_1.default],
13
+ });
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,mBAAgB;AAChB,oDAA0D;AAC1D,oEAA8D;AAC9D,+EAA4D;AAE5D,kBAAe,IAAA,cAAM,EAAC,eAAO,CAAC,OAAO,EAAE;IACrC,OAAO,EAAE,wBAAoB;IAC7B,OAAO,EAAE,CAAC,mBAAa,CAAC;CACzB,CAAC,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { LoaderOptions, ModuleProvider, ModulesSdkTypes } from "@acmekit/framework/types";
2
+ declare const _default: ({ container, options, }: LoaderOptions<(ModulesSdkTypes.ModuleServiceInitializeOptions | ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions) & {
3
+ providers: ModuleProvider[];
4
+ }>) => Promise<void>;
5
+ export default _default;
6
+ //# sourceMappingURL=providers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/loaders/providers.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,cAAc,EACd,eAAe,EAChB,MAAM,0BAA0B,CAAA;yBAsCX,yBAGnB,aAAa,CACd,CACI,eAAe,CAAC,8BAA8B,GAC9C,eAAe,CAAC,6CAA6C,CAChE,GAAG;IAAE,SAAS,EAAE,cAAc,EAAE,CAAA;CAAE,CACpC,KAAG,OAAO,CAAC,IAAI,CAAC;AARjB,wBA4DC"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const modules_sdk_1 = require("@acmekit/framework/modules-sdk");
4
+ const utils_1 = require("@acmekit/framework/utils");
5
+ const _services_1 = require("../services");
6
+ const _types_1 = require("../types");
7
+ const awilix_1 = require("@acmekit/framework/awilix");
8
+ const in_memory_1 = require("../providers/in-memory");
9
+ const registrationFn = async (klass, container, { id }) => {
10
+ const key = _services_1.LockingProviderService.getRegistrationIdentifier(klass);
11
+ if (!id) {
12
+ throw new Error(`No "id" provided for provider ${key}`);
13
+ }
14
+ const regKey = (0, utils_1.getProviderRegistrationKey)({
15
+ providerId: id,
16
+ providerIdentifier: key,
17
+ });
18
+ container.register({
19
+ [_types_1.LockingProviderRegistrationPrefix + id]: (0, awilix_1.aliasTo)(regKey),
20
+ });
21
+ container.registerAdd(_types_1.LockingIdentifiersRegistrationName, (0, awilix_1.asValue)(key));
22
+ };
23
+ exports.default = async ({ container, options, }) => {
24
+ const logger = container.resolve(utils_1.ContainerRegistrationKeys.LOGGER);
25
+ container.registerAdd(_types_1.LockingIdentifiersRegistrationName, (0, awilix_1.asValue)(undefined));
26
+ // InMemoryLockingProvider - default provider
27
+ container.register({
28
+ [_types_1.LockingProviderRegistrationPrefix + in_memory_1.InMemoryLockingProvider.identifier]: (0, awilix_1.asFunction)((cradle) => new in_memory_1.InMemoryLockingProvider(), {
29
+ lifetime: awilix_1.Lifetime.SINGLETON,
30
+ }),
31
+ });
32
+ container.registerAdd(_types_1.LockingIdentifiersRegistrationName, (0, awilix_1.asValue)(in_memory_1.InMemoryLockingProvider.identifier));
33
+ container.register(_types_1.LockingDefaultProvider, (0, awilix_1.asValue)(in_memory_1.InMemoryLockingProvider.identifier));
34
+ // Load other providers
35
+ await (0, modules_sdk_1.moduleProviderLoader)({
36
+ container,
37
+ providers: options?.providers || [],
38
+ registerServiceFn: registrationFn,
39
+ });
40
+ const isSingleProvider = options?.providers?.length === 1;
41
+ let hasDefaultProvider = false;
42
+ for (const provider of options?.providers || []) {
43
+ if (provider.is_default || isSingleProvider) {
44
+ if (provider.is_default) {
45
+ hasDefaultProvider = true;
46
+ }
47
+ container.register(_types_1.LockingDefaultProvider, (0, awilix_1.asValue)(provider.id));
48
+ }
49
+ }
50
+ if (!hasDefaultProvider) {
51
+ logger.info(`Locking module: Using "${container.resolve(_types_1.LockingDefaultProvider)}" as default.`);
52
+ /*
53
+ logger.warn(
54
+ `No default locking provider explicit defined. Using "${container.resolve(
55
+ LockingDefaultProvider
56
+ )}" as default.`
57
+ )
58
+ */
59
+ }
60
+ };
61
+ //# sourceMappingURL=providers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"providers.js","sourceRoot":"","sources":["../../src/loaders/providers.ts"],"names":[],"mappings":";;AAAA,gEAAqE;AAMrE,oDAGiC;AACjC,yCAAkD;AAClD,mCAIe;AACf,sDAKkC;AAClC,sDAAgE;AAEhE,MAAM,cAAc,GAAG,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,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AA;IAED,uBAAuB;IACvB,MAAM,IAAA,kCAAoB,EAAC;QACzB,SAAS;QACT,SAAS,EAAE,OAAO,EAAE,SAAS,IAAI,EAAE;QACnC,iBAAiB,EAAE,cAAc;KAClC,CAAC,CAAA;IAEF,MAAM,gBAAgB,GAAG,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC,CAAA;IACzD,IAAI,kBAAkB,GAAG,KAAK,CAAA;IAC9B,KAAK,MAAM,QAAQ,IAAI,OAAO,EAAE,SAAS,IAAI,EAAE,EAAE,CAAC;QAChD,IAAI,QAAQ,CAAC,UAAU,IAAI,gBAAgB,EAAE,CAAC;YAC5C,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;gBACxB,kBAAkB,GAAG,IAAI,CAAA;YAC3B,CAAC;YACD,SAAS,CAAC,QAAQ,CAAC,+BAAsB,EAAE,IAAA,gBAAO,EAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAA;QAClE,CAAC;IACH,CAAC;IAED,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,MAAM,CAAC,IAAI,CACT,0BAA0B,SAAS,CAAC,OAAO,CACzC,+BAAsB,CACvB,eAAe,CACjB,CAAA;QACD;;;;;;UAME;IACJ,CAAC;AACH,CAAC,CAAA"}
@@ -0,0 +1,30 @@
1
+ import { ILockingProvider } from "@acmekit/framework/types";
2
+ export declare class InMemoryLockingProvider implements ILockingProvider {
3
+ static identifier: string;
4
+ private locks;
5
+ constructor();
6
+ private getPromise;
7
+ execute<T>(keys: string | string[], job: () => Promise<T>, args?: {
8
+ timeout?: number;
9
+ }): Promise<T>;
10
+ acquire(keys: string | string[], args?: {
11
+ ownerId?: string | null;
12
+ expire?: number;
13
+ awaitQueue?: boolean;
14
+ }): Promise<void>;
15
+ acquire_(keys: string | string[], args?: {
16
+ ownerId?: string | null;
17
+ expire?: number;
18
+ awaitQueue?: boolean;
19
+ }, cancellationToken?: {
20
+ cancelled: boolean;
21
+ }): Promise<void>;
22
+ release(keys: string | string[], args?: {
23
+ ownerId?: string | null;
24
+ }): Promise<boolean>;
25
+ releaseAll(args?: {
26
+ ownerId?: string | null;
27
+ }): Promise<void>;
28
+ private getTimeout;
29
+ }
30
+ //# sourceMappingURL=in-memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-memory.d.ts","sourceRoot":"","sources":["../../src/providers/in-memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAc3D,qBAAa,uBAAwB,YAAW,gBAAgB;IAC9D,MAAM,CAAC,UAAU,SAAc;IAE/B,OAAO,CAAC,KAAK,CAAmC;;IAIhD,OAAO,CAAC,UAAU;IAYZ,OAAO,CAAC,CAAC,EACb,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EACvB,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACrB,IAAI,CAAC,EAAE;QACL,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB,GACA,OAAO,CAAC,CAAC,CAAC;IA8BP,OAAO,CACX,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EACvB,IAAI,CAAC,EAAE;QACL,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;QACvB,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,UAAU,CAAC,EAAE,OAAO,CAAA;KACrB,GACA,OAAO,CAAC,IAAI,CAAC;IAIV,QAAQ,CACZ,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EACvB,IAAI,CAAC,EAAE;QACL,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;QACvB,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,UAAU,CAAC,EAAE,OAAO,CAAA;KACrB,EACD,iBAAiB,CAAC,EAAE;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,GACzC,OAAO,CAAC,IAAI,CAAC;IAmDV,OAAO,CACX,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EACvB,IAAI,CAAC,EAAE;QACL,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KACxB,GACA,OAAO,CAAC,OAAO,CAAC;IAyBb,UAAU,CAAC,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;YAkBrD,UAAU;CAWzB"}
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InMemoryLockingProvider = void 0;
4
+ const utils_1 = require("@acmekit/framework/utils");
5
+ class InMemoryLockingProvider {
6
+ constructor() {
7
+ this.locks = new Map();
8
+ }
9
+ getPromise() {
10
+ let resolve;
11
+ const pro = new Promise((ok) => {
12
+ resolve = ok;
13
+ });
14
+ return {
15
+ promise: pro,
16
+ resolve,
17
+ };
18
+ }
19
+ async execute(keys, job, args) {
20
+ const timeout = Math.max(args?.timeout ?? 5, 1);
21
+ const timeoutSeconds = Number.isNaN(timeout) ? 1 : timeout;
22
+ const cancellationToken = { cancelled: false };
23
+ const promises = [];
24
+ if (timeoutSeconds > 0) {
25
+ promises.push(this.getTimeout(timeoutSeconds, cancellationToken));
26
+ }
27
+ promises.push(this.acquire_(keys, {
28
+ expire: timeoutSeconds,
29
+ awaitQueue: true,
30
+ }, cancellationToken));
31
+ await Promise.race(promises);
32
+ try {
33
+ return await job();
34
+ }
35
+ finally {
36
+ await this.release(keys);
37
+ }
38
+ }
39
+ async acquire(keys, args) {
40
+ return this.acquire_(keys, args);
41
+ }
42
+ async acquire_(keys, args, cancellationToken) {
43
+ keys = Array.isArray(keys) ? keys : [keys];
44
+ const { ownerId, expire } = args ?? {};
45
+ for (const key of keys) {
46
+ const lock = this.locks.get(key);
47
+ const now = Date.now();
48
+ if (!lock) {
49
+ this.locks.set(key, {
50
+ ownerId: ownerId ?? null,
51
+ expiration: expire ? now + expire * 1000 : null,
52
+ currentPromise: this.getPromise(),
53
+ });
54
+ continue;
55
+ }
56
+ if (lock.expiration && lock.expiration <= now) {
57
+ lock.currentPromise?.resolve?.();
58
+ this.locks.set(key, {
59
+ ownerId: ownerId ?? null,
60
+ expiration: expire ? now + expire * 1000 : null,
61
+ currentPromise: this.getPromise(),
62
+ });
63
+ continue;
64
+ }
65
+ if (lock.ownerId !== null && lock.ownerId === ownerId) {
66
+ if (expire) {
67
+ lock.expiration = now + expire * 1000;
68
+ this.locks.set(key, lock);
69
+ }
70
+ continue;
71
+ }
72
+ if (lock.currentPromise && args?.awaitQueue) {
73
+ await lock.currentPromise.promise;
74
+ if (cancellationToken?.cancelled) {
75
+ return;
76
+ }
77
+ return this.acquire(keys, args);
78
+ }
79
+ throw new Error(`Failed to acquire lock for key "${key}"`);
80
+ }
81
+ }
82
+ async release(keys, args) {
83
+ const { ownerId } = args ?? {};
84
+ keys = Array.isArray(keys) ? keys : [keys];
85
+ let success = true;
86
+ for (const key of keys) {
87
+ const lock = this.locks.get(key);
88
+ if (!lock) {
89
+ success = false;
90
+ continue;
91
+ }
92
+ if ((0, utils_1.isDefined)(ownerId) && lock.ownerId !== ownerId) {
93
+ success = false;
94
+ continue;
95
+ }
96
+ lock.currentPromise?.resolve?.();
97
+ this.locks.delete(key);
98
+ }
99
+ return success;
100
+ }
101
+ async releaseAll(args) {
102
+ const { ownerId } = args ?? {};
103
+ if (!(0, utils_1.isDefined)(ownerId)) {
104
+ for (const [key, lock] of this.locks.entries()) {
105
+ lock.currentPromise?.resolve?.();
106
+ this.locks.delete(key);
107
+ }
108
+ }
109
+ else {
110
+ for (const [key, lock] of this.locks.entries()) {
111
+ if (lock.ownerId === ownerId) {
112
+ lock.currentPromise?.resolve?.();
113
+ this.locks.delete(key);
114
+ }
115
+ }
116
+ }
117
+ }
118
+ async getTimeout(seconds, cancellationToken) {
119
+ return new Promise((_, reject) => {
120
+ setTimeout(() => {
121
+ cancellationToken.cancelled = true;
122
+ reject(new Error("Timed-out acquiring lock."));
123
+ }, seconds * 1000).unref();
124
+ });
125
+ }
126
+ }
127
+ exports.InMemoryLockingProvider = InMemoryLockingProvider;
128
+ InMemoryLockingProvider.identifier = "in-memory";
129
+ //# sourceMappingURL=in-memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-memory.js","sourceRoot":"","sources":["../../src/providers/in-memory.ts"],"names":[],"mappings":";;;AACA,oDAAoD;AAapD,MAAa,uBAAuB;IAKlC;QAFQ,UAAK,GAA0B,IAAI,GAAG,EAAE,CAAA;IAEjC,CAAC;IAER,UAAU;QAChB,IAAI,OAAY,CAAA;QAChB,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE;YAC7B,OAAO,GAAG,EAAE,CAAA;QACd,CAAC,CAAC,CAAA;QAEF,OAAO;YACL,OAAO,EAAE,GAAG;YACZ,OAAO;SACR,CAAA;IACH,CAAC;IAED,KAAK,CAAC,OAAO,CACX,IAAuB,EACvB,GAAqB,EACrB,IAEC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;QAC/C,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAA;QAE1D,MAAM,iBAAiB,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,CAAA;QAC9C,MAAM,QAAQ,GAAmB,EAAE,CAAA;QACnC,IAAI,cAAc,GAAG,CAAC,EAAE,CAAC;YACvB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC,CAAA;QACnE,CAAC;QAED,QAAQ,CAAC,IAAI,CACX,IAAI,CAAC,QAAQ,CACX,IAAI,EACJ;YACE,MAAM,EAAE,cAAc;YACtB,UAAU,EAAE,IAAI;SACjB,EACD,iBAAiB,CAClB,CACF,CAAA;QAED,MAAM,OAAO,CAAC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AyC;QAEzC,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;YAC/B,UAAU,CAAC,GAAG,EAAE;gBACd,iBAAiB,CAAC,SAAS,GAAG,IAAI,CAAA;gBAClC,MAAM,CAAC,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC,CAAA;YAChD,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC,CAAC,KAAK,EAAE,CAAA;QAC5B,CAAC,CAAC,CAAA;IACJ,CAAC;;AAvLH,0DAwLC;AAvLQ,kCAAU,GAAG,WAAW,AAAd,CAAc"}
@@ -0,0 +1,3 @@
1
+ export { default as LockingModuleService } from "./locking-module";
2
+ export { default as LockingProviderService } from "./locking-provider";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAClE,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,oBAAoB,CAAA"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.LockingProviderService = exports.LockingModuleService = void 0;
7
+ var locking_module_1 = require("./locking-module");
8
+ Object.defineProperty(exports, "LockingModuleService", { enumerable: true, get: function () { return __importDefault(locking_module_1).default; } });
9
+ var locking_provider_1 = require("./locking-provider");
10
+ Object.defineProperty(exports, "LockingProviderService", { enumerable: true, get: function () { return __importDefault(locking_provider_1).default; } });
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;AAAA,mDAAkE;AAAzD,uIAAA,OAAO,OAAwB;AACxC,uDAAsE;AAA7D,2IAAA,OAAO,OAA0B"}
@@ -0,0 +1,36 @@
1
+ import { Context, ILockingModule, InternalModuleDeclaration, Logger } from "@acmekit/types";
2
+ import { EntityManager } from "@acmekit/framework/mikro-orm/core";
3
+ import { LockingDefaultProvider } from "../types";
4
+ import LockingProviderService from "./locking-provider";
5
+ type InjectedDependencies = {
6
+ manager: EntityManager;
7
+ lockingProviderService: LockingProviderService;
8
+ logger?: Logger;
9
+ [LockingDefaultProvider]: string;
10
+ };
11
+ export default class LockingModuleService implements ILockingModule {
12
+ protected readonly moduleDeclaration: InternalModuleDeclaration;
13
+ protected manager: EntityManager;
14
+ protected providerService_: LockingProviderService;
15
+ protected defaultProviderId: string;
16
+ constructor(container: InjectedDependencies, moduleDeclaration: InternalModuleDeclaration);
17
+ execute<T>(keys: string | string[], job: () => Promise<T>, args?: {
18
+ timeout?: number;
19
+ provider?: string;
20
+ }, sharedContext?: Context): Promise<T>;
21
+ acquire(keys: string | string[], args?: {
22
+ ownerId?: string | null;
23
+ expire?: number;
24
+ provider?: string;
25
+ }, sharedContext?: Context): Promise<void>;
26
+ release(keys: string | string[], args?: {
27
+ ownerId?: string | null;
28
+ provider?: string;
29
+ }, sharedContext?: Context): Promise<boolean>;
30
+ releaseAll(args?: {
31
+ ownerId?: string | null;
32
+ provider?: string;
33
+ }, sharedContext?: Context): Promise<void>;
34
+ }
35
+ export {};
36
+ //# sourceMappingURL=locking-module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locking-module.d.ts","sourceRoot":"","sources":["../../src/services/locking-module.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,cAAc,EACd,yBAAyB,EACzB,MAAM,EACP,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAA;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAA;AAC/C,OAAO,sBAAsB,MAAM,oBAAoB,CAAA;AAEv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UAAU,CACd,IAAI,CAAC,EAAE;QACL,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAA;KAClB,EACD,aAAa,GAAE,OAAY,GAC1B,OAAO,CAAC,IAAI,CAAC;CAOjB"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const _types_1 = require("../types");
4
+ class LockingModuleService {
5
+ constructor(container, moduleDeclaration) {
6
+ this.moduleDeclaration = moduleDeclaration;
7
+ this.manager = container.manager;
8
+ this.providerService_ = container.lockingProviderService;
9
+ this.defaultProviderId = container[_types_1.LockingDefaultProvider];
10
+ }
11
+ async execute(keys, job, args, sharedContext = {}) {
12
+ const providerId = args?.provider ?? this.defaultProviderId;
13
+ const provider = this.providerService_.retrieveProviderRegistration(providerId);
14
+ return provider.execute(keys, job, args, sharedContext);
15
+ }
16
+ async acquire(keys, args, sharedContext = {}) {
17
+ const providerId = args?.provider ?? this.defaultProviderId;
18
+ const provider = this.providerService_.retrieveProviderRegistration(providerId);
19
+ await provider.acquire(keys, args, sharedContext);
20
+ }
21
+ async release(keys, args, sharedContext = {}) {
22
+ const providerId = args?.provider ?? this.defaultProviderId;
23
+ const provider = this.providerService_.retrieveProviderRegistration(providerId);
24
+ return await provider.release(keys, args, sharedContext);
25
+ }
26
+ async releaseAll(args, sharedContext = {}) {
27
+ const providerId = args?.provider ?? this.defaultProviderId;
28
+ const provider = this.providerService_.retrieveProviderRegistration(providerId);
29
+ return await provider.releaseAll(args, sharedContext);
30
+ }
31
+ }
32
+ exports.default = LockingModuleService;
33
+ //# sourceMappingURL=locking-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locking-module.js","sourceRoot":"","sources":["../../src/services/locking-module.ts"],"names":[],"mappings":";;AAOA,mCAA+C;AAU/C,MAAqB,oBAAoB;IAKvC,YACE,SAA+B,EACZ,iBAA4C;QAA5C,sBAAiB,GAAjB,iBAAi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EACD,gBAAyB,EAAE;QAE3B,MAAM,UAAU,GAAG,IAAI,EAAE,QAAQ,IAAI,IAAI,CAAC,iBAAiB,CAAA;QAC3D,MAAM,QAAQ,GACZ,IAAI,CAAC,gBAAgB,CAAC,4BAA4B,CAAC,UAAU,CAAC,CAAA;QAEhE,OAAO,MAAM,QAAQ,CAAC,UAAU,CAAC,IAAI,EAAE,aAAa,CAAC,CAAA;IACvD,CAAC;CACF;AA1ED,uCA0EC"}
@@ -0,0 +1,14 @@
1
+ import { Constructor, ILockingProvider, Logger } from "@acmekit/framework/types";
2
+ type InjectedDependencies = {
3
+ [key: `lp_${string}`]: ILockingProvider;
4
+ logger?: Logger;
5
+ };
6
+ export default class LockingProviderService {
7
+ #private;
8
+ protected __container__: InjectedDependencies;
9
+ constructor(container: InjectedDependencies);
10
+ static getRegistrationIdentifier(providerClass: Constructor<ILockingProvider>): string;
11
+ retrieveProviderRegistration(providerId: string): ILockingProvider;
12
+ }
13
+ export {};
14
+ //# sourceMappingURL=locking-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locking-provider.d.ts","sourceRoot":"","sources":["../../src/services/locking-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,MAAM,EACP,MAAM,0BAA0B,CAAA;AAIjC,KAAK,oBAAoB,GAAG;IAC1B,CAAC,GAAG,EAAE,MAAM,MAAM,EAAE,GAAG,gBAAgB,CAAA;IACvC,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,CAAC,OAAO,OAAO,sBAAsB;;IACzC,SAAS,CAAC,aAAa,EAAE,oBAAoB,CAAA;gBAGjC,SAAS,EAAE,oBAAoB;IAO3C,MAAM,CAAC,yBAAyB,CAC9B,aAAa,EAAE,WAAW,CAAC,gBAAgB,CAAC;IAWvC,4BAA4B,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB;CAuB1E"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _LockingProviderService_logger;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const utils_1 = require("@acmekit/framework/utils");
16
+ const types_1 = require("../types");
17
+ class LockingProviderService {
18
+ constructor(container) {
19
+ _LockingProviderService_logger.set(this, void 0);
20
+ this.__container__ = container;
21
+ __classPrivateFieldSet(this, _LockingProviderService_logger, container["logger"]
22
+ ? container.logger
23
+ : console, "f");
24
+ }
25
+ static getRegistrationIdentifier(providerClass) {
26
+ if (!providerClass.identifier) {
27
+ throw new utils_1.AcmeKitError(utils_1.AcmeKitError.Types.INVALID_ARGUMENT, `Trying to register a locking provider without an identifier.`);
28
+ }
29
+ return `${providerClass.identifier}`;
30
+ }
31
+ retrieveProviderRegistration(providerId) {
32
+ try {
33
+ return this.__container__[`${types_1.LockingProviderRegistrationPrefix}${providerId}`];
34
+ }
35
+ catch (err) {
36
+ if (err.name === "AwilixResolutionError") {
37
+ const errMessage = `
38
+ Unable to retrieve the locking provider with id: ${providerId}
39
+ Please make sure that the provider is registered in the container and it is configured correctly in your project configuration file.`;
40
+ // Log full error for debugging
41
+ __classPrivateFieldGet(this, _LockingProviderService_logger, "f").error(`AwilixResolutionError: ${err.message}`, err);
42
+ throw new Error(errMessage);
43
+ }
44
+ const errMessage = `Unable to retrieve the locking provider with id: ${providerId}, the following error occurred: ${err.message}`;
45
+ __classPrivateFieldGet(this, _LockingProviderService_logger, "f").error(errMessage);
46
+ throw new Error(errMessage);
47
+ }
48
+ }
49
+ }
50
+ _LockingProviderService_logger = new WeakMap();
51
+ exports.default = LockingProviderService;
52
+ //# sourceMappingURL=locking-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locking-provider.js","sourceRoot":"","sources":["../../src/services/locking-provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAKA,oDAAuD;AACvD,oCAA4D;AAO5D,MAAqB,sBAAsB;IAIzC,YAAY,SAA+B;QAF3C,iDAAe;QAGb,IAAI,CAAC,aAAa,GAAG,SAAS,CAAA;QAC9B,uBAAA,IAAI,kCAAW,SAAS,CAAC,QAAQ,CAAC;YAChC,CAAC,CAAC,SAAS,CAAC,MAAM;YAClB,CAAC,CAAE,OAA6B,MAAA,CAAA;IACpC,CAAC;IAED,MAAM,CAAC,yBAAyB,CAC9B,aAA4C;QAE5C,IAAI,CAAE,aAAqB,CAAC,UAAU,EAAE,CAAC;YACvC,MAAM,IAAI,oBAAY,CACpB,oBAAY,CAAC,KAAK,CAAC,gBAAgB,EACnC,8DAA8D,CAC/D,CAAA;QACH,CAAC;QACD,OAAO,GAAI,aAAqB,CAAC,UAAU,EAAE,CAAA;IAC/C,CAAC;IAEM,4BAA4B,CAAC,UAAkB;QACpD,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,aAAa,CACvB,GAAG,yCAAiC,GAAG,UAAU,EAAE,CACpD,CAAA;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,GAAG,CAAC,IAAI,KAAK,uBAAuB,EAAE,CAAC;gBACzC,MAAM,UAAU,GAAG;oDACyB,UAAU;qIACuE,CAAA;gBAE7H,+BAA+B;gBAC/B,uBAAA,IAAI,sCAAQ,CAAC,KAAK,CAAC,0BAA0B,GAAG,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,CAAA;gBAEhE,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC,CAAA;YAC7B,CAAC;YAED,MAAM,UAAU,GAAG,oDAAoD,UAAU,mCAAmC,GAAG,CAAC,OAAO,EAAE,CAAA;YACjI,uBAAA,IAAI,sCAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;YAE9B,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC,CAAA;QAC7B,CAAC;IACH,CAAC;CACF;;kBA9CoB,sBAAsB"}
@@ -0,0 +1 @@
1
+ {"root":["../src/index.ts","../src/loaders/providers.ts","../src/providers/in-memory.ts","../src/services/index.ts","../src/services/locking-module.ts","../src/services/locking-provider.ts","../src/types/index.ts"],"version":"5.9.3"}
@@ -0,0 +1,34 @@
1
+ import { ModuleProviderExports, ModuleServiceInitializeOptions } from "@acmekit/framework/types";
2
+ export declare const LockingDefaultProvider = "default_provider";
3
+ export declare const LockingIdentifiersRegistrationName = "locking_providers_identifier";
4
+ export declare const LockingProviderRegistrationPrefix = "lp_";
5
+ export type LockingModuleOptions = Partial<ModuleServiceInitializeOptions> & {
6
+ /**
7
+ * Providers to be registered
8
+ */
9
+ providers?: {
10
+ /**
11
+ * The module provider to be registered
12
+ */
13
+ resolve: string | ModuleProviderExports;
14
+ /**
15
+ * If the provider is the default
16
+ */
17
+ is_default?: boolean;
18
+ /**
19
+ * The id of the provider
20
+ */
21
+ id: string;
22
+ /**
23
+ * key value pair of the configuration to be passed to the provider constructor
24
+ */
25
+ options?: Record<string, unknown>;
26
+ }[];
27
+ };
28
+ declare module "@acmekit/types" {
29
+ interface ModuleOptions {
30
+ "@acmekit/locking": LockingModuleOptions;
31
+ "@acmekit/acmekit/locking": LockingModuleOptions;
32
+ }
33
+ }
34
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,8BAA8B,EAC/B,MAAM,0BAA0B,CAAA;AAEjC,eAAO,MAAM,sBAAsB,qBAAqB,CAAA;AACxD,eAAO,MAAM,kCAAkC,iCAAiC,CAAA;AAEhF,eAAO,MAAM,iCAAiC,QAAQ,CAAA;AAEtD,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,8BAA8B,CAAC,GAAG;IAC3E;;OAEG;IACH,SAAS,CAAC,EAAE;QACV;;WAEG;QACH,OAAO,EAAE,MAAM,GAAG,qBAAqB,CAAA;QACvC;;WAEG;QACH,UAAU,CAAC,EAAE,OAAO,CAAA;QACpB;;WAEG;QACH,EAAE,EAAE,MAAM,CAAA;QACV;;WAEG;QACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAClC,EAAE,CAAA;CACJ,CAAA;AAED,OAAO,QAAQ,gBAAgB,CAAC;IAC9B,UAAU,aAAa;QACrB,kBAAkB,EAAE,oBAAoB,CAAA;QACxC,0BAA0B,EAAE,oBAAoB,CAAA;KACjD;CACF"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LockingProviderRegistrationPrefix = exports.LockingIdentifiersRegistrationName = exports.LockingDefaultProvider = void 0;
4
+ exports.LockingDefaultProvider = "default_provider";
5
+ exports.LockingIdentifiersRegistrationName = "locking_providers_identifier";
6
+ exports.LockingProviderRegistrationPrefix = "lp_";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;AAKa,QAAA,sBAAsB,GAAG,kBAAkB,CAAA;AAC3C,QAAA,kCAAkC,GAAG,8BAA8B,CAAA;AAEnE,QAAA,iCAAiC,GAAG,KAAK,CAAA"}
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@acmekit/locking",
3
+ "version": "2.13.1",
4
+ "description": "Locking Module for AcmeKit",
5
+ "main": "dist/index.js",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/acmekit/acmekit",
9
+ "directory": "packages/modules/locking"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "!dist/**/__tests__",
14
+ "!dist/**/__mocks__",
15
+ "!dist/**/__fixtures__"
16
+ ],
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "author": "AcmeKit",
21
+ "license": "MIT",
22
+ "scripts": {
23
+ "watch": "yarn run -T tsc --build --watch",
24
+ "watch:test": "yarn run -T tsc --build tsconfig.spec.json --watch",
25
+ "resolve:aliases": "yarn run -T tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && yarn run -T tsc-alias -p tsconfig.resolved.json && yarn run -T rimraf tsconfig.resolved.json",
26
+ "build": "yarn run -T rimraf dist && yarn run -T tsc --build && npm run resolve:aliases",
27
+ "test": "../../../node_modules/.bin/jest --passWithNoTests --bail --forceExit --testPathPattern=src",
28
+ "test:integration": "../../../node_modules/.bin/jest --passWithNoTests --forceExit --testPathPattern=\"integration-tests/__tests__/.*\\.spec\\.ts\"",
29
+ "migration:initial": "MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts MIKRO_ORM_ALLOW_GLOBAL_CLI=true acmekit-mikro-orm migration:create --initial -n InitialSetupMigration",
30
+ "migration:create": "MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts MIKRO_ORM_ALLOW_GLOBAL_CLI=true acmekit-mikro-orm migration:create",
31
+ "migration:up": "MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts MIKRO_ORM_ALLOW_GLOBAL_CLI=true acmekit-mikro-orm migration:up",
32
+ "orm:cache:clear": "MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts MIKRO_ORM_ALLOW_GLOBAL_CLI=true acmekit-mikro-orm cache:clear"
33
+ },
34
+ "devDependencies": {
35
+ "@acmekit/framework": "2.13.1",
36
+ "@acmekit/test-utils": "2.13.1"
37
+ },
38
+ "peerDependencies": {
39
+ "@acmekit/framework": "2.13.1"
40
+ }
41
+ }