@firmer/mesh 0.0.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.
Files changed (111) hide show
  1. package/README.md +24 -0
  2. package/dist/asm/index.d.ts +11 -0
  3. package/dist/cause/codeable.d.ts +5 -0
  4. package/dist/cause/errors.d.ts +1 -0
  5. package/dist/cause/index.d.ts +3 -0
  6. package/dist/cause/status.d.ts +46 -0
  7. package/dist/codec/codec.d.ts +43 -0
  8. package/dist/codec/index.d.ts +2 -0
  9. package/dist/codec/json.d.ts +12 -0
  10. package/dist/grpc/consumer.d.ts +8 -0
  11. package/dist/grpc/index.d.ts +3 -0
  12. package/dist/grpc/interceptor.d.ts +2 -0
  13. package/dist/grpc/provider.d.ts +5 -0
  14. package/dist/http/consumer.d.ts +12 -0
  15. package/dist/http/index.d.ts +2 -0
  16. package/dist/http/provider.d.ts +5 -0
  17. package/dist/index.d.ts +116 -0
  18. package/dist/macro/ark.d.ts +84 -0
  19. package/dist/macro/binding.d.ts +1 -0
  20. package/dist/macro/dsa.d.ts +20 -0
  21. package/dist/macro/env.d.ts +43 -0
  22. package/dist/macro/idx.d.ts +12 -0
  23. package/dist/macro/index.d.ts +10 -0
  24. package/dist/macro/inspector.d.ts +144 -0
  25. package/dist/macro/loader.d.ts +15 -0
  26. package/dist/macro/mpi.d.ts +21 -0
  27. package/dist/macro/mps.d.ts +12 -0
  28. package/dist/macro/spi.d.ts +13 -0
  29. package/dist/mesh.d.ts +2 -0
  30. package/dist/mesh.js +11088 -0
  31. package/dist/mesh.umd.cjs +24 -0
  32. package/dist/mpc/compiler.d.ts +23 -0
  33. package/dist/mpc/consumer.d.ts +28 -0
  34. package/dist/mpc/consumer_filter.d.ts +6 -0
  35. package/dist/mpc/context.d.ts +33 -0
  36. package/dist/mpc/eden.d.ts +44 -0
  37. package/dist/mpc/execution.d.ts +74 -0
  38. package/dist/mpc/filter.d.ts +19 -0
  39. package/dist/mpc/hook.d.ts +23 -0
  40. package/dist/mpc/index.d.ts +16 -0
  41. package/dist/mpc/invoker.d.ts +57 -0
  42. package/dist/mpc/mesh.d.ts +42 -0
  43. package/dist/mpc/mesh_eden.d.ts +25 -0
  44. package/dist/mpc/mock.d.ts +7 -0
  45. package/dist/mpc/provider.d.ts +10 -0
  46. package/dist/mpc/proxy.d.ts +6 -0
  47. package/dist/mpc/reference.d.ts +21 -0
  48. package/dist/mpc/service.d.ts +7 -0
  49. package/dist/mpc/urn.d.ts +32 -0
  50. package/dist/psi/builtin.d.ts +49 -0
  51. package/dist/psi/cache.d.ts +44 -0
  52. package/dist/psi/cipher.d.ts +73 -0
  53. package/dist/psi/cluster.d.ts +11 -0
  54. package/dist/psi/commerce.d.ts +20 -0
  55. package/dist/psi/context.d.ts +148 -0
  56. package/dist/psi/cryptor.d.ts +23 -0
  57. package/dist/psi/datahouse.d.ts +24 -0
  58. package/dist/psi/dispatcher.d.ts +13 -0
  59. package/dist/psi/endpoint.d.ts +14 -0
  60. package/dist/psi/evaluator.d.ts +20 -0
  61. package/dist/psi/graph.d.ts +11 -0
  62. package/dist/psi/index.d.ts +29 -0
  63. package/dist/psi/kms.d.ts +20 -0
  64. package/dist/psi/kv.d.ts +24 -0
  65. package/dist/psi/licenser.d.ts +24 -0
  66. package/dist/psi/locker.d.ts +19 -0
  67. package/dist/psi/network.d.ts +49 -0
  68. package/dist/psi/pipeline.d.ts +28 -0
  69. package/dist/psi/publisher.d.ts +12 -0
  70. package/dist/psi/registry.d.ts +20 -0
  71. package/dist/psi/routable.d.ts +37 -0
  72. package/dist/psi/savepoint.d.ts +24 -0
  73. package/dist/psi/scheduler.d.ts +47 -0
  74. package/dist/psi/sequence.d.ts +20 -0
  75. package/dist/psi/subscriber.d.ts +11 -0
  76. package/dist/psi/tokenizer.d.ts +48 -0
  77. package/dist/psi/transport.d.ts +33 -0
  78. package/dist/psi/vfs.d.ts +32 -0
  79. package/dist/psi/workflow.d.ts +35 -0
  80. package/dist/schema/citizen.d.ts +25 -0
  81. package/dist/schema/index.d.ts +2 -0
  82. package/dist/schema/schema.d.ts +2 -0
  83. package/dist/system/index.d.ts +1 -0
  84. package/dist/system/mesh_network.d.ts +15 -0
  85. package/dist/test/network.test.d.ts +4 -0
  86. package/dist/tool/addrs.d.ts +11 -0
  87. package/dist/tool/index.d.ts +3 -0
  88. package/dist/tool/table.d.ts +7 -0
  89. package/dist/tool/tool.d.ts +31 -0
  90. package/dist/types/builtin.d.ts +121 -0
  91. package/dist/types/cipher.d.ts +111 -0
  92. package/dist/types/document.d.ts +34 -0
  93. package/dist/types/entity.d.ts +59 -0
  94. package/dist/types/enums.d.ts +2 -0
  95. package/dist/types/environ.d.ts +52 -0
  96. package/dist/types/event.d.ts +55 -0
  97. package/dist/types/index.d.ts +20 -0
  98. package/dist/types/keys.d.ts +41 -0
  99. package/dist/types/license.d.ts +111 -0
  100. package/dist/types/oauth2.d.ts +138 -0
  101. package/dist/types/payload.d.ts +29 -0
  102. package/dist/types/principal.d.ts +35 -0
  103. package/dist/types/registration.d.ts +114 -0
  104. package/dist/types/route.d.ts +90 -0
  105. package/dist/types/savepoint.d.ts +34 -0
  106. package/dist/types/script.d.ts +26 -0
  107. package/dist/types/status.d.ts +13 -0
  108. package/dist/types/transport.d.ts +40 -0
  109. package/dist/types/version.d.ts +10 -0
  110. package/dist/types/workflow.d.ts +190 -0
  111. package/package.json +56 -0
