@autometa/app 0.3.0 → 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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @autometa/app
2
2
 
3
+ ## 0.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 6c4bb8d: fix: getApp function not defined
8
+
3
9
  ## 0.3.0
4
10
 
5
11
  ### Minor Changes
package/dist/esm/index.js CHANGED
@@ -7,48 +7,24 @@ var AutometaWorld = class {
7
7
  };
8
8
 
9
9
  // src/get-app.ts
10
- import { container } from "tsyringe";
11
- import { AutomationError } from "@autometa/errors";
12
10
  import { v4 } from "uuid";
13
- import { ErrorCatcherProxy } from "@autometa/fixture-proxies";
14
- function getApp(appType, worldType, ...instances) {
15
- if (!appType) {
16
- throw new AutomationError(`A reference to an 'app' and 'world' is required to run tests.
17
-
18
- Configure the app by extending 'AutometaApp' and adding it to your
19
- 'autometa.config.ts' file:
20
-
21
- @AppType(MyWorld)
22
- export class MyAutometaApp extends AutometaApp {
23
- ...
24
- }
25
- defineConfig({
26
- roots: {
27
- app: './src/app'
28
- }
29
- })`);
30
- }
31
- instances.forEach(({ token, instance, cls }) => {
32
- const proxiedCls = cls ? ErrorCatcherProxy(cls) : void 0;
33
- const proxiedInst = instance ? ErrorCatcherProxy(instance) : void 0;
34
- return child.register(token, proxiedInst ?? proxiedCls);
35
- });
36
- const child = container.createChildContainer();
37
- const app = ErrorCatcherProxy(child.resolve(appType));
38
- app.id = v4();
39
- 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);
40
16
  }
41
17
 
42
18
  // src/decorators/app-type.ts
43
19
  import { metadata } from "@autometa/injection";
