@coasys/ad4m 0.12.0-rc1-dev.5 → 0.12.0-rc2

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 (161) hide show
  1. package/lib/index.cjs +4968 -4805
  2. package/lib/index.js +4936 -4801
  3. package/lib/src/agent/AgentClient.d.ts +4 -0
  4. package/lib/src/agent/AgentClient.js +34 -0
  5. package/lib/src/index.d.ts +2 -3
  6. package/lib/src/index.js +2 -3
  7. package/lib/src/model/Ad4mModel.d.ts +8 -812
  8. package/lib/src/model/Ad4mModel.js +78 -2390
  9. package/lib/src/model/ModelQueryBuilder.d.ts +370 -0
  10. package/lib/src/model/ModelQueryBuilder.js +556 -0
  11. package/lib/src/model/decorators.d.ts +2 -20
  12. package/lib/src/model/decorators.js +5 -410
  13. package/lib/src/model/hydration.d.ts +102 -0
  14. package/lib/src/model/hydration.js +709 -0
  15. package/lib/src/model/index.d.ts +20 -0
  16. package/lib/src/model/index.js +20 -0
  17. package/lib/src/model/{schema/fromJSONSchema.d.ts → json-schema.d.ts} +45 -12
  18. package/lib/src/model/json-schema.js +326 -0
  19. package/lib/src/model/prolog-facts.d.ts +37 -0
  20. package/lib/src/model/{prolog/generatePrologFacts.js → prolog-facts.js} +47 -52
  21. package/lib/src/model/query-common.d.ts +14 -0
  22. package/lib/src/model/query-common.js +36 -0
  23. package/lib/src/model/query-prolog.d.ts +15 -0
  24. package/lib/src/model/query-prolog.js +140 -0
  25. package/lib/src/model/query-surreal.d.ts +44 -0
  26. package/lib/src/model/query-surreal.js +249 -0
  27. package/lib/src/model/sdna.d.ts +14 -0
  28. package/lib/src/model/sdna.js +141 -0
  29. package/lib/src/model/shacl-gen.d.ts +31 -0
  30. package/lib/src/model/shacl-gen.js +246 -0
  31. package/lib/src/model/surreal-utils.d.ts +1 -1
  32. package/lib/src/model/types.d.ts +75 -96
  33. package/lib/src/model/types.js +4 -4
  34. package/lib/src/model/util.d.ts +4 -5
  35. package/lib/src/model/util.js +12 -32
  36. package/lib/src/perspectives/PerspectiveClient.d.ts +1 -1
  37. package/lib/src/perspectives/PerspectiveProxy.d.ts +1 -1
  38. package/lib/src/perspectives/WakerSubscriptionManager.d.ts +79 -0
  39. package/lib/src/perspectives/WakerSubscriptionManager.js +196 -0
  40. package/lib/src/runtime/RuntimeResolver.d.ts +14 -0
  41. package/lib/src/runtime/RuntimeResolver.js +73 -0
  42. package/lib/src/schema.gql +14 -0
  43. package/lib/src/typeDefs.js +14 -0
  44. package/package.json +13 -8
  45. package/src/agent/AgentClient.ts +45 -0
  46. package/src/index.ts +2 -3
  47. package/src/model/Ad4mModel.ts +1084 -3818
  48. package/src/model/ModelQueryBuilder.ts +617 -0
  49. package/src/model/Subject.ts +1 -1
  50. package/src/model/decorators.ts +17 -475
  51. package/src/model/hydration.ts +796 -0
  52. package/src/model/index.ts +21 -0
  53. package/src/model/json-schema.ts +424 -0
  54. package/src/model/prolog-facts.ts +145 -0
  55. package/src/model/query-common.ts +48 -0
  56. package/src/model/query-prolog.ts +148 -0
  57. package/src/model/query-surreal.ts +280 -0
  58. package/src/model/relation-filtering.test.ts +0 -1
  59. package/src/model/sdna.ts +170 -0
  60. package/src/model/shacl-gen.ts +292 -0
  61. package/src/model/surreal-utils.ts +1 -1
  62. package/src/model/types.ts +182 -0
  63. package/src/model/util.ts +13 -36
  64. package/src/perspectives/PerspectiveClient.ts +1 -1
  65. package/src/perspectives/PerspectiveProxy.ts +1 -1
  66. package/src/perspectives/WakerSubscriptionManager.ts +292 -0
  67. package/src/runtime/RuntimeResolver.ts +53 -0
  68. package/lib/src/Ad4mClient.test.d.ts +0 -1
  69. package/lib/src/Ad4mClient.test.js +0 -1204
  70. package/lib/src/Literal.test.d.ts +0 -1
  71. package/lib/src/Literal.test.js +0 -41
  72. package/lib/src/model/mutation.d.ts +0 -81
  73. package/lib/src/model/mutation.js +0 -317
  74. package/lib/src/model/parentUtils.d.ts +0 -32
  75. package/lib/src/model/parentUtils.js +0 -64
  76. package/lib/src/model/prolog/generatePrologFacts.d.ts +0 -36
  77. package/lib/src/model/prolog/index.d.ts +0 -1
  78. package/lib/src/model/prolog/index.js +0 -1
  79. package/lib/src/model/query/ModelQueryBuilder.d.ts +0 -82
  80. package/lib/src/model/query/ModelQueryBuilder.js +0 -115
  81. package/lib/src/model/query/QueryBuilder.d.ts +0 -101
  82. package/lib/src/model/query/QueryBuilder.js +0 -193
  83. package/lib/src/model/query/SurrealQueryBuilder.d.ts +0 -48
  84. package/lib/src/model/query/SurrealQueryBuilder.js +0 -371
  85. package/lib/src/model/query/fetchInstance.d.ts +0 -24
  86. package/lib/src/model/query/fetchInstance.js +0 -144
  87. package/lib/src/model/query/hydration.d.ts +0 -54
  88. package/lib/src/model/query/hydration.js +0 -214
  89. package/lib/src/model/query/operations.d.ts +0 -59
  90. package/lib/src/model/query/operations.js +0 -384
  91. package/lib/src/model/query/snapshot.d.ts +0 -59
  92. package/lib/src/model/query/snapshot.js +0 -106
  93. package/lib/src/model/query/surrealCompiler.d.ts +0 -42
  94. package/lib/src/model/query/surrealCompiler.js +0 -304
  95. package/lib/src/model/schema/fromJSONSchema.js +0 -264
  96. package/lib/src/model/schema/metadata.d.ts +0 -15
  97. package/lib/src/model/schema/metadata.js +0 -112
  98. package/lib/src/model/subscription.d.ts +0 -47
  99. package/lib/src/model/subscription.js +0 -231
  100. package/lib/src/model/transaction.d.ts +0 -27
  101. package/lib/src/model/transaction.js +0 -32
  102. package/lib/src/shims/reflect-metadata.d.ts +0 -0
  103. package/lib/src/shims/type-graphql.d.ts +0 -32
  104. package/lib/src/src/Ad4mClient.d.ts +0 -28
  105. package/lib/src/src/Address.d.ts +0 -1
  106. package/lib/src/src/DID.d.ts +0 -1
  107. package/lib/src/src/Exception.d.ts +0 -7
  108. package/lib/src/src/Literal.d.ts +0 -7
  109. package/lib/src/src/PubSub.d.ts +0 -17
  110. package/lib/src/src/SmartLiteral.d.ts +0 -12
  111. package/lib/src/src/agent/Agent.d.ts +0 -110
  112. package/lib/src/src/agent/AgentClient.d.ts +0 -62
  113. package/lib/src/src/agent/AgentResolver.d.ts +0 -30
  114. package/lib/src/src/agent/AgentStatus.d.ts +0 -8
  115. package/lib/src/src/ai/AIClient.d.ts +0 -32
  116. package/lib/src/src/ai/AIResolver.d.ts +0 -75
  117. package/lib/src/src/ai/Tasks.d.ts +0 -37
  118. package/lib/src/src/buildSchema.d.ts +0 -1
  119. package/lib/src/src/expression/Expression.d.ts +0 -28
  120. package/lib/src/src/expression/ExpressionClient.d.ts +0 -13
  121. package/lib/src/src/expression/ExpressionRef.d.ts +0 -9
  122. package/lib/src/src/expression/ExpressionResolver.d.ts +0 -10
  123. package/lib/src/src/index.d.ts +0 -35
  124. package/lib/src/src/jestSetup.d.ts +0 -1
  125. package/lib/src/src/language/Icon.d.ts +0 -4
  126. package/lib/src/src/language/Language.d.ts +0 -206
  127. package/lib/src/src/language/LanguageClient.d.ts +0 -17
  128. package/lib/src/src/language/LanguageContext.d.ts +0 -37
  129. package/lib/src/src/language/LanguageHandle.d.ts +0 -9
  130. package/lib/src/src/language/LanguageMeta.d.ts +0 -35
  131. package/lib/src/src/language/LanguageRef.d.ts +0 -6
  132. package/lib/src/src/language/LanguageResolver.d.ts +0 -19
  133. package/lib/src/src/links/Links.d.ts +0 -39
  134. package/lib/src/src/links/Links.test.d.ts +0 -1
  135. package/lib/src/src/model/Ad4mModel.d.ts +0 -1438
  136. package/lib/src/src/model/Ad4mModel.test.d.ts +0 -1
  137. package/lib/src/src/model/Subject.d.ts +0 -25
  138. package/lib/src/src/model/decorators.d.ts +0 -545
  139. package/lib/src/src/model/util.d.ts +0 -12
  140. package/lib/src/src/neighbourhood/Neighbourhood.d.ts +0 -10
  141. package/lib/src/src/neighbourhood/NeighbourhoodClient.d.ts +0 -25
  142. package/lib/src/src/neighbourhood/NeighbourhoodProxy.d.ts +0 -19
  143. package/lib/src/src/neighbourhood/NeighbourhoodProxy.test.d.ts +0 -1
  144. package/lib/src/src/neighbourhood/NeighbourhoodResolver.d.ts +0 -24
  145. package/lib/src/src/perspectives/LinkQuery.d.ts +0 -11
  146. package/lib/src/src/perspectives/Perspective.d.ts +0 -38
  147. package/lib/src/src/perspectives/Perspective.test.d.ts +0 -1
  148. package/lib/src/src/perspectives/PerspectiveClient.d.ts +0 -97
  149. package/lib/src/src/perspectives/PerspectiveDiff.d.ts +0 -9
  150. package/lib/src/src/perspectives/PerspectiveHandle.d.ts +0 -18
  151. package/lib/src/src/perspectives/PerspectiveProxy.d.ts +0 -865
  152. package/lib/src/src/perspectives/PerspectiveResolver.d.ts +0 -57
  153. package/lib/src/src/runtime/RuntimeClient.d.ts +0 -56
  154. package/lib/src/src/runtime/RuntimeResolver.d.ts +0 -132
  155. package/lib/src/src/shacl/SHACLFlow.d.ts +0 -171
  156. package/lib/src/src/shacl/SHACLFlow.test.d.ts +0 -1
  157. package/lib/src/src/shacl/SHACLShape.d.ts +0 -117
  158. package/lib/src/src/shacl/SHACLShape.test.d.ts +0 -1
  159. package/lib/src/src/typeDefs.d.ts +0 -1
  160. package/lib/src/src/unwrapApolloResult.d.ts +0 -2
  161. package/lib/src/src/utils.d.ts +0 -25