@@ -0,0 +1,20 @@
1
+ import { Context } from './context';
2
+ import { CommerceEnviron, CommerceLicense, License } from '../types';
3
+ export declare abstract class Commercialize {
4
+ /**
5
+ * Sign license, only glab has permission to sign.
6
+ */
7
+ sign(lsr: License, ctx?: Context): Promise<CommerceLicense>;
8
+ /**
9
+ * History list the sign license in history, the latest is the first index.
10
+ */
11
+ history(instId: string, ctx?: Context): Promise<CommerceLicense[]>;
12
+ /**
13
+ * Issued mesh node identity.
14
+ */
15
+ issued(name: string, kind: string, cname: string, ctx?: Context): Promise<CommerceEnviron>;
16
+ /**
17
+ * Dump the node identity.
18
+ */
19
+ dump(nodeId: string, ctx?: Context): Promise<CommerceEnviron[]>;
20
+ }
@@ -0,0 +1,148 @@
1
+ import { Location, Principal } from '../types/principal';
2
+ export declare class RunMode {
3
+ /**
4
+ * Routine 正常模式
5
+ */
6
+ static readonly Routine: RunMode;
7
+ /**
8
+ * Perform 评测模式
9
+ */
10
+ static readonly Perform: RunMode;
11
+ /**
12
+ * Defense 高防模式
13
+ */
14
+ static readonly Defense: RunMode;
15
+ /**
16
+ * Debug 调试模式
17
+ */
18
+ static readonly Debug: RunMode;
19
+ /**
20
+ * LoadTest 压测模式
21
+ */
22
+ static readonly LoadTest: RunMode;
23
+ /**
24
+ * Mock Mock模式
25
+ */
26
+ static readonly Mock: RunMode;
27
+ private readonly v;
28
+ constructor(v: number);
29
+ /**
30
+ * match run mode or else.
31
+ */
32
+ matches(r: number): boolean;
33
+ }
34
+ export declare class Key<T> {
35
+ name: string;
36
+ constructor(name: string);
37
+ }
38
+ export declare class Deque<T> extends Array {
39
+ peek(): T | undefined;
40
+ }
41
+ export declare abstract class Context {
42
+ /**
43
+ * GetTraceId the request trace id.
44
+ */
45
+ abstract getTraceId(): string;
46
+ /**
47
+ * GetSpanId the request span id.
48
+ */
49
+ abstract getSpanId(): string;
50
+ /**
51
+ * getTimestamp the request create time.
52
+ */
53
+ abstract getTimestamp(): number;
54
+ /**
55
+ * getRunMode the request run mode. {@link RunMode}
56
+ */
57
+ abstract getRunMode(): number;
58
+ /**
59
+ * getUrn mesh resource uniform name. Like: create.tenant.omega.json.http2.lx000001.mpi.3344.tech
60
+ */
61
+ abstract getUrn(): string;
62
+ /**
63
+ * getConsumer the consumer network principal.
64
+ */
65
+ abstract getConsumer(ctc: Context): Location;
66
+ /**
67
+ * getProvider the provider network principal.
68
+ * @param ctx
69
+ */
70
+ abstract getProvider(ctx: Context): Location;
71
+ /**
72
+ * getAttachments Dispatch attachments.
73
+ */
74
+ abstract getAttachments(): Map<string, string>;
75
+ /**
76
+ * getPrincipals Get the mpc broadcast network principals.
77
+ */
78
+ abstract getPrincipals(): Deque<Principal>;
79
+ /**
80
+ * getAttributes like getAttachments, but attribute wont be transfer in invoke chain.
81
+ */
82
+ abstract getAttributes(): Map<string, any>;
83
+ /**
84
+ * getAttribute like getAttachments, but attribute wont be transfer in invoke chain.
85
+ */
86
+ abstract getAttribute<T>(key: Key<T>): any;
87
+ /**
88
+ * setAttribute Like putAttachments, but attribute won't be transfer in invoke chain.
89
+ */
90
+ abstract setAttribute<T>(key: Key<T>, value: any): void;
91
+ /**
92
+ * rewriteURN rewrite the urn.
93
+ */
94
+ abstract rewriteURN(urn: string): void;
95
+ /**
96
+ * rewriteContext rewrite the context by another context.
97
+ */
98
+ abstract rewriteContext(ctx: Context): void;
99
+ /**
100
+ * resume will open a new context.
101
+ */
102
+ abstract resume(): Context;
103
+ }
104
+ /**
105
+ * https://www.rfc-editor.org/rfc/rfc7540#section-8.1.2
106
+ */
107
+ export declare class Header {
108
+ static MESH_TRACE_ID: Header;
109
+ static MESH_SPAN_ID: Header;
110
+ static MESH_TIMESTAMP: Header;
111
+ static MESH_RUN_MODE: Header;
112
+ static MESH_CONSUMER: Header;
113
+ static MESH_PROVIDER: Header;
114
+ static MESH_URN: Header;
115
+ static MESH_FROM_INST_ID: Header;
116
+ static MESH_FROM_NODE_ID: Header;
117
+ static MESH_INCOMING_HOST: Header;
118
+ static MESH_OUTGOING_HOST: Header;
119
+ static MESH_INCOMING_PROXY: Header;
120
+ static MESH_OUTGOING_PROXY: Header;
121
+ static MESH_SUBSET: Header;
122
+ static MESH_SESSION_ID: Header;
123
+ static MESH_VERSION: Header;
124
+ static MESH_TIMEOUT: Header;
125
+ static MESH_PTP_VERSION: Header;
126
+ static MESH_PTP_TPC: Header;
127
+ static MESH_PTP_TRACE_ID: Header;
128
+ static MESH_PTP_TOKEN: Header;
129
+ static MESH_PTP_SOURCE_NODE_ID: Header;
130
+ static MESH_PTP_TARGET_NODE_ID: Header;
131
+ static MESH_PTP_SOURCE_INST_ID: Header;
132
+ static MESH_PTP_TARGET_INST_ID: Header;
133
+ static MESH_PTP_SESSION_ID: Header;
134
+ private readonly key;
135
+ constructor(key: string);
136
+ get(ctx: Context): string;
137
+ set(ctx: Context, value: string): void;
138
+ }
139
+ export declare abstract class ContextProvider {
140
+ /**
141
+ * New mpc context.
142
+ */
143
+ abstract context(): Context;
144
+ }
145
+ /**
146
+ * New mpc context.
147
+ */
148
+ export declare function context(): Context;
@@ -0,0 +1,23 @@
1
+ import { Context } from './context';
2
+ export declare abstract class Cryptor {
3
+ /**
4
+ * Encrypt binary to encrypted binary.
5
+ */
6
+ encrypt(buf: Uint8Array, keys: Record<string, Uint8Array>, ctx?: Context): Promise<Uint8Array>;
7
+ /**
8
+ * Decrypt binary to decrypted binary.
9
+ */
10
+ decrypt(buf: Uint8Array, keys: Record<string, Uint8Array>, ctx?: Context): Promise<Uint8Array>;
11
+ /**
12
+ * Hash compute the hash value.
13
+ */
14
+ hash(buf: Uint8Array, keys: Record<string, Uint8Array>, ctx?: Context): Promise<Uint8Array>;
15
+ /**
16
+ * Sign compute the signature value.
17
+ */
18
+ sign(buf: Uint8Array, keys: Record<string, Uint8Array>, ctx?: Context): Promise<Uint8Array>;
19
+ /**
20
+ * Verify the signature value.
21
+ */
22
+ verify(buf: Uint8Array, keys: Record<string, Uint8Array>, ctx?: Context): Promise<boolean>;
23
+ }
@@ -0,0 +1,24 @@
1
+ import { Context } from './context';
2
+ import { Document, Page, Paging } from '../types';
3
+ export declare abstract class DataHouse {
4
+ /**
5
+ * Writes
6
+ */
7
+ writes(docs: Document[], ctx?: Context): Promise<void>;
8
+ /**
9
+ * Write
10
+ */
11
+ write(doc: Document, ctx?: Context): Promise<void>;
12
+ /**
13
+ * Read
14
+ */
15
+ read(index: Paging, ctx?: Context): Promise<Page<any>>;
16
+ /**
17
+ * Indies
18
+ */
19
+ indies(index: Paging, ctx?: Context): Promise<Page<any>>;
20
+ /**
21
+ * Tables
22
+ */
23
+ tables(index: Paging, ctx?: Context): Promise<Page<any>>;
24
+ }
@@ -0,0 +1,13 @@
1
+ import { Context } from './context';
2
+ export declare abstract class Dispatcher {
3
+ /**
4
+ * Invoke with fewer returns
5
+ * In multi returns, it will discard multi returns
6
+ */
7
+ invoke(urn: string, param: Record<string, any>, ctx?: Context): Promise<any>;
8
+ /**
9
+ * Invoke0 with fewer returns in generic mode
10
+ * In multi returns, it will discard multi returns
11
+ */
12
+ invoke0(urn: string, param: any, ctx?: Context): Promise<any>;
13
+ }
@@ -0,0 +1,14 @@
1
+ import { Context } from './context';
2
+ export declare abstract class Endpoint {
3
+ /**
4
+ * Fuzzy call with generic param
5
+ * In multi returns, it's an array.
6
+ */
7
+ fuzzy(buff: Uint8Array, ctx?: Context): Promise<Uint8Array>;
8
+ }
9
+ export declare abstract class EndpointSticker<I, O> {
10
+ /**
11
+ * Stick with generic param
12
+ */
13
+ stick(varg: I, ctx?: Context): Promise<O>;
14
+ }
@@ -0,0 +1,20 @@
1
+ import { Context } from './context';
2
+ import { Page, Paging, Script } from '../types';
3
+ export declare abstract class Evaluator {
4
+ /**
5
+ * Compile the named rule.
6
+ */
7
+ compile(script: Script, ctx?: Context): Promise<string>;
8
+ /**
9
+ * Exec the script with name.
10
+ */
11
+ exec(code: string, args: Record<string, string>, dft: string, ctx?: Context): Promise<string>;
12
+ /**
13
+ * Dump the scripts.
14
+ */
15
+ dump(feature: Record<string, string>, ctx?: Context): Promise<Script[]>;
16
+ /**
17
+ * Index the scripts.
18
+ */
19
+ index(index: Paging, ctx?: Context): Promise<Page<Script>>;
20
+ }
@@ -0,0 +1,11 @@
1
+ import { Context } from './context';
2
+ export declare abstract class Graph {
3
+ /**
4
+ * Query with cypher.
5
+ */
6
+ query(expr: string, args: Record<string, any>, ctx?: Context): Promise<Record<string, any>[]>;
7
+ /**
8
+ * Exec cypher.
9
+ */
10
+ exec(expr: string, args: Record<string, any>, ctx?: Context): Promise<void>;
11
+ }
@@ -0,0 +1,29 @@
1
+ export * from './builtin';
2
+ export * from './cache';
3
+ export * from './cipher';
4
+ export * from './cluster';
5
+ export * from './commerce';
6
+ export * from './context';
7
+ export * from './cryptor';
8
+ export * from './datahouse';
9
+ export * from './dispatcher';
10
+ export * from './endpoint';
11
+ export * from './evaluator';
12
+ export * from './graph';
13
+ export * from './kms';
14
+ export * from './kv';
15
+ export * from './licenser';
16
+ export * from './locker';
17
+ export * from './network';
18
+ export * from './pipeline';
19
+ export * from './publisher';
20
+ export * from './registry';
21
+ export * from './routable';
22
+ export * from './savepoint';
23
+ export * from './scheduler';
24
+ export * from './sequence';
25
+ export * from './subscriber';
26
+ export * from './tokenizer';
27
+ export * from './transport';
28
+ export * from './vfs';
29
+ export * from './workflow';
@@ -0,0 +1,20 @@
1
+ import { Context } from './context';
2
+ import { Environ, KeyCsr, Keys } from '../types';
3
+ export declare abstract class KMS {
4
+ /**
5
+ * Reset will override the keystore environ.
6
+ */
7
+ reset(env: Environ, ctx?: Context): Promise<void>;
8
+ /**
9
+ * Environ will return the keystore environ.
10
+ */
11
+ environ(ctx?: Context): Promise<Environ>;
12
+ /**
13
+ * List will return the keystore environ.
14
+ */
15
+ list(cno: string, ctx?: Context): Promise<Keys[]>;
16
+ /**
17
+ * Issue will apply the certification.
18
+ */
19
+ issue(csr: KeyCsr, ctx?: Context): Promise<Keys[]>;
20
+ }
@@ -0,0 +1,24 @@
1
+ import { Context } from './context';
2
+ import { Body, Entry, Page, Paging } from '../types';
3
+ export declare abstract class KV {
4
+ /**
5
+ * Get the value from kv store.
6
+ */
7
+ get(key: string, ctx?: Context): Promise<Body>;
8
+ /**
9
+ * Put the value to kv store.
10
+ */
11
+ put(key: string, value: Body, ctx?: Context): Promise<void>;
12
+ /**
13
+ * Remove the kv store.
14
+ */
15
+ remove(key: string, ctx?: Context): Promise<void>;
16
+ /**
17
+ * Keys with the pattern of kv store.
18
+ */
19
+ keys(pattern: string, ctx?: Context): Promise<string[]>;
20
+ /**
21
+ * Index the kv for webui
22
+ */
23
+ index(index: Paging, ctx?: Context): Promise<Page<Entry>>;
24
+ }
@@ -0,0 +1,24 @@
1
+ import { Context } from './context';
2
+ import { License } from '../types';
3
+ export declare abstract class Licenser {
4
+ /**
5
+ * Imports the licenses.
6
+ */
7
+ imports(license: string, ctx?: Context): Promise<void>;
8
+ /**
9
+ * Exports the licenses.
10
+ */
11
+ exports(ctx?: Context): Promise<string>;
12
+ /**
13
+ * Explain the license.
14
+ */
15
+ explain(ctx?: Context): Promise<License>;
16
+ /**
17
+ * Verify the license.
18
+ */
19
+ verify(ctx?: Context): Promise<number>;
20
+ /**
21
+ * Features is license features.
22
+ */
23
+ features(ctx?: Context): Promise<Record<string, string>>;
24
+ }
@@ -0,0 +1,19 @@
1
+ import { Context } from './context';
2
+ export declare abstract class Locker {
3
+ /**
4
+ * Lock create write lock.
5
+ */
6
+ lock(rid: string, timeout: number, ctx?: Context): Promise<boolean>;
7
+ /**
8
+ * Unlock release write lock.
9
+ */
10
+ unlock(rid: string, ctx?: Context): Promise<void>;
11
+ /**
12
+ * ReadLock create read lock.
13
+ */
14
+ readLock(rid: string, timeout: number, ctx?: Context): Promise<boolean>;
15
+ /**
16
+ * ReadUnlock release read lock.
17
+ */
18
+ readUnlock(rid: string, ctx?: Context): Promise<void>;
19
+ }
@@ -0,0 +1,49 @@
1
+ import { Context } from './context';
2
+ import { Environ, Page, Paging, Route, Versions } from '../types';
3
+ export declare abstract class Network {
4
+ /**
5
+ * Environ Get the meth network environment fixed information.
6
+ */
7
+ environ(ctx?: Context): Promise<Environ>;
8
+ /**
9
+ * Accessible Check the mesh network is accessible.
10
+ */
11
+ accessible(route: Route, ctx?: Context): Promise<boolean>;
12
+ /**
13
+ * Refresh the routes to mesh network.
14
+ */
15
+ refresh(routes: Route[], ctx?: Context): Promise<void>;
16
+ /**
17
+ * Route the network edge route.
18
+ */
19
+ route(mdc: string, ctx?: Context): Promise<Route>;
20
+ /**
21
+ * Routes the network edge routes.
22
+ */
23
+ routes(ctx?: Context): Promise<Route[]>;
24
+ /**
25
+ * Disable the network
26
+ */
27
+ disable(mdc: string, ctx?: Context): Promise<void>;
28
+ /**
29
+ * Enable the network
30
+ */
31
+ enable(mdc: string, ctx?: Context): Promise<void>;
32
+ /**
33
+ * Index the network edges
34
+ */
35
+ index(index: Paging, ctx?: Context): Promise<Page<Route>>;
36
+ /**
37
+ * Version
38
+ * Network environment version.
39
+ */
40
+ version(mdc: string, ctx?: Context): Promise<Versions>;
41
+ /**
42
+ * Exports the weave certificate.
43
+ */
44
+ exports(mdc: string, ctx?: Context): Promise<string>;
45
+ /**
46
+ * Imports the weave certificate.
47
+ */
48
+ imports(crt: string, ctx?: Context): Promise<void>;
49
+ }
@@ -0,0 +1,28 @@
1
+ import { Context } from './context';
2
+ export declare abstract class Pipeline {
3
+ /**
4
+ * Peek
5
+ * Retrieves, but does not remove, the head of this queue,
6
+ * or returns None if this queue is empty.
7
+ */
8
+ peek(topic: string, ctx?: Context): Promise<Uint8Array>;
9
+ /**
10
+ * Pop
11
+ * Retrieves and removes the head of this queue,
12
+ * or returns None if this queue is empty.
13
+ */
14
+ pop(timeout: number, topic: string, ctx?: Context): Promise<Uint8Array>;
15
+ /**
16
+ * Push
17
+ * Inserts the specified element into this queue if it is possible to do
18
+ * so immediately without violating capacity restrictions.
19
+ * When using a capacity-restricted queue, this method is generally
20
+ * preferable to add, which can fail to insert an element only
21
+ * by throwing an exception.
22
+ */
23
+ push(payload: Uint8Array, metadata: Record<string, string>, topic: string, ctx?: Context): Promise<void>;
24
+ /**
25
+ * Release the channel session.
26
+ */
27
+ release(timeout: number, topic: string, ctx?: Context): Promise<void>;
28
+ }
@@ -0,0 +1,12 @@
1
+ import { Context } from './context';
2
+ import { Event } from '../types';
3
+ export declare abstract class Publisher {
4
+ /**
5
+ * Publish
6
+ */
7
+ publish(events: Event[], ctx?: Context): Promise<string[]>;
8
+ /**
9
+ * Broadcast
10
+ */
11
+ broadcast(events: Event[], ctx?: Context): Promise<string[]>;
12
+ }
@@ -0,0 +1,20 @@
1
+ import { Context } from './context';
2
+ import { Registration } from '../types';
3
+ export declare abstract class Registry {
4
+ /**
5
+ * Register
6
+ */
7
+ register(registration: Registration<any>, ctx?: Context): Promise<void>;
8
+ /**
9
+ * Registers
10
+ */
11
+ registers(registrations: Registration<any>[], ctx?: Context): Promise<void>;
12
+ /**
13
+ * Unregister
14
+ */
15
+ unregister(registration: Registration<any>, ctx?: Context): Promise<void>;
16
+ /**
17
+ * Export
18
+ */
19
+ export(kind: string, ctx?: Context): Promise<Registration<any>[]>;
20
+ }
@@ -0,0 +1,37 @@
1
+ import { Context } from './context';
2
+ import { Principal } from '../types';
3
+ export declare abstract class Routable {
4
+ /**
5
+ * With
6
+ * Route with attachments.
7
+ */
8
+ with(key: string, value: string, ctx?: Context): Promise<Routable>;
9
+ /**
10
+ * WithMap
11
+ * Route with attachments.
12
+ */
13
+ withMap(attachments: Record<string, string>, ctx?: Context): Promise<Routable>;
14
+ /**
15
+ * Local
16
+ * Invoke the service in local network.
17
+ */
18
+ local(ctx?: Context): Promise<any>;
19
+ /**
20
+ * Any
21
+ * Invoke the service in a network, it may be local or others.
22
+ */
23
+ any(principal: Principal, ctx?: Context): Promise<any>;
24
+ /**
25
+ * Many
26
+ * Invoke the service in many network, it may be local or others. Broadcast mode.
27
+ */
28
+ many(principals: Principal[], ctx?: Context): Promise<any[]>;
29
+ }
30
+ export declare class MpcStream {
31
+ /**
32
+ */
33
+ reference?: any;
34
+ /**
35
+ */
36
+ attachments: Record<string, string>;
37
+ }
@@ -0,0 +1,24 @@
1
+ import { Context } from './context';
2
+ import { DtxBranch, DtxDefinition } from '../types';
3
+ export declare abstract class Savepoint {
4
+ /**
5
+ * Begin a savepoint, this method will blocked a database transaction connection with timeout.
6
+ */
7
+ begin(definition: DtxDefinition, ctx?: Context): Promise<string>;
8
+ /**
9
+ * Commit a savepoint.
10
+ */
11
+ commit(xid: string, ctx?: Context): Promise<void>;
12
+ /**
13
+ * Rollback a savepoint.
14
+ */
15
+ rollback(xid: string, ctx?: Context): Promise<void>;
16
+ /**
17
+ * Execute a savepoint sql.
18
+ */
19
+ execute(branch: DtxBranch, ctx?: Context): Promise<Uint8Array>;
20
+ /**
21
+ * Redo dolog void redo before commit.
22
+ */
23
+ redo(commit: Uint8Array, ctx?: Context): Promise<void>;
24
+ }
@@ -0,0 +1,47 @@
1
+ import { Context } from './context';
2
+ import { Timeout, Topic } from '../types';
3
+ export declare abstract class Scheduler {
4
+ /**
5
+ * Timeout
6
+ * Schedules the specified {@link Timeout} for one-time execution after the specified delay.
7
+ */
8
+ timeout(timeout: Timeout, duration: number, ctx?: Context): Promise<string>;
9
+ /**
10
+ * Cron
11
+ * Schedules with the cron expression. "0 * * 1-3 * ? *"
12
+ */
13
+ cron(cron: string, topic: Topic, ctx?: Context): Promise<string>;
14
+ /**
15
+ * Period
16
+ * schedule with fixed duration.
17
+ */
18
+ period(duration: number, topic: Topic, ctx?: Context): Promise<string>;
19
+ /**
20
+ * Dump max is 1000 items
21
+ * Releases all resources acquired by this {@link Scheduler} and cancels all
22
+ * tasks which were scheduled but not executed yet.
23
+ */
24
+ dump(ctx?: Context): Promise<string[]>;
25
+ /**
26
+ * Cancel
27
+ * Attempts to cancel the {@link tech.firmer.mesh.types.Timeout} associated with this handle.
28
+ * If the task has been executed or cancelled already, it will return with
29
+ * no side effect.
30
+ */
31
+ cancel(taskId: string, ctx?: Context): Promise<boolean>;
32
+ /**
33
+ * Stop
34
+ * Attempts to stop the {@link tech.firmer.mesh.types.Timeout} associated with this handle.
35
+ * If the task has been executed or cancelled already, it will return with
36
+ * no side effect.
37
+ */
38
+ stop(taskId: string, ctx?: Context): Promise<boolean>;
39
+ /**
40
+ * Emit the scheduler topic
41
+ */
42
+ emit(topic: Topic, ctx?: Context): Promise<void>;
43
+ /**
44
+ * Shutdown the scheduler
45
+ */
46
+ shutdown(duration: number, ctx?: Context): Promise<void>;
47
+ }
@@ -0,0 +1,20 @@
1
+ import { Context } from './context';
2
+ export declare abstract class Sequence {
3
+ /**
4
+ * Next 生成全网唯一序列号
5
+ *
6
+ * Parameters:
7
+ * kind - 序列号类型,各个业务保持唯一.
8
+ * length - 长度
9
+ */
10
+ next(kind: string, length: number, ctx?: Context): Promise<string>;
11
+ /**
12
+ * Section 获取序列号段.
13
+ *
14
+ * Parameters:
15
+ * kind - 类型
16
+ * size - 号段大小
17
+ * length - 长度
18
+ */
19
+ section(kind: string, size: number, length: number, ctx?: Context): Promise<string[]>;
20
+ }
@@ -0,0 +1,11 @@
1
+ import { Context } from './context';
2
+ import { Event } from '../types';
3
+ export declare abstract class Subscriber {
4
+ /**
5
+ * Subscribe the event with {@link tech.firmer.mesh.macro.Bindings} or {@link tech.firmer.mesh.macro.Binding}
6
+ *
7
+ * Parameters:
8
+ * event - uniform event payload.
9
+ */
10
+ subscribe(event: Event, ctx?: Context): Promise<void>;
11
+ }