@autometa/app 0.2.4 → 0.3.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/CHANGELOG.md +17 -0
- package/dist/esm/index.js +12 -85
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.cts +6 -59
- package/dist/index.d.ts +6 -59
- package/dist/index.js +12 -79
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @autometa/app
|
|
2
2
|
|
|
3
|
+
## 0.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6c4bb8d: fix: getApp function not defined
|
|
8
|
+
|
|
9
|
+
## 0.3.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 98d911f: feat: replace tsyringe with custom DI solution
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [98d911f]
|
|
18
|
+
- @autometa/injection@0.1.0
|
|
19
|
+
|
|
3
20
|
## 0.2.4
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/esm/index.js
CHANGED
|
@@ -1,109 +1,36 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
-
if (decorator = decorators[i])
|
|
7
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
-
if (kind && result)
|
|
9
|
-
__defProp(target, key, result);
|
|
10
|
-
return result;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
1
|
// src/autometa-app.ts
|
|
14
2
|
var AutometaApp = class {
|
|
15
3
|
};
|
|
16
4
|
|
|
17
5
|
// src/autometa-world.ts
|
|
18
|
-
import { PhraseParser } from "@autometa/phrases";
|
|
19
6
|
var AutometaWorld = class {
|
|
20
7
|
};
|
|
21
|
-
AutometaWorld = __decorateClass([
|
|
22
|
-
PhraseParser
|
|
23
|
-
], AutometaWorld);
|
|
24
8
|
|
|
25
9
|
// src/get-app.ts
|
|
26
|
-
import { container } from "tsyringe";
|
|
27
|
-
import { AutomationError } from "@autometa/errors";
|
|
28
10
|
import { v4 } from "uuid";
|
|
29
|
-
import {
|
|
30
|
-
function getApp(appType,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
Configure the app by extending 'AutometaApp' and adding it to your
|
|
35
|
-
'autometa.config.ts' file:
|
|
36
|
-
|
|
37
|
-
@AppType(MyWorld)
|
|
38
|
-
export class MyAutometaApp extends AutometaApp {
|
|
39
|
-
...
|
|
40
|
-
}
|
|
41
|
-
defineConfig({
|
|
42
|
-
roots: {
|
|
43
|
-
app: './src/app'
|
|
44
|
-
}
|
|
45
|
-
})`);
|
|
46
|
-
}
|
|
47
|
-
instances.forEach(({ token, instance, cls }) => {
|
|
48
|
-
const proxiedCls = cls ? ErrorCatcherProxy(cls) : void 0;
|
|
49
|
-
const proxiedInst = instance ? ErrorCatcherProxy(instance) : void 0;
|
|
50
|
-
return child.register(token, proxiedInst ?? proxiedCls);
|
|
51
|
-
});
|
|
52
|
-
const child = container.createChildContainer();
|
|
53
|
-
const app = ErrorCatcherProxy(child.resolve(appType));
|
|
54
|
-
app.world = child.resolve(worldType);
|
|
55
|
-
app.id = v4();
|
|
56
|
-
return app;
|
|
11
|
+
import { Container, defineContainerContext } from "@autometa/injection";
|
|
12
|
+
function getApp(appType, containerName = v4()) {
|
|
13
|
+
const context = defineContainerContext(containerName);
|
|
14
|
+
const container = new Container(context);
|
|
15
|
+
return container.get(appType);
|
|
57
16
|
}
|
|
58
17
|
|
|
59
|
-
// src/decorators/fixture.ts
|
|
60
|
-
import "reflect-metadata";
|
|
61
|
-
import {
|
|
62
|
-
scoped,
|
|
63
|
-
inject,
|
|
64
|
-
Lifecycle as LC,
|
|
65
|
-
injectable,
|
|
66
|
-
singleton
|
|
67
|
-
} from "tsyringe";
|
|
68
|
-
function Fixture(arg) {
|
|
69
|
-
if (arg !== void 0 && typeof arg !== "number") {
|
|
70
|
-
injectable()(arg);
|
|
71
|
-
scoped(LC.ContainerScoped)(arg);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
return (target) => {
|
|
75
|
-
injectable()(target);
|
|
76
|
-
if (arg === LIFE_CYCLE.Singleton) {
|
|
77
|
-
singleton()(target);
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
scoped(arg ?? LIFE_CYCLE.ContainerScoped)(target);
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
var Inject = inject;
|
|
84
|
-
var LIFE_CYCLE = {
|
|
85
|
-
Transient: LC.Transient,
|
|
86
|
-
Singleton: LC.Singleton,
|
|
87
|
-
ResolutionScoped: LC.ResolutionScoped,
|
|
88
|
-
ContainerScoped: LC.ContainerScoped
|
|
89
|
-
};
|
|
90
|
-
|
|
91
18
|
// src/decorators/app-type.ts
|
|
92
|
-
import {
|
|
93
|
-
function AppType(
|
|
19
|
+
import { metadata } from "@autometa/injection";
|
|
20
|
+
function AppType(container, world, environment = "default") {
|
|
94
21
|
const env = environment ?? "default";
|
|
95
22
|
return (target) => {
|
|
96
|
-
|
|
97
|
-
|
|
23
|
+
metadata(target.prototype).set({
|
|
24
|
+
key: "world",
|
|
25
|
+
class: world
|
|
26
|
+
});
|
|
27
|
+
container[env] = { app: target, world };
|
|
98
28
|
};
|
|
99
29
|
}
|
|
100
30
|
export {
|
|
101
31
|
AppType,
|
|
102
32
|
AutometaApp,
|
|
103
33
|
AutometaWorld,
|
|
104
|
-
Fixture,
|
|
105
|
-
Inject,
|
|
106
|
-
LIFE_CYCLE,
|
|
107
34
|
getApp
|
|
108
35
|
};
|
|
109
36
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/autometa-app.ts","../../src/autometa-world.ts","../../src/get-app.ts","../../src/decorators/
|
|
1
|
+
{"version":3,"sources":["../../src/autometa-app.ts","../../src/autometa-world.ts","../../src/get-app.ts","../../src/decorators/app-type.ts"],"sourcesContent":["import { World } from \"./fixtures.typings\";\nexport abstract class AutometaApp {\n id: string;\n [key: string]: unknown;\n world: World;\n}\n","export class AutometaWorld {}\n","import { AutometaApp } from \"./autometa-app\";\nimport { Class } from \"@autometa/types\";\nimport { v4 } from \"uuid\";\nimport { Container, defineContainerContext } from \"@autometa/injection\";\nimport { App } from \"./fixtures.typings\";\nexport function getApp<T extends AutometaApp>(\n appType: Class<T>,\n containerName = v4()\n): App {\n const context = defineContainerContext(containerName);\n const container = new Container(context);\n return container.get(appType);\n}\n","import { Class } from \"@autometa/types\";\nimport { App, World, AutometaWorld } from \"..\";\nimport { metadata } from \"@autometa/injection\";\nexport function AppType(\n container: Record<string, { app: Class<App>; world: Class<World> }>,\n world: Class<AutometaWorld>,\n environment = \"default\"\n) {\n const env = environment ?? \"default\";\n return (target: Class<unknown>) => {\n metadata(target.prototype).set({\n key: \"world\",\n class: world\n });\n container[env] = { app: target as Class<App>, world: world as Class<World> };\n };\n}\n"],"mappings":";AACO,IAAe,cAAf,MAA2B;AAIlC;;;ACLO,IAAM,gBAAN,MAAoB;AAAC;;;ACE5B,SAAS,UAAU;AACnB,SAAS,WAAW,8BAA8B;AAE3C,SAAS,OACd,SACA,gBAAgB,GAAG,GACd;AACL,QAAM,UAAU,uBAAuB,aAAa;AACpD,QAAM,YAAY,IAAI,UAAU,OAAO;AACvC,SAAO,UAAU,IAAI,OAAO;AAC9B;;;ACVA,SAAS,gBAAgB;AAClB,SAAS,QACd,WACA,OACA,cAAc,WACd;AACA,QAAM,MAAM,eAAe;AAC3B,SAAO,CAAC,WAA2B;AACjC,aAAS,OAAO,SAAS,EAAE,IAAI;AAAA,MAC7B,KAAK;AAAA,MACL,OAAO;AAAA,IACT,CAAC;AACD,cAAU,GAAG,IAAI,EAAE,KAAK,QAAsB,MAA6B;AAAA,EAC7E;AACF;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { Container } from '@autometa/injection';
|
|
1
2
|
import { Class } from '@autometa/types';
|
|
2
|
-
import { inject } from 'tsyringe';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Basic Key Value store for managing state across Step Definitions. A unique copy of this object
|
|
@@ -87,8 +87,8 @@ interface World {
|
|
|
87
87
|
* ```
|
|
88
88
|
*/
|
|
89
89
|
interface App {
|
|
90
|
-
readonly id: string;
|
|
91
90
|
world: World;
|
|
91
|
+
di: Container;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
declare abstract class AutometaApp {
|
|
@@ -98,66 +98,13 @@ declare abstract class AutometaApp {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
declare class AutometaWorld {
|
|
101
|
-
[key: string]: unknown;
|
|
102
101
|
}
|
|
103
102
|
|
|
104
|
-
declare function getApp<T extends AutometaApp
|
|
105
|
-
token: any;
|
|
106
|
-
instance?: any;
|
|
107
|
-
cls?: Class<any>;
|
|
108
|
-
}[]): T;
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Marks a class as an injectable fixture. Constructor parameters
|
|
112
|
-
* which are also injectable will be automatically constructed
|
|
113
|
-
* and passed to the constructor.
|
|
114
|
-
*
|
|
115
|
-
* Example fixtures are the `App` which acts as shared
|
|
116
|
-
* entry point for all steps in a test, and the World,
|
|
117
|
-
* which stores persistent data across tests.
|
|
118
|
-
*
|
|
119
|
-
* Fixtures are persistent by default, meaning each class
|
|
120
|
-
* will exist as a singleton for the duration of the test
|
|
121
|
-
* ```ts
|
|
122
|
-
* @Fixture
|
|
123
|
-
* export class World {
|
|
124
|
-
* [key: string]: unknown;
|
|
125
|
-
*
|
|
126
|
-
* declare someExpectedData: MyDataType
|
|
127
|
-
* }
|
|
128
|
-
*
|
|
129
|
-
* @Fixture
|
|
130
|
-
* export class MyClient {
|
|
131
|
-
* constructor(world: MyWorld){}
|
|
132
|
-
*
|
|
133
|
-
* login = async ()=>{
|
|
134
|
-
* this.world.someExpectedData = await fetch(...)
|
|
135
|
-
* }
|
|
136
|
-
* }
|
|
137
|
-
*
|
|
138
|
-
* @Fixture
|
|
139
|
-
* export class App {
|
|
140
|
-
* constructor(
|
|
141
|
-
* world: MyWorld,
|
|
142
|
-
* client: MyClient
|
|
143
|
-
* ){}
|
|
144
|
-
* }
|
|
145
|
-
* ```
|
|
146
|
-
*/
|
|
147
|
-
declare function Fixture(target: Class<unknown>): void;
|
|
148
|
-
declare function Fixture<T extends Class<unknown>>(scope?: Lifecycle): (target: T) => void;
|
|
149
|
-
declare const Inject: typeof inject;
|
|
150
|
-
declare const LIFE_CYCLE: {
|
|
151
|
-
readonly Transient: 0;
|
|
152
|
-
readonly Singleton: 1;
|
|
153
|
-
readonly ResolutionScoped: 2;
|
|
154
|
-
readonly ContainerScoped: 3;
|
|
155
|
-
};
|
|
156
|
-
type Lifecycle = (typeof LIFE_CYCLE)[keyof typeof LIFE_CYCLE];
|
|
103
|
+
declare function getApp<T extends AutometaApp>(appType: Class<T>, containerName?: string): App;
|
|
157
104
|
|
|
158
105
|
declare function AppType(container: Record<string, {
|
|
159
|
-
app:
|
|
160
|
-
world:
|
|
106
|
+
app: Class<App>;
|
|
107
|
+
world: Class<World>;
|
|
161
108
|
}>, world: Class<AutometaWorld>, environment?: string): (target: Class<unknown>) => void;
|
|
162
109
|
|
|
163
|
-
export { App, AppType, AutometaApp, AutometaWorld,
|
|
110
|
+
export { App, AppType, AutometaApp, AutometaWorld, World, getApp };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { Container } from '@autometa/injection';
|
|
1
2
|
import { Class } from '@autometa/types';
|
|
2
|
-
import { inject } from 'tsyringe';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Basic Key Value store for managing state across Step Definitions. A unique copy of this object
|
|
@@ -87,8 +87,8 @@ interface World {
|
|
|
87
87
|
* ```
|
|
88
88
|
*/
|
|
89
89
|
interface App {
|
|
90
|
-
readonly id: string;
|
|
91
90
|
world: World;
|
|
91
|
+
di: Container;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
declare abstract class AutometaApp {
|
|
@@ -98,66 +98,13 @@ declare abstract class AutometaApp {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
declare class AutometaWorld {
|
|
101
|
-
[key: string]: unknown;
|
|
102
101
|
}
|
|
103
102
|
|
|
104
|
-
declare function getApp<T extends AutometaApp
|
|
105
|
-
token: any;
|
|
106
|
-
instance?: any;
|
|
107
|
-
cls?: Class<any>;
|
|
108
|
-
}[]): T;
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Marks a class as an injectable fixture. Constructor parameters
|
|
112
|
-
* which are also injectable will be automatically constructed
|
|
113
|
-
* and passed to the constructor.
|
|
114
|
-
*
|
|
115
|
-
* Example fixtures are the `App` which acts as shared
|
|
116
|
-
* entry point for all steps in a test, and the World,
|
|
117
|
-
* which stores persistent data across tests.
|
|
118
|
-
*
|
|
119
|
-
* Fixtures are persistent by default, meaning each class
|
|
120
|
-
* will exist as a singleton for the duration of the test
|
|
121
|
-
* ```ts
|
|
122
|
-
* @Fixture
|
|
123
|
-
* export class World {
|
|
124
|
-
* [key: string]: unknown;
|
|
125
|
-
*
|
|
126
|
-
* declare someExpectedData: MyDataType
|
|
127
|
-
* }
|
|
128
|
-
*
|
|
129
|
-
* @Fixture
|
|
130
|
-
* export class MyClient {
|
|
131
|
-
* constructor(world: MyWorld){}
|
|
132
|
-
*
|
|
133
|
-
* login = async ()=>{
|
|
134
|
-
* this.world.someExpectedData = await fetch(...)
|
|
135
|
-
* }
|
|
136
|
-
* }
|
|
137
|
-
*
|
|
138
|
-
* @Fixture
|
|
139
|
-
* export class App {
|
|
140
|
-
* constructor(
|
|
141
|
-
* world: MyWorld,
|
|
142
|
-
* client: MyClient
|
|
143
|
-
* ){}
|
|
144
|
-
* }
|
|
145
|
-
* ```
|
|
146
|
-
*/
|
|
147
|
-
declare function Fixture(target: Class<unknown>): void;
|
|
148
|
-
declare function Fixture<T extends Class<unknown>>(scope?: Lifecycle): (target: T) => void;
|
|
149
|
-
declare const Inject: typeof inject;
|
|
150
|
-
declare const LIFE_CYCLE: {
|
|
151
|
-
readonly Transient: 0;
|
|
152
|
-
readonly Singleton: 1;
|
|
153
|
-
readonly ResolutionScoped: 2;
|
|
154
|
-
readonly ContainerScoped: 3;
|
|
155
|
-
};
|
|
156
|
-
type Lifecycle = (typeof LIFE_CYCLE)[keyof typeof LIFE_CYCLE];
|
|
103
|
+
declare function getApp<T extends AutometaApp>(appType: Class<T>, containerName?: string): App;
|
|
157
104
|
|
|
158
105
|
declare function AppType(container: Record<string, {
|
|
159
|
-
app:
|
|
160
|
-
world:
|
|
106
|
+
app: Class<App>;
|
|
107
|
+
world: Class<World>;
|
|
161
108
|
}>, world: Class<AutometaWorld>, environment?: string): (target: Class<unknown>) => void;
|
|
162
109
|
|
|
163
|
-
export { App, AppType, AutometaApp, AutometaWorld,
|
|
110
|
+
export { App, AppType, AutometaApp, AutometaWorld, World, getApp };
|
package/dist/index.js
CHANGED
|
@@ -16,15 +16,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
20
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
21
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
22
|
-
if (decorator = decorators[i])
|
|
23
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
24
|
-
if (kind && result)
|
|
25
|
-
__defProp(target, key, result);
|
|
26
|
-
return result;
|
|
27
|
-
};
|
|
28
19
|
|
|
29
20
|
// src/index.ts
|
|
30
21
|
var src_exports = {};
|
|
@@ -32,9 +23,6 @@ __export(src_exports, {
|
|
|
32
23
|
AppType: () => AppType,
|
|
33
24
|
AutometaApp: () => AutometaApp,
|
|
34
25
|
AutometaWorld: () => AutometaWorld,
|
|
35
|
-
Fixture: () => Fixture,
|
|
36
|
-
Inject: () => Inject,
|
|
37
|
-
LIFE_CYCLE: () => LIFE_CYCLE,
|
|
38
26
|
getApp: () => getApp
|
|
39
27
|
});
|
|
40
28
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -44,80 +32,28 @@ var AutometaApp = class {
|
|
|
44
32
|
};
|
|
45
33
|
|
|
46
34
|
// src/autometa-world.ts
|
|
47
|
-
var import_phrases = require("@autometa/phrases");
|
|
48
35
|
var AutometaWorld = class {
|
|
49
36
|
};
|
|
50
|
-
AutometaWorld = __decorateClass([
|
|
51
|
-
import_phrases.PhraseParser
|
|
52
|
-
], AutometaWorld);
|
|
53
37
|
|
|
54
38
|
// src/get-app.ts
|
|
55
|
-
var import_tsyringe = require("tsyringe");
|
|
56
|
-
var import_errors = require("@autometa/errors");
|
|
57
39
|
var import_uuid = require("uuid");
|
|
58
|
-
var
|
|
59
|
-
function getApp(appType,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
Configure the app by extending 'AutometaApp' and adding it to your
|
|
64
|
-
'autometa.config.ts' file:
|
|
65
|
-
|
|
66
|
-
@AppType(MyWorld)
|
|
67
|
-
export class MyAutometaApp extends AutometaApp {
|
|
68
|
-
...
|
|
40
|
+
var import_injection = require("@autometa/injection");
|
|
41
|
+
function getApp(appType, containerName = (0, import_uuid.v4)()) {
|
|
42
|
+
const context = (0, import_injection.defineContainerContext)(containerName);
|
|
43
|
+
const container = new import_injection.Container(context);
|
|
44
|
+
return container.get(appType);
|
|
69
45
|
}
|
|
70
|
-
defineConfig({
|
|
71
|
-
roots: {
|
|
72
|
-
app: './src/app'
|
|
73
|
-
}
|
|
74
|
-
})`);
|
|
75
|
-
}
|
|
76
|
-
instances.forEach(({ token, instance, cls }) => {
|
|
77
|
-
const proxiedCls = cls ? (0, import_fixture_proxies.ErrorCatcherProxy)(cls) : void 0;
|
|
78
|
-
const proxiedInst = instance ? (0, import_fixture_proxies.ErrorCatcherProxy)(instance) : void 0;
|
|
79
|
-
return child.register(token, proxiedInst ?? proxiedCls);
|
|
80
|
-
});
|
|
81
|
-
const child = import_tsyringe.container.createChildContainer();
|
|
82
|
-
const app = (0, import_fixture_proxies.ErrorCatcherProxy)(child.resolve(appType));
|
|
83
|
-
app.world = child.resolve(worldType);
|
|
84
|
-
app.id = (0, import_uuid.v4)();
|
|
85
|
-
return app;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// src/decorators/fixture.ts
|
|
89
|
-
var import_reflect_metadata = require("reflect-metadata");
|
|
90
|
-
var import_tsyringe2 = require("tsyringe");
|
|
91
|
-
function Fixture(arg) {
|
|
92
|
-
if (arg !== void 0 && typeof arg !== "number") {
|
|
93
|
-
(0, import_tsyringe2.injectable)()(arg);
|
|
94
|
-
(0, import_tsyringe2.scoped)(import_tsyringe2.Lifecycle.ContainerScoped)(arg);
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
return (target) => {
|
|
98
|
-
(0, import_tsyringe2.injectable)()(target);
|
|
99
|
-
if (arg === LIFE_CYCLE.Singleton) {
|
|
100
|
-
(0, import_tsyringe2.singleton)()(target);
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
(0, import_tsyringe2.scoped)(arg ?? LIFE_CYCLE.ContainerScoped)(target);
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
var Inject = import_tsyringe2.inject;
|
|
107
|
-
var LIFE_CYCLE = {
|
|
108
|
-
Transient: import_tsyringe2.Lifecycle.Transient,
|
|
109
|
-
Singleton: import_tsyringe2.Lifecycle.Singleton,
|
|
110
|
-
ResolutionScoped: import_tsyringe2.Lifecycle.ResolutionScoped,
|
|
111
|
-
ContainerScoped: import_tsyringe2.Lifecycle.ContainerScoped
|
|
112
|
-
};
|
|
113
46
|
|
|
114
47
|
// src/decorators/app-type.ts
|
|
115
|
-
var
|
|
116
|
-
function AppType(
|
|
48
|
+
var import_injection2 = require("@autometa/injection");
|
|
49
|
+
function AppType(container, world, environment = "default") {
|
|
117
50
|
const env = environment ?? "default";
|
|
118
51
|
return (target) => {
|
|
119
|
-
|
|
120
|
-
|
|
52
|
+
(0, import_injection2.metadata)(target.prototype).set({
|
|
53
|
+
key: "world",
|
|
54
|
+
class: world
|
|
55
|
+
});
|
|
56
|
+
container[env] = { app: target, world };
|
|
121
57
|
};
|
|
122
58
|
}
|
|
123
59
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -125,9 +61,6 @@ function AppType(container2, world, environment = "default") {
|
|
|
125
61
|
AppType,
|
|
126
62
|
AutometaApp,
|
|
127
63
|
AutometaWorld,
|
|
128
|
-
Fixture,
|
|
129
|
-
Inject,
|
|
130
|
-
LIFE_CYCLE,
|
|
131
64
|
getApp
|
|
132
65
|
});
|
|
133
66
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/autometa-app.ts","../src/autometa-world.ts","../src/get-app.ts","../src/decorators/
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/autometa-app.ts","../src/autometa-world.ts","../src/get-app.ts","../src/decorators/app-type.ts"],"sourcesContent":["export * from \"./autometa-app\";\nexport * from \"./autometa-world\";\nexport * from \"./get-app\";\nexport * from \"./decorators\";\nexport * from \"./fixtures.typings\";\n","import { World } from \"./fixtures.typings\";\nexport abstract class AutometaApp {\n id: string;\n [key: string]: unknown;\n world: World;\n}\n","export class AutometaWorld {}\n","import { AutometaApp } from \"./autometa-app\";\nimport { Class } from \"@autometa/types\";\nimport { v4 } from \"uuid\";\nimport { Container, defineContainerContext } from \"@autometa/injection\";\nimport { App } from \"./fixtures.typings\";\nexport function getApp<T extends AutometaApp>(\n appType: Class<T>,\n containerName = v4()\n): App {\n const context = defineContainerContext(containerName);\n const container = new Container(context);\n return container.get(appType);\n}\n","import { Class } from \"@autometa/types\";\nimport { App, World, AutometaWorld } from \"..\";\nimport { metadata } from \"@autometa/injection\";\nexport function AppType(\n container: Record<string, { app: Class<App>; world: Class<World> }>,\n world: Class<AutometaWorld>,\n environment = \"default\"\n) {\n const env = environment ?? \"default\";\n return (target: Class<unknown>) => {\n metadata(target.prototype).set({\n key: \"world\",\n class: world\n });\n container[env] = { app: target as Class<App>, world: world as Class<World> };\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCO,IAAe,cAAf,MAA2B;AAIlC;;;ACLO,IAAM,gBAAN,MAAoB;AAAC;;;ACE5B,kBAAmB;AACnB,uBAAkD;AAE3C,SAAS,OACd,SACA,oBAAgB,gBAAG,GACd;AACL,QAAM,cAAU,yCAAuB,aAAa;AACpD,QAAM,YAAY,IAAI,2BAAU,OAAO;AACvC,SAAO,UAAU,IAAI,OAAO;AAC9B;;;ACVA,IAAAA,oBAAyB;AAClB,SAAS,QACd,WACA,OACA,cAAc,WACd;AACA,QAAM,MAAM,eAAe;AAC3B,SAAO,CAAC,WAA2B;AACjC,oCAAS,OAAO,SAAS,EAAE,IAAI;AAAA,MAC7B,KAAK;AAAA,MACL,OAAO;AAAA,IACT,CAAC;AACD,cAAU,GAAG,IAAI,EAAE,KAAK,QAAsB,MAA6B;AAAA,EAC7E;AACF;","names":["import_injection"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autometa/app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "App and World container for Autometa",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"@autometa/asserters": "0.1.8",
|
|
52
52
|
"@autometa/errors": "0.2.2",
|
|
53
53
|
"@autometa/fixture-proxies": "^0.1.3",
|
|
54
|
+
"@autometa/injection": "^0.1.0",
|
|
54
55
|
"@autometa/phrases": "0.1.12",
|
|
55
56
|
"tsyringe": "^4.8.0",
|
|
56
57
|
"uuid": "^9.0.1"
|