@treenity/core 1.0.21 → 1.0.23

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 (46) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/context.d.ts +14 -67
  3. package/dist/context.mjs +69 -1
  4. package/dist/context.mjs.map +1 -0
  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 +10 -1
  25. package/dist/index.mjs.map +1 -0
  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 +35 -0
  31. package/dist/meta-type.mjs +71 -0
  32. package/dist/meta-type.mjs.map +1 -0
  33. package/dist/meta.d.ts +16 -33
  34. package/dist/meta.mjs +19 -1
  35. package/dist/meta.mjs.map +1 -0
  36. package/dist/node/index.d.ts +1 -0
  37. package/dist/node/types.d.ts +27 -0
  38. package/dist/stats.html +1 -1
  39. package/dist/test/context.test.d.ts +1 -0
  40. package/dist/test/proxy-chain.test.d.ts +1 -0
  41. package/dist/types.d.ts +13 -0
  42. package/dist/types.mjs +16 -0
  43. package/dist/types.mjs.map +1 -0
  44. package/package.json +9 -10
  45. package/dist/contexts/json-schema/types.d.ts +0 -3
  46. package/jest.config.ts +0 -29
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @treenity/core
2
2
 
3
+ ## 1.0.23
4
+
5
+ ### Patch Changes
6
+
7
+ - Add entity and other changes
8
+ - Updated dependencies
9
+ - @treenity/js-shared@1.0.21
10
+
11
+ ## 1.0.22
12
+
13
+ ### Patch Changes
14
+
15
+ - Update deps
16
+ - Updated dependencies
17
+ - @treenity/js-shared@1.0.20
18
+
3
19
  ## 1.0.21
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 +1,69 @@
1
- import{capitalize as e}from"@treenity/js-shared/utils";import{SynchronousPromise as t}from"synchronous-promise";class s{name;items=new Map;constructor(e){this.name=e,n[e]=this}add(...e){e.length<=3&&e.unshift("");const[t,s,n,o]=e,r=t?t+":"+s:s,a={id:r,context:this.name,subContext:t,component:n,options:o};return this.items.set(r,a),a}getInfo(e,s){s||(s=e,e="");const n=e?e+":"+s:s,o=this.items.get(n);return o?t.resolve(o):t.reject(new Error("not found: "+n))}get(e,t){return this.getInfo(e,t).then((({component:e,options:t})=>[e,t]))}search(e,t){const s=[];t||(t=e,e="");for(let n of this.items.values()){const o=n.subContext===e,r=n.id.includes(t);o&&r&&s.push(n)}return s}}const n={};new class extends s{add(...t){if(4===t.length){const[,s,n]=t;n.displayName||n.name||(n.displayName=e(s))}else{const[s,n]=t;n.displayName||n.name||(n.displayName=e(s))}return super.add(...t)}}("react"),new class extends s{}("meta"),new class extends s{}("proto"),new class extends s{}("jsSrv"),new class extends s{}("noflo");export{s as ContextImpl,n as types};
1
+ import { SynchronousPromise } from 'synchronous-promise';
2
+ import { getTypeCache } from './get-type-cache.mjs';
3
+ import { metaType } from './meta-type.mjs';
4
+
5
+ class ContextImpl {
6
+ name;
7
+ items = new Map();
8
+ constructor(name) {
9
+ this.name = name;
10
+ getTypeCache()[name] = this;
11
+ }
12
+ // add(...args: Pro<Context<C, O>['add']>): TypeContextInfo<C, O>;
13
+ // add(...args: ArgumentTypes<Context<C, O>['add']>): TypeContextInfo<C, O> {
14
+ add(...args) {
15
+ if (args.length <= 3)
16
+ args.unshift(undefined);
17
+ let [subContext, typeName, component, options = {}] = args;
18
+ typeName = metaType(typeName, subContext);
19
+ const contextType = typeName.$id;
20
+ const t = {
21
+ id: contextType,
22
+ context: this.name,
23
+ subContext,
24
+ component,
25
+ options,
26
+ };
27
+ this.items.set(contextType, t);
28
+ return t;
29
+ }
30
+ // get(typeName: string): Promise<TypeContextInfo<C, O>>;
31
+ // get(subContext: string, typeName: string): Promise<TypeContextInfo<C, O>>;
32
+ getInfo(subContext, typeName) {
33
+ if (!typeName) {
34
+ typeName = subContext;
35
+ subContext = undefined;
36
+ }
37
+ typeName = metaType(typeName, subContext);
38
+ const contextType = typeName.$id;
39
+ const item = this.items.get(contextType);
40
+ if (!item) {
41
+ return SynchronousPromise.reject(new Error('not found: ' + contextType + ' in ' + this.name + ' context'));
42
+ }
43
+ return SynchronousPromise.resolve(item);
44
+ }
45
+ get(subContext, typeName) {
46
+ return this.getInfo(subContext, typeName).then(({ component, options }) => [
47
+ component,
48
+ options,
49
+ ]);
50
+ }
51
+ async search(subContext, query) {
52
+ const result = [];
53
+ if (!query) {
54
+ query = subContext;
55
+ subContext = '';
56
+ }
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)) {
60
+ result.push(t);
61
+ }
62
+ }
63
+ return result;
64
+ }
65
+ }
66
+ // Node engine script context type
67
+
68
+ export { ContextImpl };
69
+ //# sourceMappingURL=context.mjs.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ription } 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 +1,10 @@
1
- export{ContextImpl,types}from"./context.mjs";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';
10
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
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
+ export { Link as default };
72
+ //# sourceMappingURL=link.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link.mjs","sources":["../../src/link/link.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAaA,MAAM,YAAY,GAAG,oBAAoB,CAAC;AAI1C,MAAM,IAAK,SAAQ,GAAG,CAAA;;IAEX,IAAI,CAAS;;IAEb,IAAI,CAAS;;IAEb,IAAI,CAAS;;IAEb,QAAQ,CAAS;;AAEjB,IAAA,KAAK,CAAS;IAEvB,WAAY,CAAA,MAA2B,EAAE,QAAwB,EAAA;AAC/D,QAAA,IAAI,MAAM,YAAY,IAAI,EAAE;YAC1B,IAAI,CAAC,QAAQ,EAAE;AACb,gBAAA,OAAO,MAAM,CAAC;aACf;AACD,YAAA,MAAM,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;SAC5B;AAAM,aAAA,IAAI,MAAM,YAAY,GAAG,EAAE;AAChC,YAAA,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC;SACtB;AAED,QAAA,MAAM,QAAQ,GAAG,QAAQ,EAAE,QAAQ,IAAI,OAAO,CAAC;AAE/C,QAAA,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC;YAAE,MAAM,GAAG,GAAG,QAAQ,CAAA,CAAA,CAAG,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;QAC/E,KAAK,CAAC,MAAM,CAAC,CAAC;AAEd,QAAA,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACvC,QAAA,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;AAE9C,QAA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,IAAI,CAAC,CAAC;KACrB;AAED,IAAA,IAAI,OAAO,GAAA;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;KACvC;AAED,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,35 @@
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
+ constructor(type: string, context: string);
10
+ get $id(): string;
11
+ get server(): MetaType<T>;
12
+ get client(): MetaType<T>;
13
+ get empty(): MetaType<T>;
14
+ inContext<T1 = T>(this: MetaType<any>, context: string): MetaType<T1>;
15
+ toString(): string;
16
+ isEqual(other: MetaName<any>, context?: string | boolean): boolean;
17
+ }
18
+ type MetaType_<T> = Readonly<InstanceType<typeof MetaTypeImpl<T>>>;
19
+ export type MetaType<T> = MetaType_<T>;
20
+ export type MetaName<T> = MetaType<T> | string;
21
+ export type MetaPath = Link | string;
22
+ export type FromMetaType<T> = T extends MetaType<infer U> ? U : never;
23
+ export declare function pathToString(path: MetaPath): string;
24
+ export declare function metaType<T>(type: MetaName<T>, context?: string): MetaType<T>;
25
+ 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>;
26
+ /**
27
+ * Any type equals to any other type and has no context
28
+ */
29
+ export declare class AntTypeImpl extends MetaTypeImpl<any> {
30
+ constructor();
31
+ isEqual(other: MetaName<any>, context?: string | boolean): boolean;
32
+ inContext<T1 = any>(context: string): MetaType<any>;
33
+ }
34
+ export declare const AnyType: Readonly<MetaTypeImpl<unknown>>;
35
+ export {};
@@ -0,0 +1,71 @@
1
+ import { getTypeName } from './meta.mjs';
2
+
3
+ function makeTypeId(type, context) {
4
+ return context ? `${context}:${type}` : type;
5
+ }
6
+ class MetaTypeImpl {
7
+ $type;
8
+ $context;
9
+ $item;
10
+ constructor(type, context) {
11
+ this.$type = type;
12
+ this.$context = context;
13
+ Object.freeze(this);
14
+ }
15
+ get $id() {
16
+ return makeTypeId(this.$type, this.$context);
17
+ }
18
+ get server() {
19
+ return this.$context === 'server' ? this : this.inContext('server');
20
+ }
21
+ get client() {
22
+ return this.$context === 'client' ? this : this.inContext('client');
23
+ }
24
+ get empty() {
25
+ return !this.$context ? this : this.inContext('');
26
+ }
27
+ inContext(context) {
28
+ return metaType(this, context);
29
+ }
30
+ toString() {
31
+ return `[${this.$id}]`;
32
+ }
33
+ isEqual(other, context) {
34
+ // if context boolean – it indicates if we should count context while comparison
35
+ if (typeof context === 'boolean') {
36
+ other = metaType(other);
37
+ return this.$type === other.$type && (!context || this.$context === other.$context);
38
+ }
39
+ other = metaType(other, context);
40
+ return this.$type === other.$type && this.$context === other.$context;
41
+ }
42
+ }
43
+ function pathToString(path) {
44
+ return typeof path === 'string' ? path : path.toString();
45
+ }
46
+ function metaType(type, subContext) {
47
+ subContext ??= typeof type === 'string' ? '' : type.$context;
48
+ type = getTypeName(type);
49
+ return (_metaTypes[makeTypeId(type, subContext)] ??= new MetaTypeImpl(type, subContext));
50
+ }
51
+ /**
52
+ * Any type equals to any other type and has no context
53
+ */
54
+ class AntTypeImpl extends MetaTypeImpl {
55
+ constructor() {
56
+ super('any', '');
57
+ }
58
+ isEqual(other, context) {
59
+ return true;
60
+ }
61
+ inContext(context) {
62
+ return this;
63
+ }
64
+ }
65
+ const _metaTypes = {
66
+ any: new AntTypeImpl(),
67
+ };
68
+ const AnyType = metaType('any');
69
+
70
+ export { AntTypeImpl, AnyType, MetaTypeImpl, makeTypeId, metaType, pathToString };
71
+ //# sourceMappingURL=meta-type.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta-type.mjs","sources":["../src/meta-type.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAIgB,SAAA,UAAU,CAAC,IAAY,EAAE,OAAgB,EAAA;AACvD,IAAA,OAAO,OAAO,GAAG,CAAG,EAAA,OAAO,CAAI,CAAA,EAAA,IAAI,CAAE,CAAA,GAAG,IAAI,CAAC;AAC/C,CAAC;MAEY,YAAY,CAAA;AACvB,IAAA,KAAK,CAAS;AACd,IAAA,QAAQ,CAAS;AACjB,IAAA,KAAK,CAAK;IAEV,WAAY,CAAA,IAAY,EAAE,OAAe,EAAA;AACvC,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;AAClB,QAAA,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;AACxB,QAAA,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;KACrB;AAED,IAAA,IAAI,GAAG,GAAA;QACL,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;KAC9C;AAED,IAAA,IAAI,MAAM,GAAA;AACR,QAAA,OAAO,IAAI,CAAC,QAAQ,KAAK,QAAQ,GAAG,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;KACrE;AAED,IAAA,IAAI,MAAM,GAAA;AACR,QAAA,OAA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,WAAW,CAAC,IAAI,CAAC,CAAC;AAEzB,IAAA,QAAQ,UAAU,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,KAAK,IAAI,YAAY,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE;AAC3F,CAAC;AAED;;AAEG;AACG,MAAO,WAAY,SAAQ,YAAiB,CAAA;AAChD,IAAA,WAAA,GAAA;AACE,QAAA,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;KAClB;IAED,OAAO,CAAC,KAAoB,EAAE,OAA0B,EAAA;AACtD,QAAA,OAAO,IAAI,CAAC;KACb;AAED,IAAA,SAAS,CAAW,OAAe,EAAA;AACjC,QAAA,OAAO,IAAqB,CAAC;KAC9B;AACF,CAAA;AAED,MAAM,UAAU,GAA4C;IAC1D,GAAG,EAAE,IAAI,WAAW,EAAE;CACvB,CAAC;MAEW,OAAO,GAAG,QAAQ,CAAC,KAAK;;;;"}
package/dist/meta.d.ts CHANGED
@@ -1,39 +1,22 @@
1
- export interface IMeta {
1
+ import { Raw } from '@treenity/js-shared/utils';
2
+ import { MetaName } from './meta-type';
3
+ export interface WithId {
2
4
  $id: string;
3
- $name: string;
4
- $anchor?: string;
5
+ }
6
+ export interface Typed {
5
7
  $type: string;
8
+ }
9
+ export interface MetaRaw extends Typed, WithId {
10
+ $name?: string;
11
+ $anchor?: string;
6
12
  $perm?: MetaPermission;
7
13
  $tg?: string[];
8
14
  }
9
- export type Meta<T = {}> = IMeta & T;
10
- export type MetaPermission = Record<string, Array<string>>;
11
- export interface NodeRef {
12
- ref: string;
13
- url: string;
14
- }
15
- export interface NodeLink {
16
- p: string;
17
- v: string;
15
+ export interface Meta<T = any> extends MetaRaw {
18
16
  }
19
- export interface INode {
20
- $parid: string;
21
- /**
22
- * if ref exists in $refs, then field value will be replaced with value pointed by NodeRef.url
23
- */
24
- $refs: NodeRef[];
25
- path: string;
26
- links?: NodeLink[];
27
- defaultMeta?: string;
28
- title: string;
29
- metas: {
30
- [name: string]: Meta;
31
- };
32
- }
33
- export type Node = Meta<INode>;
34
- export type MetaType_<T> = {
35
- readonly $type: string;
36
- readonly $item?: T;
37
- };
38
- export type MetaType<T> = MetaType_<T>;
39
- export declare function metaType<T>(type: string, item?: Partial<T>): MetaType<T>;
17
+ export type MetaPermission = Record<string, Array<string>>;
18
+ export declare const MetaSymbolType: unique symbol;
19
+ export declare function getMeta<T>(entity: T): Meta<T>;
20
+ export declare function getMetaRaw<T>(entity: T): Raw<T>;
21
+ export declare function serializeMeta(meta: any): Record<string, any>;
22
+ export declare function getTypeName(metaName: MetaName<any>): string;
package/dist/meta.mjs CHANGED
@@ -1 +1,19 @@
1
- function t(){return`[${this.$type}]`}function n(n,e){return{$type:n,$item:e,toString:t}}export{n as metaType};
1
+ import { getSymbolField } from '@treenity/js-shared/utils';
2
+
3
+ //& NodeCallSignature;
4
+ const MetaSymbolType = Symbol.for('$meta');
5
+ function getMeta(entity) {
6
+ return getSymbolField(entity, MetaSymbolType);
7
+ }
8
+ function getMetaRaw(entity) {
9
+ return getSymbolField(entity, MetaSymbolType).$raw;
10
+ }
11
+ function serializeMeta(meta) {
12
+ return typeof meta.toJSON === 'function' ? meta.toJSON() : JSON.parse(JSON.stringify(meta));
13
+ }
14
+ function getTypeName(metaName) {
15
+ return typeof metaName === 'string' ? metaName : metaName.$type;
16
+ }
17
+
18
+ export { MetaSymbolType, getMeta, getMetaRaw, getTypeName, serializeMeta };
19
+ //# sourceMappingURL=meta.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta.mjs","sources":["../src/meta.ts"],"sourcesContent":[null],"names":[],"mappings":";;AA0BA;AAEa,MAAA,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE;AAE5C,SAAU,OAAO,CAAI,MAAS,EAAA;AAClC,IAAA,OAAO,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAChD,CAAC;AAEK,SAAU,UAAU,CAAI,MAAS,EAAA;IACrC,OAAQ,cAAc,CAAC,MAAM,EAAE,cAAc,CAAS,CAAC,IAAc,CAAC;AACxE,CAAC;AAEK,SAAU,aAAa,CAAC,IAAS,EAAA;IACrC,OAAO,OAAO,IAAI,CAAC,MAAM,KAAK,UAAU,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9F,CAAC;AAEK,SAAU,WAAW,CAAC,QAAuB,EAAA;AACjD,IAAA,OAAO,OAAO,QAAQ,KAAK,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC;AAClE;;;;"}
@@ -0,0 +1 @@
1
+ export * from './types';
@@ -0,0 +1,27 @@
1
+ import { ProxyChain, Raw } from '@treenity/js-shared/utils';
2
+ import { MetaPermission, MetaRaw } from '../meta';
3
+ import { MetaName, MetaPath } from '../meta-type';
4
+ export interface NodeRef {
5
+ ref: string;
6
+ url: string;
7
+ }
8
+ export interface NodeRaw {
9
+ /**
10
+ * if ref exists in $refs, then field value will be replaced with value pointed by NodeRef.url
11
+ */
12
+ $perm: MetaPermission;
13
+ url: string;
14
+ default?: string;
15
+ refs: NodeRef[];
16
+ metas: {
17
+ [name: string]: MetaRaw;
18
+ };
19
+ }
20
+ export interface Node extends NodeRaw {
21
+ allRaw(): MetaRaw[];
22
+ raw<T>(type: MetaName<T>, path?: MetaPath): T | undefined;
23
+ get<T>(type: MetaName<T>, path?: MetaPath): Promise<T>;
24
+ $<T>(type: MetaName<T>, path?: MetaPath): ProxyChain<T>;
25
+ add<T>(type: MetaName<T>, meta: Raw<T>, name?: string): Promise<T>;
26
+ remove(meta: string | any): Promise<boolean>;
27
+ }
package/dist/stats.html CHANGED
@@ -4822,7 +4822,7 @@ var drawChart = (function (exports) {
4822
4822
  </script>
4823
4823
  <script>
4824
4824
  /*<!--*/
4825
- const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.mjs","children":[{"name":"src/index.ts","uid":"36925c29-1"}]},{"name":"context.mjs","children":[{"name":"src/context.ts","uid":"36925c29-3"}]},{"name":"meta.mjs","children":[{"name":"src/meta.ts","uid":"36925c29-5"}]}],"isRoot":true},"nodeParts":{"36925c29-1":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"36925c29-0"},"36925c29-3":{"renderedLength":2915,"gzipLength":798,"brotliLength":0,"metaUid":"36925c29-2"},"36925c29-5":{"renderedLength":138,"gzipLength":118,"brotliLength":0,"metaUid":"36925c29-4"}},"nodeMetas":{"36925c29-0":{"id":"/src/index.ts","moduleParts":{"index.mjs":"36925c29-1"},"imported":[{"uid":"36925c29-2"},{"uid":"36925c29-6"},{"uid":"36925c29-4"}],"importedBy":[],"isEntry":true},"36925c29-2":{"id":"/src/context.ts","moduleParts":{"context.mjs":"36925c29-3"},"imported":[{"uid":"36925c29-7"},{"uid":"36925c29-8"}],"importedBy":[{"uid":"36925c29-0"}]},"36925c29-4":{"id":"/src/meta.ts","moduleParts":{"meta.mjs":"36925c29-5"},"imported":[],"importedBy":[{"uid":"36925c29-0"}]},"36925c29-6":{"id":"/src/contexts/json-schema/types.ts","moduleParts":{},"imported":[],"importedBy":[{"uid":"36925c29-0"}]},"36925c29-7":{"id":"@treenity/js-shared/utils","moduleParts":{},"imported":[],"importedBy":[{"uid":"36925c29-2"}],"isExternal":true},"36925c29-8":{"id":"synchronous-promise","moduleParts":{},"imported":[],"importedBy":[{"uid":"36925c29-2"}],"isExternal":true}},"env":{"rollup":"4.9.6"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
4825
+ const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.mjs","children":[{"name":"src/index.ts","uid":"b5c9bc81-1"}]},{"name":"context.mjs","children":[{"name":"src/context.ts","uid":"b5c9bc81-3"}]},{"name":"link/link.mjs","children":[{"name":"src/link/link.ts","uid":"b5c9bc81-5"}]},{"name":"types.mjs","children":[{"name":"src/types.ts","uid":"b5c9bc81-7"}]},{"name":"meta.mjs","children":[{"name":"src/meta.ts","uid":"b5c9bc81-9"}]},{"name":"contexts/service.mjs","children":[{"name":"src/contexts/service.ts","uid":"b5c9bc81-11"}]},{"name":"contexts/proto.mjs","children":[{"name":"src/contexts/proto.ts","uid":"b5c9bc81-13"}]},{"name":"contexts/node-engine.mjs","children":[{"name":"src/contexts/node-engine.ts","uid":"b5c9bc81-15"}]},{"name":"contexts/react-context.mjs","children":[{"name":"src/contexts/react-context.ts","uid":"b5c9bc81-17"}]},{"name":"meta-type.mjs","children":[{"name":"src/meta-type.ts","uid":"b5c9bc81-19"}]},{"name":"get-type-cache.mjs","children":[{"name":"src/get-type-cache.ts","uid":"b5c9bc81-21"}]},{"name":"contexts/object.mjs","children":[{"name":"src/contexts/object.ts","uid":"b5c9bc81-23"}]}],"isRoot":true},"nodeParts":{"b5c9bc81-1":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"b5c9bc81-0"},"b5c9bc81-3":{"renderedLength":2064,"gzipLength":677,"brotliLength":0,"metaUid":"b5c9bc81-2"},"b5c9bc81-5":{"renderedLength":2233,"gzipLength":703,"brotliLength":0,"metaUid":"b5c9bc81-4"},"b5c9bc81-7":{"renderedLength":213,"gzipLength":137,"brotliLength":0,"metaUid":"b5c9bc81-6"},"b5c9bc81-9":{"renderedLength":468,"gzipLength":237,"brotliLength":0,"metaUid":"b5c9bc81-8"},"b5c9bc81-11":{"renderedLength":52,"gzipLength":62,"brotliLength":0,"metaUid":"b5c9bc81-10"},"b5c9bc81-13":{"renderedLength":50,"gzipLength":60,"brotliLength":0,"metaUid":"b5c9bc81-12"},"b5c9bc81-15":{"renderedLength":55,"gzipLength":65,"brotliLength":0,"metaUid":"b5c9bc81-14"},"b5c9bc81-17":{"renderedLength":576,"gzipLength":211,"brotliLength":0,"metaUid":"b5c9bc81-16"},"b5c9bc81-19":{"renderedLength":1877,"gzipLength":633,"brotliLength":0,"metaUid":"b5c9bc81-18"},"b5c9bc81-21":{"renderedLength":73,"gzipLength":81,"brotliLength":0,"metaUid":"b5c9bc81-20"},"b5c9bc81-23":{"renderedLength":348,"gzipLength":192,"brotliLength":0,"metaUid":"b5c9bc81-22"}},"nodeMetas":{"b5c9bc81-0":{"id":"/src/index.ts","moduleParts":{"index.mjs":"b5c9bc81-1"},"imported":[{"uid":"b5c9bc81-2"},{"uid":"b5c9bc81-24"},{"uid":"b5c9bc81-4"},{"uid":"b5c9bc81-25"},{"uid":"b5c9bc81-6"},{"uid":"b5c9bc81-8"},{"uid":"b5c9bc81-10"},{"uid":"b5c9bc81-12"},{"uid":"b5c9bc81-14"},{"uid":"b5c9bc81-16"},{"uid":"b5c9bc81-18"}],"importedBy":[],"isEntry":true},"b5c9bc81-2":{"id":"/src/context.ts","moduleParts":{"context.mjs":"b5c9bc81-3"},"imported":[{"uid":"b5c9bc81-26"},{"uid":"b5c9bc81-20"},{"uid":"b5c9bc81-18"}],"importedBy":[{"uid":"b5c9bc81-0"},{"uid":"b5c9bc81-10"},{"uid":"b5c9bc81-12"},{"uid":"b5c9bc81-14"},{"uid":"b5c9bc81-16"},{"uid":"b5c9bc81-22"}]},"b5c9bc81-4":{"id":"/src/link/link.ts","moduleParts":{"link/link.mjs":"b5c9bc81-5"},"imported":[{"uid":"b5c9bc81-27"}],"importedBy":[{"uid":"b5c9bc81-0"}]},"b5c9bc81-6":{"id":"/src/types.ts","moduleParts":{"types.mjs":"b5c9bc81-7"},"imported":[{"uid":"b5c9bc81-14"},{"uid":"b5c9bc81-22"},{"uid":"b5c9bc81-12"},{"uid":"b5c9bc81-16"},{"uid":"b5c9bc81-10"},{"uid":"b5c9bc81-20"}],"importedBy":[{"uid":"b5c9bc81-0"}]},"b5c9bc81-8":{"id":"/src/meta.ts","moduleParts":{"meta.mjs":"b5c9bc81-9"},"imported":[{"uid":"b5c9bc81-27"}],"importedBy":[{"uid":"b5c9bc81-0"},{"uid":"b5c9bc81-16"},{"uid":"b5c9bc81-18"}]},"b5c9bc81-10":{"id":"/src/contexts/service.ts","moduleParts":{"contexts/service.mjs":"b5c9bc81-11"},"imported":[{"uid":"b5c9bc81-2"}],"importedBy":[{"uid":"b5c9bc81-0"},{"uid":"b5c9bc81-6"}]},"b5c9bc81-12":{"id":"/src/contexts/proto.ts","moduleParts":{"contexts/proto.mjs":"b5c9bc81-13"},"imported":[{"uid":"b5c9bc81-2"}],"importedBy":[{"uid":"b5c9bc81-0"},{"uid":"b5c9bc81-6"}]},"b5c9bc81-14":{"id":"/src/contexts/node-engine.ts","moduleParts":{"contexts/node-engine.mjs":"b5c9bc81-15"},"imported":[{"uid":"b5c9bc81-2"}],"importedBy":[{"uid":"b5c9bc81-0"},{"uid":"b5c9bc81-6"}]},"b5c9bc81-16":{"id":"/src/contexts/react-context.ts","moduleParts":{"contexts/react-context.mjs":"b5c9bc81-17"},"imported":[{"uid":"b5c9bc81-27"},{"uid":"b5c9bc81-2"},{"uid":"b5c9bc81-8"}],"importedBy":[{"uid":"b5c9bc81-0"},{"uid":"b5c9bc81-6"}]},"b5c9bc81-18":{"id":"/src/meta-type.ts","moduleParts":{"meta-type.mjs":"b5c9bc81-19"},"imported":[{"uid":"b5c9bc81-8"}],"importedBy":[{"uid":"b5c9bc81-0"},{"uid":"b5c9bc81-2"}]},"b5c9bc81-20":{"id":"/src/get-type-cache.ts","moduleParts":{"get-type-cache.mjs":"b5c9bc81-21"},"imported":[],"importedBy":[{"uid":"b5c9bc81-2"},{"uid":"b5c9bc81-6"}]},"b5c9bc81-22":{"id":"/src/contexts/object.ts","moduleParts":{"contexts/object.mjs":"b5c9bc81-23"},"imported":[{"uid":"b5c9bc81-2"}],"importedBy":[{"uid":"b5c9bc81-6"}]},"b5c9bc81-24":{"id":"/src/contexts/noflo/types.ts","moduleParts":{},"imported":[],"importedBy":[{"uid":"b5c9bc81-0"}]},"b5c9bc81-25":{"id":"/src/node/index.ts","moduleParts":{},"imported":[{"uid":"b5c9bc81-28"}],"importedBy":[{"uid":"b5c9bc81-0"}]},"b5c9bc81-26":{"id":"synchronous-promise","moduleParts":{},"imported":[],"importedBy":[{"uid":"b5c9bc81-2"}],"isExternal":true},"b5c9bc81-27":{"id":"@treenity/js-shared/utils","moduleParts":{},"imported":[],"importedBy":[{"uid":"b5c9bc81-4"},{"uid":"b5c9bc81-8"},{"uid":"b5c9bc81-16"}],"isExternal":true},"b5c9bc81-28":{"id":"/src/node/types.ts","moduleParts":{},"imported":[],"importedBy":[{"uid":"b5c9bc81-25"}]}},"env":{"rollup":"4.18.0"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
4826
4826
 
4827
4827
  const run = () => {
4828
4828
  const width = window.innerWidth;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import { NodeEngineTypeContext } from './contexts/node-engine';
2
+ import { ObjectTypeContext } from './contexts/object';
3
+ import { ProtoTypeContext } from './contexts/proto';
4
+ import { ReactTypeContext } from './contexts/react-context';
5
+ import { ServiceTypeContext } from './contexts/service';
6
+ export interface ContextTypes {
7
+ react: ReactTypeContext;
8
+ jsSrv: ServiceTypeContext;
9
+ proto: ProtoTypeContext;
10
+ noflo: NodeEngineTypeContext;
11
+ entity: ObjectTypeContext;
12
+ }
13
+ export declare const types: ContextTypes;
package/dist/types.mjs ADDED
@@ -0,0 +1,16 @@
1
+ import { NodeEngineTypeContextImpl } from './contexts/node-engine.mjs';
2
+ import { ObjectTypeContextImpl } from './contexts/object.mjs';
3
+ import { ProtoTypeContextImpl } from './contexts/proto.mjs';
4
+ import { ReactTypeContextImpl } from './contexts/react-context.mjs';
5
+ import { ServiceTypeContextImpl } from './contexts/service.mjs';
6
+ import { getTypeCache } from './get-type-cache.mjs';
7
+
8
+ const types = getTypeCache();
9
+ new ReactTypeContextImpl('react');
10
+ new ProtoTypeContextImpl('proto');
11
+ new ServiceTypeContextImpl('jsSrv');
12
+ new NodeEngineTypeContextImpl('noflo');
13
+ new ObjectTypeContextImpl('entity');
14
+
15
+ export { types };
16
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.mjs","sources":["../src/types.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAea,MAAA,KAAK,GAAiB,YAAY,GAAmB;AAElE,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAClC,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAClC,IAAI,sBAAsB,CAAC,OAAO,CAAC,CAAC;AACpC,IAAI,yBAAyB,CAAC,OAAO,CAAC,CAAC;AACvC,IAAI,qBAAqB,CAAC,QAAQ,CAAC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@treenity/core",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "description": "treenity core",
5
5
  "author": "Treenity",
6
6
  "license": "ISC",
@@ -14,10 +14,11 @@
14
14
  }
15
15
  },
16
16
  "dependencies": {
17
- "@treenity/js-shared": "1.0.19",
18
- "json-schema-to-ts": "3.0.0",
17
+ "@treenity/js-shared": "1.0.21",
18
+ "json-schema": "^0.4.0",
19
+ "json-schema-to-ts": "3.1.0",
19
20
  "synchronous-promise": "2.0.17",
20
- "tslib": "2.6.2"
21
+ "tslib": "2.6.3"
21
22
  },
22
23
  "peerDependencies": {
23
24
  "react": "^18.2.0"
@@ -25,18 +26,16 @@
25
26
  "devDependencies": {
26
27
  "@testing-library/dom": "^8.17.1",
27
28
  "@testing-library/jest-dom": "6.4.5",
28
- "@testing-library/preact": "3.2.3",
29
- "@treenity/build-utils": "1.1.11",
30
- "@treenity/tsconfig": "1.0.9",
29
+ "@treenity/build-utils": "1.1.14",
30
+ "@treenity/tsconfig": "1.0.10",
31
31
  "@types/jest": "29.5.12",
32
+ "@types/json-schema": "^7.0.15",
32
33
  "@types/node": "20.11.16",
33
34
  "@types/prop-types": "^15.7.5",
34
35
  "@types/react": "18.2.51",
35
36
  "ajv": "^8.12.0",
36
37
  "jest": "29.7.0",
37
38
  "react": "18.2.0",
38
- "rollup": "4.9.6",
39
- "ts-jest": "29.0.3",
40
39
  "typescript": "5.4.5"
41
40
  },
42
41
  "scripts": {
@@ -44,7 +43,7 @@
44
43
  "watch": "rollup -c -w",
45
44
  "clean": "treenity-clean",
46
45
  "typecheck": "tsc",
47
- "--test": "jest --no-cache --detectOpenHandles --runInBand --forceExit",
46
+ "test": "jest --no-cache --detectOpenHandles --runInBand --forceExit",
48
47
  "--doc": "typedoc --plugin typedoc-plugin-markdown"
49
48
  }
50
49
  }
@@ -1,3 +0,0 @@
1
- import { SomeJSONSchema } from 'ajv/lib/types/json-schema';
2
- import { JSONSchema } from 'json-schema-to-ts';
3
- export type JsonObjectSchema = SomeJSONSchema & JSONSchema;
package/jest.config.ts DELETED
@@ -1,29 +0,0 @@
1
- import type { JestConfigWithTsJest } from 'ts-jest';
2
-
3
- const jestConfig: JestConfigWithTsJest = {
4
- preset: 'ts-jest',
5
- globals: {
6
- 'ts-jest': {
7
- tsconfig: {
8
- allowJs: true,
9
- },
10
- },
11
- },
12
- testEnvironment: 'node',
13
- moduleNameMapper: {
14
- '^@/(.*)$': '<rootDir>/src/$1',
15
- },
16
- transformIgnorePatterns: ['node_modules/.pnpm/(?!@s-libs*)'],
17
- transform: {
18
- // '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
19
- // '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
20
- '^.+\\.(ts|js|jsx|mjs|tsx)?$': [
21
- 'ts-jest',
22
- {
23
- useESM: true,
24
- },
25
- ],
26
- },
27
- };
28
-
29
- export default jestConfig;