@@ -1,38 +0,0 @@
1
- import { Link, LinkExpression, LinkExpressionInput, LinkInput } from "../links/Links";
2
- import { LinkQuery } from "./LinkQuery";
3
- /** A Perspective represents subjective meaning, encoded through
4
- * associations between expressions, a.k.a. Links, that is a graph
5
- * over the objective Expressions of any subset of Languages.
6
- *
7
- * This type represents the clean onotological concept of a Perspective.
8
- * An instance of this class can be regarded as an immutable snapshot of
9
- * a mutable perspective.
10
- *
11
- * The types PerspectiveProxy and PerspectiveHandle are used when dealing
12
- * with an instantiated mutable perspective as is done through most of
13
- * the GraphQL mutations.
14
- */
15
- export declare class Perspective {
16
- /** The content of the perspective, a list/graph of links */
17
- links: LinkExpression[];
18
- constructor(links?: LinkExpression[]);
19
- /** Convenience function for filtering links just like with PerspectiveProxy */
20
- get(query: LinkQuery): LinkExpression[];
21
- /** Convenience function to get the target of the first link that matches the given query
22
- * This makes sense when the query is expected to return only one link
23
- * and the target of that link is what you are looking for.
24
- */
25
- getSingleTarget(query: LinkQuery): string | void;
26
- }
27
- export declare class PerspectiveInput {
28
- links: LinkExpressionInput[];
29
- }
30
- export declare class PerspectiveUnsignedInput {
31
- links: LinkInput[];
32
- constructor(links?: LinkInput[]);
33
- static fromLink(link: Link): PerspectiveUnsignedInput;
34
- }
35
- declare const PerspectiveExpression_base: any;
36
- export declare class PerspectiveExpression extends PerspectiveExpression_base {
37
- }
38
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,97 +0,0 @@
1
- import { ApolloClient } from "@apollo/client/core";
2
- import { ExpressionRendered } from "../expression/Expression";
3
- import { ExpressionClient } from "../expression/ExpressionClient";
4
- import { Link, LinkExpressionInput, LinkExpression, LinkMutations, LinkExpressionMutations } from "../links/Links";
5
- import { NeighbourhoodClient } from "../neighbourhood/NeighbourhoodClient";
6
- import { NeighbourhoodProxy } from "../neighbourhood/NeighbourhoodProxy";
7
- import { LinkQuery } from "./LinkQuery";
8
- import { Perspective } from "./Perspective";
9
- import { PerspectiveHandle, PerspectiveState } from "./PerspectiveHandle";
10
- import { LinkStatus, PerspectiveProxy } from './PerspectiveProxy';
11
- import { AIClient } from "../ai/AIClient";
12
- import { AllInstancesResult } from "../model/Ad4mModel";
13
- export type PerspectiveHandleCallback = (perspective: PerspectiveHandle) => null;
14
- export type UuidCallback = (uuid: string) => null;
15
- export type LinkCallback = (link: LinkExpression) => null;
16
- export type SyncStateChangeCallback = (state: PerspectiveState) => null;
17
- export declare class PerspectiveClient {
18
- #private;
19
- constructor(client: ApolloClient<any>, subscribe?: boolean);
20
- setExpressionClient(client: ExpressionClient): void;
21
- setNeighbourhoodClient(client: NeighbourhoodClient): void;
22
- setAIClient(client: AIClient): void;
23
- get aiClient(): AIClient;
24
- all(): Promise<PerspectiveProxy[]>;
25
- byUUID(uuid: string): Promise<PerspectiveProxy | null>;
26
- snapshotByUUID(uuid: string): Promise<Perspective | null>;
27
- publishSnapshotByUUID(uuid: string): Promise<string | null>;
28
- queryLinks(uuid: string, query: LinkQuery): Promise<LinkExpression[]>;
29
- queryProlog(uuid: string, query: string): Promise<any>;
30
- /**
31
- * Executes a read-only SurrealQL query against a perspective's link cache.
32
- *
33
- * Security: Only SELECT, RETURN, and other read-only queries are permitted.
34
- * Mutating operations (DELETE, UPDATE, INSERT, etc.) are blocked.
35
- *
36
- * Note: GraphQL field name is "perspectiveQuerySurrealDb" (lowercase "b" in "Db")
37
- * as generated from Rust method "perspective_query_surreal_db"
38
- */
39
- querySurrealDB(uuid: string, query: string): Promise<any>;
40
- subscribeQuery(uuid: string, query: string): Promise<{
41
- subscriptionId: string;
42
- result: AllInstancesResult;
43
- isInit?: boolean;
44
- }>;
45
- perspectiveSubscribeSurrealQuery(uuid: string, query: string): Promise<{
46
- subscriptionId: string;
47
- result: AllInstancesResult;
48
- isInit?: boolean;
49
- }>;
50
- perspectiveKeepAliveSurrealQuery(uuid: string, subscriptionId: string): Promise<boolean>;
51
- perspectiveDisposeSurrealQuerySubscription(uuid: string, subscriptionId: string): Promise<boolean>;
52
- subscribeToQueryUpdates(subscriptionId: string, onData: (result: AllInstancesResult) => void): () => void;
53
- keepAliveQuery(uuid: string, subscriptionId: string): Promise<boolean>;
54
- disposeQuerySubscription(uuid: string, subscriptionId: string): Promise<boolean>;
55
- add(name: string): Promise<PerspectiveProxy>;
56
- update(uuid: string, name: string): Promise<PerspectiveProxy>;
57
- remove(uuid: string): Promise<{
58
- perspectiveRemove: boolean;
59
- }>;
60
- addLink(uuid: string, link: Link, status?: LinkStatus, batchId?: string): Promise<LinkExpression>;
61
- addLinks(uuid: string, links: Link[], status?: LinkStatus, batchId?: string): Promise<LinkExpression[]>;
62
- removeLinks(uuid: string, links: LinkExpressionInput[], batchId?: string): Promise<LinkExpression[]>;
63
- linkMutations(uuid: string, mutations: LinkMutations, status?: LinkStatus): Promise<LinkExpressionMutations>;
64
- addLinkExpression(uuid: string, link: LinkExpression, status?: LinkStatus, batchId?: string): Promise<LinkExpression>;
65
- updateLink(uuid: string, oldLink: LinkExpressionInput, newLink: Link, batchId?: string): Promise<LinkExpression>;
66
- removeLink(uuid: string, link: LinkExpressionInput, batchId?: string): Promise<boolean>;
67
- /**
68
- * Adds Social DNA code to a perspective.
69
- *
70
- * Preferred usage: pass shaclJson (from SHACLShape.toJSON()) as the primary schema definition.
71
- * The sdnaCode parameter is kept for backward compatibility but SHACL is the source of truth
72
- * for all SDNA operations. Prolog engines remain available for complex queries.
73
- *
74
- * @param sdnaCode - Legacy Prolog code (pass empty string when using shaclJson)
75
- * @param shaclJson - SHACL JSON string from SHACLShape.toJSON() (recommended)
76
- */
77
- addSdna(uuid: string, name: string, sdnaCode: string | undefined, sdnaType: "subject_class" | "flow" | "custom", shaclJson?: string): Promise<boolean>;
78
- executeCommands(uuid: string, commands: string, expression: string, parameters: string, batchId?: string): Promise<boolean>;
79
- createSubject(uuid: string, subjectClass: string, expressionAddress: string, initialValues?: string, batchId?: string): Promise<boolean>;
80
- getSubjectData(uuid: string, subjectClass: string, expressionAddress: string): Promise<string>;
81
- getExpression(expressionURI: string): Promise<ExpressionRendered>;
82
- createExpression(content: any, languageAddress: string): Promise<string>;
83
- addPerspectiveAddedListener(cb: PerspectiveHandleCallback): void;
84
- subscribePerspectiveAdded(): void;
85
- addPerspectiveUpdatedListener(cb: PerspectiveHandleCallback): void;
86
- subscribePerspectiveUpdated(): void;
87
- addPerspectiveSyncedListener(cb: SyncStateChangeCallback): void;
88
- addPerspectiveSyncStateChangeListener(uuid: String, cb: SyncStateChangeCallback[]): Promise<void>;
89
- addPerspectiveRemovedListener(cb: UuidCallback): void;
90
- subscribePerspectiveRemoved(): void;
91
- addPerspectiveLinkAddedListener(uuid: String, cb: LinkCallback[]): Promise<void>;
92
- addPerspectiveLinkRemovedListener(uuid: String, cb: LinkCallback[]): Promise<void>;
93
- addPerspectiveLinkUpdatedListener(uuid: String, cb: LinkCallback[]): Promise<void>;
94
- getNeighbourhoodProxy(uuid: string): NeighbourhoodProxy;
95
- createBatch(uuid: string): Promise<string>;
96
- commitBatch(uuid: string, batchId: string): Promise<LinkExpressionMutations>;
97
- }
@@ -1,9 +0,0 @@
1
- import { LinkExpression } from "../links/Links";
2
- export declare class PerspectiveDiff {
3
- additions: LinkExpression[];
4
- removals: LinkExpression[];
5
- }
6
- declare const PerspectiveDiffExpression_base: any;
7
- export declare class PerspectiveDiffExpression extends PerspectiveDiffExpression_base {
8
- }
9
- export {};
@@ -1,18 +0,0 @@
1
- import { NeighbourhoodExpression } from "../neighbourhood/Neighbourhood";
2
- export declare enum PerspectiveState {
3
- Private = "PRIVATE",
4
- NeighboudhoodCreationInitiated = "NEIGHBOURHOOD_CREATION_INITIATED",
5
- NeighbourhoodJoinInitiated = "NEIGHBOURHOOD_JOIN_INITIATED",
6
- LinkLanguageFailedToInstall = "LINK_LANGUAGE_FAILED_TO_INSTALL",
7
- LinkLanguageInstalledButNotSynced = "LINK_LANGUAGE_INSTALLED_BUT_NOT_SYNCED",
8
- Synced = "SYNCED"
9
- }
10
- export declare class PerspectiveHandle {
11
- uuid: string;
12
- name: string;
13
- state: PerspectiveState;
14
- sharedUrl?: string;
15
- neighbourhood?: NeighbourhoodExpression;
16
- owners?: string[];
17
- constructor(uuid?: string, name?: string, state?: PerspectiveState);
18
- }