@treenity/core 1.0.22 → 1.0.24

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/context.d.ts +14 -67
  3. package/dist/context.mjs +17 -45
  4. package/dist/context.mjs.map +1 -1
  5. package/dist/contexts/node-engine.d.ts +11 -0
  6. package/dist/contexts/node-engine.mjs +7 -0
  7. package/dist/contexts/node-engine.mjs.map +1 -0
  8. package/dist/contexts/object.d.ts +10 -0
  9. package/dist/contexts/object.mjs +15 -0
  10. package/dist/contexts/object.mjs.map +1 -0
  11. package/dist/contexts/proto.d.ts +10 -0
  12. package/dist/contexts/proto.mjs +7 -0
  13. package/dist/contexts/proto.mjs.map +1 -0
  14. package/dist/contexts/react-context.d.ts +18 -0
  15. package/dist/contexts/react-context.mjs +24 -0
  16. package/dist/contexts/react-context.mjs.map +1 -0
  17. package/dist/contexts/service.d.ts +14 -0
  18. package/dist/contexts/service.mjs +7 -0
  19. package/dist/contexts/service.mjs.map +1 -0
  20. package/dist/get-type-cache.d.ts +1 -0
  21. package/dist/get-type-cache.mjs +7 -0
  22. package/dist/get-type-cache.mjs.map +1 -0
  23. package/dist/index.d.ts +10 -1
  24. package/dist/index.mjs +9 -2
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/link/link.d.ts +24 -0
  27. package/dist/link/link.mjs +72 -0
  28. package/dist/link/link.mjs.map +1 -0
  29. package/dist/link/link.test.d.ts +1 -0
  30. package/dist/meta-type.d.ts +36 -0
  31. package/dist/meta-type.mjs +78 -0
  32. package/dist/meta-type.mjs.map +1 -0
  33. package/dist/meta.d.ts +15 -33
  34. package/dist/meta.mjs +15 -5
  35. package/dist/meta.mjs.map +1 -1
  36. package/dist/node/index.d.ts +1 -0
  37. package/dist/node/types.d.ts +31 -0
  38. package/dist/test/context.test.d.ts +1 -0
  39. package/dist/test/proxy-chain.test.d.ts +1 -0
  40. package/dist/types.d.ts +13 -0
  41. package/dist/types.mjs +16 -0
  42. package/dist/types.mjs.map +1 -0
  43. package/package.json +8 -9
  44. package/dist/contexts/json-schema/types.d.ts +0 -3
  45. package/dist/stats.html +0 -4842
  46. package/jest.config.mjs +0 -1
  47. package/jest.config.ts +0 -29
  48. package/rollup.config.mjs +0 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @treenity/core
2
2
 
3
+ ## 1.0.24
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix create entity and add entity meta add, fixed patches feathers transport common
8
+ - Updated dependencies
9
+ - @treenity/js-shared@1.0.22
10
+
11
+ ## 1.0.23
12
+
13
+ ### Patch Changes
14
+
15
+ - Add entity and other changes
16
+ - Updated dependencies
17
+ - @treenity/js-shared@1.0.21
18
+
3
19
  ## 1.0.22
4
20
 
5
21
  ### Patch Changes