44
- function AppType(container2, world, environment = "default") {
20
+ function AppType(container, world, environment = "default") {
45
21
  const env = environment ?? "default";
46
22
  return (target) => {
47
23
  metadata(target.prototype).set({
48
24
  key: "world",
49
25
  class: world
50
26
  });
51
- container2[env] = { app: target, world };
27
+ container[env] = { app: target, world };
52
28
  };
53
29
  }
54
30
  export {
@@ -1 +1 @@
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 { container } from \"tsyringe\";\nimport { AutometaApp } from \"./autometa-app\";\nimport { Class } from \"@autometa/types\";\nimport { AutomationError } from \"@autometa/errors\";\nimport { AutometaWorld } from \".\";\nimport { v4 } from \"uuid\";\nimport { ErrorCatcherProxy } from \"@autometa/fixture-proxies\";\nexport function getApp<T extends AutometaApp, K extends AutometaWorld>(\n appType: Class<T>,\n worldType: Class<K>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ...instances: { token: any; instance?: any; cls?: Class<any> }[]\n) {\n if (!appType) {\n throw new AutomationError(`A reference to an 'app' and 'world' is required to run tests.\n\nConfigure the app by extending 'AutometaApp' and adding it to your\n'autometa.config.ts' file:\n\n@AppType(MyWorld)\nexport class MyAutometaApp extends AutometaApp {\n ...\n}\ndefineConfig({\n roots: {\n app: './src/app'\n }\n})`);\n }\n instances.forEach(({ token, instance, cls }) => {\n const proxiedCls = cls ? ErrorCatcherProxy(cls) : undefined;\n const proxiedInst = instance ? ErrorCatcherProxy(instance) : undefined;\n return child.register(token, proxiedInst ?? proxiedCls);\n });\n\n const child = container.createChildContainer();\n const app = ErrorCatcherProxy(child.resolve(appType));\n // app.world = child.resolve(worldType);\n app.id = v4();\n return app;\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;;;ACA5B,SAAS,iBAAiB;AAG1B,SAAS,uBAAuB;AAEhC,SAAS,UAAU;AACnB,SAAS,yBAAyB;AAC3B,SAAS,OACd,SACA,cAEG,WACH;AACA,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAa3B;AAAA,EACD;AACA,YAAU,QAAQ,CAAC,EAAE,OAAO,UAAU,IAAI,MAAM;AAC9C,UAAM,aAAa,MAAM,kBAAkB,GAAG,IAAI;AAClD,UAAM,cAAc,WAAW,kBAAkB,QAAQ,IAAI;AAC7D,WAAO,MAAM,SAAS,OAAO,eAAe,UAAU;AAAA,EACxD,CAAC;AAED,QAAM,QAAQ,UAAU,qBAAqB;AAC7C,QAAM,MAAM,kBAAkB,MAAM,QAAQ,OAAO,CAAC;AAEpD,MAAI,KAAK,GAAG;AACZ,SAAO;AACT;;;ACtCA,SAAS,gBAAgB;AAClB,SAAS,QACdA,YACA,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,IAAAA,WAAU,GAAG,IAAI,EAAE,KAAK,QAAsB,MAA6B;AAAA,EAC7E;AACF;","names":["container"]}
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
@@ -100,11 +100,7 @@ declare abstract class AutometaApp {
100
100
  declare class AutometaWorld {
101
101
  }
102
102
 
103
- declare function getApp<T extends AutometaApp, K extends AutometaWorld>(appType: Class<T>, worldType: Class<K>, ...instances: {
104
- token: any;
105
- instance?: any;
106
- cls?: Class<any>;
107
- }[]): T;
103
+ declare function getApp<T extends AutometaApp>(appType: Class<T>, containerName?: string): App;
108
104
 
109
105
  declare function AppType(container: Record<string, {
110
106
  app: Class<App>;
package/dist/index.d.ts CHANGED
@@ -100,11 +100,7 @@ declare abstract class AutometaApp {
100
100
  declare class AutometaWorld {
101
101
  }
102
102
 
103
- declare function getApp<T extends AutometaApp, K extends AutometaWorld>(appType: Class<T>, worldType: Class<K>, ...instances: {
104
- token: any;
105
- instance?: any;
106
- cls?: Class<any>;
107
- }[]): T;
103
+ declare function getApp<T extends AutometaApp>(appType: Class<T>, containerName?: string): App;
108
104
 
109
105
  declare function AppType(container: Record<string, {
110
106
  app: Class<App>;
package/dist/index.js CHANGED
@@ -36,48 +36,24 @@ var AutometaWorld = class {
36
36
  };
37
37
 
38
38
  // src/get-app.ts
39
- var import_tsyringe = require("tsyringe");
40
- var import_errors = require("@autometa/errors");
41
39
  var import_uuid = require("uuid");
42
- var import_fixture_proxies = require("@autometa/fixture-proxies");
43
- function getApp(appType, worldType, ...instances) {
44
- if (!appType) {
45
- throw new import_errors.AutomationError(`A reference to an 'app' and 'world' is required to run tests.
46
-
47
- Configure the app by extending 'AutometaApp' and adding it to your
48
- 'autometa.config.ts' file:
49
-
50
- @AppType(MyWorld)
51
- export class MyAutometaApp extends AutometaApp {
52
- ...
53
- }
54
- defineConfig({
55
- roots: {
56
- app: './src/app'
57
- }
58
- })`);
59
- }
60
- instances.forEach(({ token, instance, cls }) => {
61
- const proxiedCls = cls ? (0, import_fixture_proxies.ErrorCatcherProxy)(cls) : void 0;
62
- const proxiedInst = instance ? (0, import_fixture_proxies.ErrorCatcherProxy)(instance) : void 0;
63
- return child.register(token, proxiedInst ?? proxiedCls);
64
- });
65
- const child = import_tsyringe.container.createChildContainer();
66
- const app = (0, import_fixture_proxies.ErrorCatcherProxy)(child.resolve(appType));
67
- app.id = (0, import_uuid.v4)();
68
- return app;
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
46
 
71
47
  // src/decorators/app-type.ts
72
- var import_injection = require("@autometa/injection");
73
- function AppType(container2, world, environment = "default") {
48
+ var import_injection2 = require("@autometa/injection");
49
+ function AppType(container, world, environment = "default") {
74
50
  const env = environment ?? "default";
75
51
  return (target) => {
76
- (0, import_injection.metadata)(target.prototype).set({
52
+ (0, import_injection2.metadata)(target.prototype).set({
77
53
  key: "world",
78
54
  class: world
79
55
  });
80
- container2[env] = { app: target, world };
56
+ container[env] = { app: target, world };
81
57
  };
82
58
  }
83
59
  // Annotate the CommonJS export names for ESM import in node:
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/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 { container } from \"tsyringe\";\nimport { AutometaApp } from \"./autometa-app\";\nimport { Class } from \"@autometa/types\";\nimport { AutomationError } from \"@autometa/errors\";\nimport { AutometaWorld } from \".\";\nimport { v4 } from \"uuid\";\nimport { ErrorCatcherProxy } from \"@autometa/fixture-proxies\";\nexport function getApp<T extends AutometaApp, K extends AutometaWorld>(\n appType: Class<T>,\n worldType: Class<K>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ...instances: { token: any; instance?: any; cls?: Class<any> }[]\n) {\n if (!appType) {\n throw new AutomationError(`A reference to an 'app' and 'world' is required to run tests.\n\nConfigure the app by extending 'AutometaApp' and adding it to your\n'autometa.config.ts' file:\n\n@AppType(MyWorld)\nexport class MyAutometaApp extends AutometaApp {\n ...\n}\ndefineConfig({\n roots: {\n app: './src/app'\n }\n})`);\n }\n instances.forEach(({ token, instance, cls }) => {\n const proxiedCls = cls ? ErrorCatcherProxy(cls) : undefined;\n const proxiedInst = instance ? ErrorCatcherProxy(instance) : undefined;\n return child.register(token, proxiedInst ?? proxiedCls);\n });\n\n const child = container.createChildContainer();\n const app = ErrorCatcherProxy(child.resolve(appType));\n // app.world = child.resolve(worldType);\n app.id = v4();\n return app;\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;;;ACA5B,sBAA0B;AAG1B,oBAAgC;AAEhC,kBAAmB;AACnB,6BAAkC;AAC3B,SAAS,OACd,SACA,cAEG,WACH;AACA,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,8BAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAa3B;AAAA,EACD;AACA,YAAU,QAAQ,CAAC,EAAE,OAAO,UAAU,IAAI,MAAM;AAC9C,UAAM,aAAa,UAAM,0CAAkB,GAAG,IAAI;AAClD,UAAM,cAAc,eAAW,0CAAkB,QAAQ,IAAI;AAC7D,WAAO,MAAM,SAAS,OAAO,eAAe,UAAU;AAAA,EACxD,CAAC;AAED,QAAM,QAAQ,0BAAU,qBAAqB;AAC7C,QAAM,UAAM,0CAAkB,MAAM,QAAQ,OAAO,CAAC;AAEpD,MAAI,SAAK,gBAAG;AACZ,SAAO;AACT;;;ACtCA,uBAAyB;AAClB,SAAS,QACdA,YACA,OACA,cAAc,WACd;AACA,QAAM,MAAM,eAAe;AAC3B,SAAO,CAAC,WAA2B;AACjC,mCAAS,OAAO,SAAS,EAAE,IAAI;AAAA,MAC7B,KAAK;AAAA,MACL,OAAO;AAAA,IACT,CAAC;AACD,IAAAA,WAAU,GAAG,IAAI,EAAE,KAAK,QAAsB,MAA6B;AAAA,EAC7E;AACF;","names":["container"]}
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.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",