package/dist/context.d.ts CHANGED
@@ -1,8 +1,4 @@
1
- import { Obj } from '@treenity/js-shared';
2
- import * as React from 'react';
3
- import { JsonObjectSchema } from './contexts/json-schema/types';
4
- import { PortsDescription } from './contexts/noflo/types';
5
- import { Meta, Node } from './meta';
1
+ import { MetaType } from './meta-type';
6
2
  export interface TypeContextInfo<C, O> {
7
3
  id: string;
8
4
  context: string;
@@ -10,74 +6,25 @@ export interface TypeContextInfo<C, O> {
10
6
  component: C;
11
7
  options: O;
12
8
  }
9
+ type MetaName<T> = string | MetaType<T>;
13
10
  export interface Context<C, O> {
14
11
  name: string;
15
- add(typeName: string, component: C, options: O): TypeContextInfo<C, O>;
16
- add(subContext: string, typeName: string, component: C, options: O): TypeContextInfo<C, O>;
17
- get(typeName: string): Promise<[C, O]>;
18
- get(subContext: string, typeName: string): Promise<[C, O]>;
19
- getInfo(typeName: string): Promise<TypeContextInfo<C, O>>;
20
- getInfo(subContext: string, typeName: string): Promise<TypeContextInfo<C, O>>;
21
- search(query: string): TypeContextInfo<C, O>[];
22
- search(subContext: string, query: string): TypeContextInfo<C, O>[];
12
+ add<T, C1 extends C>(typeName: MetaName<T>, component: C1, options?: O): TypeContextInfo<C, O>;
13
+ add<T, C1 extends C>(subContext: string, typeName: MetaName<T>, component: C1, options?: O): TypeContextInfo<C, O>;
14
+ get<T>(typeName: MetaName<T>): Promise<[C, O]>;
15
+ get<T>(subContext: string, typeName: MetaName<T>): Promise<[C, O]>;
16
+ getInfo<T>(typeName: MetaName<T>): Promise<TypeContextInfo<C, O>>;
17
+ getInfo<T>(subContext: string, typeName: MetaName<T>): Promise<TypeContextInfo<C, O>>;
18
+ search(query: string): Promise<TypeContextInfo<C, O>[]>;
19
+ search(subContext: string, query: string): Promise<TypeContextInfo<C, O>[]>;
23
20
  }
24
21
  export declare class ContextImpl<C, O> implements Context<C, O> {
25
22
  name: string;
26
23
  items: Map<string, TypeContextInfo<C, O>>;
27
24
  constructor(name: string);
28
25
  add(...args: any[]): TypeContextInfo<C, O>;
29
- getInfo(subContext: string, typeName?: string): Promise<TypeContextInfo<C, O>>;
30
- get(subContext: string, typeName?: string): Promise<[C, O]>;
31
- search(subContext: string, query?: string): TypeContextInfo<C, O>[];
32
- }
33
- export interface ReactContextOptions {
34
- props?: Obj<any>;
35
- }
36
- export type IReactContextProps<T extends Meta = Meta, P = unknown> = {
37
- value: T;
38
- node: Node;
39
- onChange(setter: (m: T) => T | void): void;
40
- onChangeNode(setter: (node: Node) => Node | void): void;
41
- } & P;
42
- export type ReactTypeContextInfo = TypeContextInfo<React.FC<IReactContextProps>, ReactContextOptions>;
43
- export interface ReactTypeContext extends Context<React.FC<IReactContextProps>, ReactContextOptions> {
44
- }
45
- export interface Service {
46
- run(params: {
47
- meta: Meta;
48
- node: Node;
49
- }): Promise<void>;
50
- }
51
- export interface ServiceContextOptions {
52
- }
53
- export interface ServiceTypeContext extends Context<Service, ServiceContextOptions> {
54
- }
55
- export type ScriptNode = (...params: any[]) => any;
56
- export interface NodeEngineContextOptions {
57
- ports: PortsDescription;
58
- }
59
- export type NodeEngineTypeContextInfo = TypeContextInfo<ScriptNode, NodeEngineContextOptions>;
60
- export interface NodeEngineTypeContext extends Context<ScriptNode, NodeEngineContextOptions> {
61
- }
62
- export interface MetaContextOptions {
63
- }
64
- export interface MetaTypeContext extends Context<JsonObjectSchema, MetaContextOptions> {
65
- }
66
- export interface ProtoTypeContextOptions {
67
- }
68
- export interface Protocol {
69
- fetch(url: string): Promise<any>;
70
- }
71
- export interface ProtoTypeContext extends Context<Protocol, ProtoTypeContextOptions> {
72
- }
73
- export interface ContextTypes {
74
- react: ReactTypeContext;
75
- jsSrv: ServiceTypeContext;
76
- meta: MetaTypeContext;
77
- proto: ProtoTypeContext;
78
- noflo: NodeEngineTypeContext;
79
- }
80
- export declare const types: ContextTypes;
81
- export interface Process {
82
- createChild(): void;
26
+ getInfo<T>(subContext: string, typeName?: MetaName<T>): Promise<TypeContextInfo<C, O>>;
27
+ get<T>(subContext: string, typeName?: MetaName<T>): Promise<[C, O]>;
28
+ search(subContext: string, query?: string): Promise<TypeContextInfo<C, O>[]>;
83
29
  }
30
+ export {};
package/dist/context.mjs CHANGED
@@ -1,21 +1,22 @@
1
- import { capitalize } from '@treenity/js-shared/utils';
2
1
  import { SynchronousPromise } from 'synchronous-promise';
2
+ import { getTypeCache } from './get-type-cache.mjs';
3
+ import { metaType } from './meta-type.mjs';
3
4
 
4
5
  class ContextImpl {
5
6
  name;
6
7
  items = new Map();
7
8
  constructor(name) {
8
9
  this.name = name;
9
- // @ts-ignore
10
- types[name] = this;
10
+ getTypeCache()[name] = this;
11
11
  }
12
12
  // add(...args: Pro<Context<C, O>['add']>): TypeContextInfo<C, O>;
13
13
  // add(...args: ArgumentTypes<Context<C, O>['add']>): TypeContextInfo<C, O> {
14
14
  add(...args) {
15
15
  if (args.length <= 3)
16
- args.unshift('');
17
- const [subContext, typeName, component, options] = args;
18
- const contextType = subContext ? subContext + ':' + typeName : typeName;
16
+ args.unshift(undefined);
17
+ let [subContext, typeName, component, options = {}] = args;
18
+ typeName = metaType(typeName, subContext);
19
+ const contextType = typeName.$id;
19
20
  const t = {
20
21
  id: contextType,
21
22
  context: this.name,
@@ -31,12 +32,13 @@ class ContextImpl {
31
32
  getInfo(subContext, typeName) {
32
33
  if (!typeName) {
33
34
  typeName = subContext;
34
- subContext = '';
35
+ subContext = undefined;
35
36
  }
36
- const contextType = subContext ? subContext + ':' + typeName : typeName;
37
+ typeName = metaType(typeName, subContext);
38
+ const contextType = typeName.$id;
37
39
  const item = this.items.get(contextType);
38
40
  if (!item) {
39
- return SynchronousPromise.reject(new Error('not found: ' + contextType));
41
+ return SynchronousPromise.reject(new Error('not found: ' + contextType + ' in ' + this.name + ' context'));
40
42
  }
41
43
  return SynchronousPromise.resolve(item);
42
44
  }
@@ -46,52 +48,22 @@ class ContextImpl {
46
48
  options,
47
49
  ]);
48
50
  }
49
- search(subContext, query) {
51
+ async search(subContext, query) {
50
52
  const result = [];
51
53
  if (!query) {
52
54
  query = subContext;
53
55
  subContext = '';
54
56
  }
55
- for (let t of this.items.values()) {
56
- const matchesContext = t.subContext === subContext;
57
- const matchesQuery = t.id.includes(query);
58
- if (matchesContext && matchesQuery) {
57
+ for (let t of Array.from(this.items.values())) {
58
+ const subEqual = (!t.subContext && !subContext) || t.subContext === subContext;
59
+ if (subEqual && t.id.includes(query)) {
59
60
  result.push(t);
60
61
  }
61
62
  }
62
63
  return result;
63
64
  }
64
65
  }
65
- class ReactTypeContextImpl extends ContextImpl {
66
- add(...args) {
67
- if (args.length === 4) {
68
- const [, typeName, component] = args;
69
- if (!component.displayName && !component.name)
70
- component.displayName = capitalize(typeName);
71
- }
72
- else {
73
- const [typeName, component] = args;
74
- if (!component.displayName && !component.name)
75
- component.displayName = capitalize(typeName);
76
- }
77
- return super.add(...args);
78
- }
79
- }
80
- class ServiceTypeContextImpl extends ContextImpl {
81
- }
82
- class NodeEngineTypeContextImpl extends ContextImpl {
83
- }
84
- class MetaTypeContextImpl extends ContextImpl {
85
- }
86
- class ProtoTypeContextImpl extends ContextImpl {
87
- }
88
- // @ts-ignore
89
- const types = {};
90
- new ReactTypeContextImpl('react');
91
- new MetaTypeContextImpl('meta');
92
- new ProtoTypeContextImpl('proto');
93
- new ServiceTypeContextImpl('jsSrv');
94
- new NodeEngineTypeContextImpl('noflo');
66
+ // Node engine script context type
95
67
 
96
- export { ContextImpl, types };
68
+ export { ContextImpl };
97
69
  //# sourceMappingURL=context.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.mjs","sources":["../src/context.ts"],"sourcesContent":[null],"names":[],"mappings":";;;MAgCa,WAAW,CAAA;AAGH,IAAA,IAAA,CAAA;AAFnB,IAAA,KAAK,GAAuC,IAAI,GAAG,EAAE,CAAC;AAEtD,IAAA,WAAA,CAAmB,IAAY,EAAA;QAAZ,IAAI,CAAA,IAAA,GAAJ,IAAI,CAAQ;;AAE7B,QAAA,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;KACpB;;;IAID,GAAG,CAAC,GAAG,IAAW,EAAA;AAChB,QAAA,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC;AAAE,YAAA,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACvC,MAAM,CAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,GAAG,IAAwC,CAAC;AAC5F,QAAA,MAAM,WAAW,GAAG,UAAU,GAAG,UAAU,GAAG,GAAG,GAAG,QAAQ,GAAG,QAAQ,CAAC;AACxE,QAAA,MAAM,CAAC,GAA0B;AAC/B,YAAA,EAAE,EAAE,WAAW;YACf,OAAO,EAAE,IAAI,CAAC,IAAI;YAClB,UAAU;YACV,SAAS;YACT,OAAO;SACR,CAAC;QAEF,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;AAC/B,QAAA,OAAO,CAAC,CAAC;KACV;;;IAID,OAAO,CAAC,UAAkB,EAAE,QAAiB,EAAA;QAC3C,IAAI,CAAC,QAAQ,EAAE;YACb,QAAQ,GAAG,UAAU,CAAC;YAC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C,IAAI,GAAG,UAAU,CAAC,CACzE,CAAC;SACH;AACD,QAAA,OAAO,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;KACzC;IAED,GAAG,CAAI,UAAkB,EAAE,QAAsB,EAAA;AAC/C,QAAA,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK;YACzE,SAAS;YACT,OAAO;AACR,SAAA,CAAC,CAAC;KACJ;AAED,IAAA,MAAM,MAAM,CAAC,UAAkB,EAAE,KAAc,EAAA;QAC7C,MAAM,MAAM,GAA4B,EAAE,CAAC;QAE3C,IAAI,CAAC,KAAK,EAAE;YACV,KAAK,GAAG,UAAU,CAAC;YACnB,UAAU,GAAG,EAAE,CAAC;SACjB;AAED,QAAA,KAAK,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE;AAC7C,YAAA,MAAM,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,UAAU,KAAK,CAAC,CAAC,UAAU,KAAK,UAAU,CAAC;YAC/E,IAAI,QAAQ,IAAI,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;AACpC,gBAAA,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aAChB;SACF;AACD,QAAA,OAAO,MAAM,CAAC;KACf;AACF,CAAA;AAED;;;;"}
@@ -0,0 +1,11 @@
1
+ import { Context, ContextImpl, TypeContextInfo } from '../context';
2
+ import { PortsDescription } from './noflo/types';
3
+ export type ScriptNode = (...params: any[]) => any;
4
+ export interface NodeEngineContextOptions {
5
+ ports: PortsDescription;
6
+ }
7
+ export type NodeEngineTypeContextInfo = TypeContextInfo<ScriptNode, NodeEngineContextOptions>;
8
+ export interface NodeEngineTypeContext extends Context<ScriptNode, NodeEngineContextOptions> {
9
+ }
10
+ export declare class NodeEngineTypeContextImpl extends ContextImpl<ScriptNode, NodeEngineContextOptions> implements NodeEngineTypeContext {
11
+ }
@@ -0,0 +1,7 @@
1
+ import { ContextImpl } from '../context.mjs';
2
+
3
+ class NodeEngineTypeContextImpl extends ContextImpl {
4
+ }
5
+
6
+ export { NodeEngineTypeContextImpl };
7
+ //# sourceMappingURL=node-engine.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-engine.mjs","sources":["../../src/contexts/node-engine.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAaM,MAAO,yBACX,SAAQ,WAAiD,CAAA;AACtB;;;;"}
@@ -0,0 +1,10 @@
1
+ import { Context, ContextImpl, TypeContextInfo } from '../context';
2
+ import { MetaName } from '../meta-type';
3
+ export type ObjectDeserializer<T> = (json: any, ...args: any[]) => T;
4
+ export interface ObjectContextOptions {
5
+ }
6
+ export interface ObjectTypeContext extends Context<ObjectDeserializer<any>, ObjectContextOptions> {
7
+ }
8
+ export declare class ObjectTypeContextImpl extends ContextImpl<ObjectDeserializer<any>, ObjectContextOptions> implements ObjectTypeContext {
9
+ getInfo<T>(subContext: string, typeName?: MetaName<T>): Promise<TypeContextInfo<ObjectDeserializer<any>, ObjectContextOptions>>;
10
+ }
@@ -0,0 +1,15 @@
1
+ import { ContextImpl } from '../context.mjs';
2
+
3
+ class ObjectTypeContextImpl extends ContextImpl {
4
+ getInfo(subContext, typeName) {
5
+ return super.getInfo(subContext, typeName).catch(error => {
6
+ if (!subContext || !typeName)
7
+ throw error;
8
+ // try empty context if specified not found
9
+ return super.getInfo('', typeName);
10
+ });
11
+ }
12
+ }
13
+
14
+ export { ObjectTypeContextImpl };
15
+ //# sourceMappingURL=object.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object.mjs","sources":["../../src/contexts/object.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAcM,MAAO,qBACX,SAAQ,WAA0D,CAAA;IAGlE,OAAO,CACL,UAAkB,EAClB,QAAsB,EAAA;AAEtB,QAAA,OAAO,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,KAAK,IAAG;AACvD,YAAA,IAAI,CAAC,UAAU,IAAI,CAAC,QAAQ;AAAE,gBAAA,MAAM,KAAK,CAAC;;YAE1C,OAAO,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;AACrC,SAAC,CAAC,CAAC;KACJ;AACF;;;;"}
@@ -0,0 +1,10 @@
1
+ import { Context, ContextImpl } from '../context';
2
+ export interface ProtoTypeContextOptions {
3
+ }
4
+ export interface Protocol {
5
+ fetch(url: string): Promise<any>;
6
+ }
7
+ export interface ProtoTypeContext extends Context<Protocol, ProtoTypeContextOptions> {
8
+ }
9
+ export declare class ProtoTypeContextImpl extends ContextImpl<Protocol, ProtoTypeContextOptions> implements ProtoTypeContext {
10
+ }
@@ -0,0 +1,7 @@
1
+ import { ContextImpl } from '../context.mjs';
2
+
3
+ class ProtoTypeContextImpl extends ContextImpl {
4
+ }
5
+
6
+ export { ProtoTypeContextImpl };
7
+ //# sourceMappingURL=proto.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proto.mjs","sources":["../../src/contexts/proto.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAUM,MAAO,oBACX,SAAQ,WAA8C,CAAA;AACxB;;;;"}
@@ -0,0 +1,18 @@
1
+ import { Obj } from '@treenity/js-shared/utils';
2
+ import * as React from 'react';
3
+ import { Context, ContextImpl, TypeContextInfo } from '../context';
4
+ import { Node } from '../node';
5
+ export interface ReactContextOptions {
6
+ props?: Obj<any>;
7
+ }
8
+ export type IReactContextProps<T = any, P = unknown> = {
9
+ value: T;
10
+ node: Node;
11
+ onChange(setter: (m: T) => T | void): void;
12
+ } & P;
13
+ export type ReactTypeContextInfo = TypeContextInfo<React.FC<IReactContextProps>, ReactContextOptions>;
14
+ export interface ReactTypeContext extends Context<React.FC<IReactContextProps>, ReactContextOptions> {
15
+ }
16
+ export declare class ReactTypeContextImpl extends ContextImpl<React.FC<IReactContextProps>, ReactContextOptions> implements ReactTypeContext {
17
+ add(...args: any[]): ReactTypeContextInfo;
18
+ }
@@ -0,0 +1,24 @@
1
+ import { capitalize } from '@treenity/js-shared/utils';
2
+ import { ContextImpl } from '../context.mjs';
3
+ import { getTypeName } from '../meta.mjs';
4
+
5
+ class ReactTypeContextImpl extends ContextImpl {
6
+ add(...args) {
7
+ if (args.length === 4) {
8
+ const [, typeName, component] = args;
9
+ if (!component.displayName && !component.name) {
10
+ component.displayName = capitalize(getTypeName(typeName));
11
+ }
12
+ }
13
+ else {
14
+ const [typeName, component] = args;
15
+ if (!component.displayName && !component.name) {
16
+ component.displayName = capitalize(getTypeName(typeName));
17
+ }
18
+ }
19
+ return super.add(...args);
20
+ }
21
+ }
22
+
23
+ export { ReactTypeContextImpl };
24
+ //# sourceMappingURL=react-context.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-context.mjs","sources":["../../src/contexts/react-context.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAyBM,MAAO,oBACX,SAAQ,WAA8D,CAAA;IAGtE,GAAG,CAAC,GAAG,IAAW,EAAA;AAChB,QAAA,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;YACrB,MAAM,GAAG,QAAQ,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC;YACrC,IAAI,CAAC,SAAS,CAAC,WAAW,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;gBAC7C,SAAS,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;aAC3D;SACF;aAAM;AACL,YAAA,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC;YACnC,IAAI,CAAC,SAAS,CAAC,WAAW,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;gBAC7C,SAAS,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;aAC3D;SACF;AACD,QAAA,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;KAC3B;AACF;;;;"}
@@ -0,0 +1,14 @@
1
+ import { Context, ContextImpl } from '../context';
2
+ import { Node } from '../node';
3
+ export interface Service<M = any> {
4
+ setup(params: {
5
+ meta: M;
6
+ node: Node;
7
+ }): Promise<void>;
8
+ }
9
+ export interface ServiceContextOptions {
10
+ }
11
+ export interface ServiceTypeContext extends Context<Service, ServiceContextOptions> {
12
+ }
13
+ export declare class ServiceTypeContextImpl extends ContextImpl<Service, ServiceContextOptions> implements ServiceTypeContext {
14
+ }
@@ -0,0 +1,7 @@
1
+ import { ContextImpl } from '../context.mjs';
2
+
3
+ class ServiceTypeContextImpl extends ContextImpl {
4
+ }
5
+
6
+ export { ServiceTypeContextImpl };
7
+ //# sourceMappingURL=service.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.mjs","sources":["../../src/contexts/service.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAWM,MAAO,sBACX,SAAQ,WAA2C,CAAA;AACnB;;;;"}
@@ -0,0 +1 @@
1
+ export declare function getTypeCache(): Record<string, any>;
@@ -0,0 +1,7 @@
1
+ const typesCache = {};
2
+ function getTypeCache() {
3
+ return typesCache;
4
+ }
5
+
6
+ export { getTypeCache };
7
+ //# sourceMappingURL=get-type-cache.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-type-cache.mjs","sources":["../src/get-type-cache.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAwB,EAAE,CAAC;SAE3B,YAAY,GAAA;AAC1B,IAAA,OAAO,UAAU,CAAC;AACpB;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,12 @@
1
1
  export * from './context';
2
- export * from './contexts/json-schema/types';
2
+ export * from './contexts/noflo/types';
3
+ export { default as Link, ILink } from './link/link';
4
+ export * from './node';
5
+ export { types } from './types';
6
+ export type { ContextTypes } from './types';
3
7
  export * from './meta';
8
+ export * from './contexts/service';
9
+ export * from './contexts/proto';
10
+ export * from './contexts/node-engine';
11
+ export * from './contexts/react-context';
12
+ export * from './meta-type';
package/dist/index.mjs CHANGED
@@ -1,3 +1,10 @@
1
- export { ContextImpl, types } from './context.mjs';
2
- export { metaType } from './meta.mjs';
1
+ export { ContextImpl } from './context.mjs';
2
+ export { default as Link } from './link/link.mjs';
3
+ export { types } from './types.mjs';
4
+ export { MetaSymbolType, getMeta, getMetaRaw, getTypeName, serializeMeta } from './meta.mjs';
5
+ export { ServiceTypeContextImpl } from './contexts/service.mjs';
6
+ export { ProtoTypeContextImpl } from './contexts/proto.mjs';
7
+ export { NodeEngineTypeContextImpl } from './contexts/node-engine.mjs';
8
+ export { ReactTypeContextImpl } from './contexts/react-context.mjs';
9
+ export { AntTypeImpl, AnyType, MetaTypeImpl, makeTypeId, metaType, pathToString } from './meta-type.mjs';
3
10
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
@@ -0,0 +1,24 @@
1
+ /// <reference types="node" />
2
+ export interface ILink extends URL {
3
+ context: string;
4
+ contextAndHost: string;
5
+ field: string;
6
+ node: string;
7
+ meta: string;
8
+ metaPath: string;
9
+ host: string;
10
+ path: string;
11
+ }
12
+ type LinkOverrides = Partial<Pick<ILink, 'protocol' | 'meta' | 'field' | 'host'>>;
13
+ declare class Link extends URL implements ILink {
14
+ readonly path: string;
15
+ readonly node: string;
16
+ readonly meta: string;
17
+ readonly metaPath: string;
18
+ readonly field: string;
19
+ constructor(source: string | Link | URL, override?: LinkOverrides);
20
+ get context(): string;
21
+ get contextAndHost(): string;
22
+ parent(): Link;
23
+ }
24
+ export default Link;
@@ -0,0 +1,72 @@
1
+ import { stripSlashes } from '@treenity/js-shared/utils';
2
+
3
+ const PROTO_REGEXP = /^([a-z-0-9\-_+]+):/;
4
+ class Link extends URL {
5
+ // @ts-ignore - field will be set in constructor
6
+ path; // path without meta and field
7
+ // @ts-ignore - field will be set in constructor
8
+ node; // node name or id
9
+ // @ts-ignore - field will be set in constructor
10
+ meta; // meta name
11
+ // @ts-ignore - field will be set in constructor
12
+ metaPath; // meta name
13
+ // @ts-ignore - field will be set in constructor
14
+ field;
15
+ constructor(source, override) {
16
+ if (source instanceof Link) {
17
+ if (!override) {
18
+ return source;
19
+ }
20
+ source = source.toString();
21
+ }
22
+ else if (source instanceof URL) {
23
+ source = source.href;
24
+ }
25
+ const protocol = override?.protocol ?? 'tree:';
26
+ if (!PROTO_REGEXP.test(source))
27
+ source = `${protocol}/` + stripSlashes(source);
28
+ super(source);
29
+ const [path, rest] = source.split('$');
30
+ let [meta, field] = rest?.split(/[#^]/) ?? [];
31
+ let pathname = this.pathname;
32
+ if (pathname.endsWith('/'))
33
+ this.pathname = pathname = pathname.slice(0, -1);
34
+ this.path = pathname.split('$')[0];
35
+ this.node = this.path.split('/').pop();
36
+ if (override?.meta !== undefined) {
37
+ meta = override.meta;
38
+ this.pathname = this.path;
39
+ }
40
+ if (override?.field !== undefined) {
41
+ this.hash = field = override.field;
42
+ }
43
+ if (override?.host !== undefined) {
44
+ this.host = override.host;
45
+ }
46
+ if (override?.protocol !== undefined) {
47
+ this.protocol = override.protocol;
48
+ }
49
+ this.meta = meta;
50
+ this.metaPath = meta ? `${this.path}$${meta}` : this.path;
51
+ this.field = field;
52
+ Object.freeze(this);
53
+ }
54
+ get context() {
55
+ return this.protocol.replace(':', '');
56
+ }
57
+ get contextAndHost() {
58
+ return `${this.protocol}//${this.host}`;
59
+ }
60
+ parent() {
61
+ if (this.hash) {
62
+ return new Link(this, { field: '' });
63
+ }
64
+ if (this.meta) {
65
+ return new Link(this, { meta: '' });
66
+ }
67
+ return new Link(new URL('.', this));
68
+ }
69
+ }
70
+
71
+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IAAA,IAAI,cAAc,GAAA;QAChB,OAAO,CAAA,EAAG,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,IAAI,CAAA,CAAE,CAAC;KACzC;IAED,MAAM,GAAA;AACJ,QAAA,IAAI,IAAI,CAAC,IAAI,EAAE;YACb,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;SACtC;AACD,QAAA,IAAI,IAAI,CAAC,IAAI,EAAE;YACb,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;SACrC;QAED,OAAO,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;KACrC;AACF;;;;"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,36 @@
1
+ import { Class } from '@treenity/js-shared';
2
+ import Link from './link/link';
3
+ import { Typed } from './meta';
4
+ export declare function makeTypeId(type: string, context?: string): string;
5
+ export declare class MetaTypeImpl<T> implements MetaType<T>, Typed {
6
+ $type: string;
7
+ $context: string;
8
+ $item?: T;
9
+ $loc: string;
10
+ constructor(type: string, context: string);
11
+ get $id(): string;
12
+ get server(): MetaType<T>;
13
+ get client(): MetaType<T>;
14
+ get empty(): MetaType<T>;
15
+ inContext<T1 = T>(this: MetaType<any>, context: string): MetaType<T1>;
16
+ toString(): string;
17
+ isEqual(other: MetaName<any>, context?: string | boolean): boolean;
18
+ }
19
+ type MetaType_<T> = Readonly<InstanceType<typeof MetaTypeImpl<T>>>;
20
+ export type MetaType<T> = MetaType_<T>;
21
+ export type MetaName<T> = MetaType<T> | string;
22
+ export type MetaPath = Link | string;
23
+ export type FromMetaType<T> = T extends MetaType<infer U> ? U : never;
24
+ export declare function pathToString(path: MetaPath): string;
25
+ export declare function metaType<T>(type: MetaName<T>, context?: string): MetaType<T>;
26
+ export declare function metaType<T>(type: MetaName<T extends Class ? InstanceType<T> : T>, cls?: T extends Class ? T : string): MetaType<T extends Class ? InstanceType<T> : T>;
27
+ /**
28
+ * Any type equals to any other type and has no context
29
+ */
30
+ export declare class AntTypeImpl extends MetaTypeImpl<any> {
31
+ constructor();
32
+ isEqual(other: MetaName<any>, context?: string | boolean): boolean;
33
+ inContext<T1 = any>(context: string): MetaType<any>;
34
+ }
35
+ export declare const AnyType: Readonly<MetaTypeImpl<any>>;
36
+ export {};