├── .editorconfig ├── .gitignore ├── .nvmrc ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── lib ├── index.js ├── package.json ├── schemas │ ├── agent.gql │ ├── agreement.gql │ ├── appreciation.gql │ ├── bridging │ │ ├── agent.agreement.gql │ │ ├── agent.geolocation.gql │ │ ├── agent.observation.gql │ │ ├── agent.plan.gql │ │ ├── agent.planning.gql │ │ ├── knowledge.observation.gql │ │ ├── observation.agreement.gql │ │ ├── observation.appreciation.gql │ │ ├── observation.geolocation.gql │ │ ├── observation.plan.gql │ │ ├── observation.planning.gql │ │ ├── observation.scenario.gql │ │ ├── planning.agreement.gql │ │ ├── planning.geolocation.gql │ │ ├── planning.plan.gql │ │ ├── planning.proposal.gql │ │ ├── proposal.agent.gql │ │ └── proposal.geolocation.gql │ ├── claim.gql │ ├── geolocation.gql │ ├── knowledge.gql │ ├── measurement.gql │ ├── observation.gql │ ├── plan.gql │ ├── planning.gql │ ├── proposal.gql │ ├── recipe.gql │ ├── scenario.gql │ └── util.gql ├── scripts │ ├── build.js │ ├── clean.sh │ └── codegen.yml └── tests │ ├── helpers.js │ ├── test-custom-extensions.js │ ├── test-module-configurations.js │ └── test-schema-parse.js ├── mock-client ├── README.md ├── index.js └── package.json ├── mock-server ├── index.js └── package.json ├── package.json ├── pnpm-lock.yaml ├── pnpm-workspace.yaml └── tests ├── helpers.js ├── package.json ├── test-custom-extensions.js ├── test-module-configurations.js └── test-schema-parse.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | # Unix-style newlines with a newline ending every file 4 | [*] 5 | end_of_line = lf 6 | insert_final_newline = true 7 | trim_trailing_whitespace = true 8 | indent_style = space 9 | indent_size = 2 10 | 11 | # Configs 12 | [*.{json,yml,ini}] 13 | indent_style = space 14 | indent_size = 2 15 | 16 | # Markdown 17 | [*.{md,markdown}] 18 | trim_trailing_whitespace = false 19 | indent_style = tab 20 | indent_size = 4 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | 3 | # build artifacts used only during packaging 4 | lib/build/ 5 | lib/json-schema.json 6 | lib/schema-manifest.js 7 | lib/ALL_VF_SDL.js 8 | lib/index.d.ts 9 | lib/index.flow.js 10 | lib/LICENSE 11 | lib/CHANGELOG.md 12 | lib/README.md 13 | 14 | # https://github.com/maxlath/backup-github-repo 15 | /repo-backup 16 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | v10.9.0 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 11 4 | # before_script: 5 | script: yarn && npm run build && npm run test 6 | git: 7 | quiet: true 8 | depth: false 9 | submodules: true 10 | branches: 11 | only: 12 | - master 13 | # :NOTE: pull request builds are on, so this takes care of feature branches 14 | - /^(release|hotfix)\/.*/ 15 | # cache: 16 | # yarn: true 17 | # directories: 18 | # - "/tmp/holochain/target" 19 | # cargo: true 20 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.8.4 2 | 3 | - Fixed casing of `AgreementResponse.agreement` to remove uppercase `A` 4 | - GraphQL peer dependency minimum compatible version downgraded to `14.5.8`. (Incompatibilities were between GraphQL & GraphiQL, not this lib.) 5 | 6 | ## 0.8.3 7 | 8 | - Added `classifiedAs` to `Organization` 9 | - Added `onHandEffect` to `Action` 10 | - Added `defaultUnitOfResource` to `ResourceSpecification` 11 | - Added `RecipeExchange` to the *recipe* module 12 | - Further modularised schemas to allow economic modules to be used without `Agent` functionality 13 | - Updated GraphQL modules to most recent version (`15.x` series) and configured `graphql` as a peerDependency to allow broader compatibility 14 | 15 | ## 0.8.2 16 | 17 | - Allow overriding options for both `buildASTSchema` and `mergeTypeDefs` 18 | 19 | ## 0.8.1 20 | 21 | - Allow overriding options to `mergeTypeDefs` in order to deal with looser validation in extension schemas 22 | 23 | ## 0.8.0 24 | 25 | - Added an additional argument to `buildSchema` to allow passing extension schemas as SDL strings in order to extend core VF with custom domain-specific additions easily 26 | - **Breaking:** removed loose `AnyType` custom scalar and restricted `inScopeOf` fields to only allow `Person | Organization` as valid values. Note that implementations may extend the `AccountingScope` union type if they wish to allow other types of record scoping (eg. groups without collective agency, geographical locations). 27 | - **Breaking:** removed `all` prefixes from toplevel record listing endpoints for sensible autocomplete, and made search endpoint query prefixes into suffixes 28 | - **Breaking:** fixed deletion methods taking `String` when they should receive `ID` 29 | 30 | ## 0.7.1 31 | 32 | - Fix generated TypeScript / Flow types missing "bridging" fields due to misconfiguration of `graphql-codegen` 33 | - Fix `EconomicEvent` appreciation edges linking directly to other events instead of via `Appreciation` 34 | 35 | ## 0.7.0 36 | 37 | - Added descriptions to all `input` fields, to make interacting with the API more self-documenting 38 | - Added pagination parameters to all list queries 39 | - Removed many accounting fields from `EconomicEventUpdateParams` that should not have been present 40 | - Added various fields missed in the original conversion: 41 | - `Agent.primaryLocation` 42 | - `Scenario.definedAs` 43 | - Fixed missing input fields: 44 | - `basedOn` & `classifiedAs` in `ProcessUpdateParams` 45 | - `refinementOf` in `Plan` create / update 46 | - `resourceConformsTo` in `RecipeResource` create / update 47 | - `processClassifiedAs` in `RecipeProcess` create / update 48 | - `refinementOf` in `Scenario` create / update 49 | - `ScenarioDefinitionUpdateParams.name` 50 | - Add missing mutations & queries for `Claim`, `Scenario`, `ScenarioDefinition` & `SpatialThing` 51 | - Removed `pass` & `fail` actions from the set of core verbs (see [ValueFlows/#610](https://github.com/valueflows/valueflows/issues/610)) 52 | 53 | ## 0.6.1 54 | 55 | - Finished some rough edges on modularisation such that you no longer need to explicitly include `query` and `mutation` in the list of schemas to `buildSchema()`. 56 | 57 | ## 0.6.0 58 | 59 | - **Breaking:** significant changes to the internal structure of the module to facilitate modular composition of schemas. Now exports a `buildSchema` function rather than pre-initialised `schema` object. Use `printSchema` on the output of `buildSchema()` for tools which require the input as an SDL schema string, rather than a GraphQLSchema object. 60 | 61 | ## 0.5.0 62 | 63 | - **Breaking:** renames the `transfer-complete` action to `transfer`, as the former was confusing for some users 64 | - Adds missed mutations for `Proposal` and related records 65 | 66 | ## 0.4.3 67 | 68 | - Adds `defaultUnitOfEffort` to `ResourceSpecification` as a stop-gap for unit inference in VF0.4 release (see [#64](https://github.com/valueflows/vf-graphql/issues/64)) 69 | 70 | ## 0.4.2 71 | 72 | - Finalise fields for `EconmicResource` & `EconomicEvent` creation & update logic 73 | 74 | ## 0.4.1 75 | 76 | - Adds missed mutations for `Unit` & `ProcessSpecification` 77 | 78 | ## 0.4.0 79 | 80 | **Updated for ValueFlows 0.4 release.** 81 | 82 | - Changed from [QUDT](http://www.qudt.org/pages/QUDToverviewPage.html) to [OM](https://github.com/HajoRijgersberg/OM) ontology for measurements 83 | - New action metadata 84 | - Add `EconomicResource` stage & state attributes 85 | - Remove `before` & `after` time fields on `EconomicEvent` & `Process` 86 | 87 | ## 0.3.0 88 | 89 | Initial release. Rough around the edges, missing many mutations & queries, but the core schema is stable. 90 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 ValueFlows contributors 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # This Project Has Moved 2 | 3 | All activity and development of this project has moved to a GitLab instance: 4 | 5 | https://lab.allmende.io/valueflows/vf-graphql 6 | 7 | This project only remains here for archival purposes. 8 | 9 | 10 | ## vf-graphql 11 | 12 | GraphQL reference implementation of the [ValueFlows](http://valueflo.ws/) grammar. 13 | 14 | 15 | 16 | - [API](#api) 17 | - [Generating schemas](#generating-schemas) 18 | - [Accessing schemas](#accessing-schemas) 19 | - [Validating implementations](#validating-implementations) 20 | - [Implementing](#implementing) 21 | - [Resolver logic](#resolver-logic) 22 | - [Scalar type resolvers](#scalar-type-resolvers) 23 | - [Dates & times](#dates--times) 24 | - [URIs](#uris) 25 | - [Development setup](#development-setup) 26 | - [Prerequisites](#prerequisites) 27 | - [Initialising for development](#initialising-for-development) 28 | - [Available commands](#available-commands) 29 | - [Contributing](#contributing) 30 | - [Directory structure](#directory-structure) 31 | - [Code structure](#code-structure) 32 | - [Publishing to NPM](#publishing-to-npm) 33 | - [License](#license) 34 | 35 | 36 | 37 | 38 | This project synchronizes projects implementing VF for a GraphQL interface between client and server. It includes: 39 | 40 | - A GraphQL-native specification of the core VF grammar 41 | - Complementary schemas not part of the RDF-based VF spec but needed for all VF implementations of economic software (for example `Agent`, `Person`, `Organization`, `SpatialThing`, `note`, `image`). 42 | - Formal definition of mutation, query & subscriptions APIs 43 | - Formal definition of available query parameters 44 | - Inverse relationship naming 45 | - Composable GraphQL schemas, TypeScript and FlowType definitions 46 | - Runtime composition of schema modules into application-specific APIs which implement subsets of the ValueFlows vocabulary 47 | 48 | 49 | 50 | 51 | ## API 52 | 53 | The top-level module export contains three methods: `buildSchema`, `printSchema` and `validate`. 54 | 55 | ### Generating schemas 56 | 57 | The **`buildSchema`** method allows you to dynamically create schemas for the entire ValueFlows specification, or modular subsets of it. The full schema is broken down into modules of functionality, so that implementations which only aim to cover part of the specification can do so. 58 | 59 | - When run without arguments, `buildSchema` will return a GraphQLSchema object for the entire ValueFlows API, including all optional and auxiliary modules. 60 | - When passed an array, it builds a subset of the full spec which includes only the specified modules. For a complete list of modules, see `schemaModules` in `schema-manifest.js` or refer to the filenames in `lib/schemas`. 61 | - An optional second argument allows for custom extensions to the core specification to be injected, where implementations include additional domain-specific logic that is not part of ValueFlows. Simply pass an array of GraphQL [SDL schema strings](https://graphql.org/learn/schema/) and these will be merged into the resultant schema. 62 | 63 | ### Accessing schemas 64 | 65 | [**`printSchema`**](https://graphql.org/graphql-js/utilities/#printschema) from the `graphql` module is also exported to make it easy to turn the built schema objects created by `buildSchema` into SDL strings, as some tooling requires this input format. 66 | 67 | Therefore, if you need access to a string version of any schema you can get an SDL version with: 68 | 69 | printSchema(buildSchema(/* [...] */)) 70 | 71 | If all you need is the *entire* schema as a string, consider importing `@valueflows/vf-graphql/ALL_VF_SDL` or `@valueflows/vf-graphql/json-schema.json` instead. 72 | 73 | ### Validating implementations 74 | 75 | **`validate`** has the same parameters as `buildSchema`, but takes another GraphQL schema as its first argument and validates it against a schema generated from the given set of module IDs and extension schemas. The output format is that of GraphQL's [`findBreakingChanges`](https://github.com/graphql/graphql-js/blob/master/src/utilities/findBreakingChanges.js) method. 76 | 77 | 78 | 79 | 80 | ## Implementing 81 | 82 | To implement a system gateway compatible with the ValueFlows spec, you will need to define the following: 83 | 84 | ### Resolver logic 85 | 86 | Resolver methods which bind to your application services must be implemented. In traditional client/server architecture, this is usually done serverside and the implementation executes remotely. In distributed/decentralised systems it is usually important that this be done in the client app to avoid adding any extra centralised services to your infrastructure. 87 | 88 | If using Apollo GraphQL, this means defining an [implementation object](https://www.apollographql.com/docs/graphql-tools/generate-schema.html) which contains methods for resolving all relationship fields. This object is passed to `makeExecutableSchema` along with the `schema` definition exported by this module. 89 | 90 | Schemas will usually have to inject `__typename` parameters to disambiguate union types, especially for `EventOrCommitment` where there are no required fields which can determine the difference between the two records via duck-typing. 91 | 92 | For a more detailed example, see the [Holochain schema bindings](https://github.com/holo-rea/holo-rea/tree/master/modules/vf-graphql-holochain#readme). 93 | 94 | ### Scalar type resolvers 95 | 96 | #### Dates & times 97 | 98 | [Scalar type resolvers](https://www.apollographql.com/docs/graphql-tools/scalars.html) need to be provided for the ISO8601 `DateTime` type, in order to handle date encoding & decoding to your chosen storage system. 99 | 100 | `DateTime` should be of variable precision, and allow specifying dates without time components as well as times without milliseconds. The timezone specifier may be omitted, but it is recommended to inject it manually prior to transmission to the server to ensure that specified times remain local to the user making the request. 101 | 102 | #### URIs 103 | 104 | There is also a separate `URI` type which simply makes it explicit when a reference to some external asset is expected. Implementations may treat these as strings, or perform URI validation as needed. 105 | 106 | We usually suggest that you do *not* enforce an http/https protocol scheme, to allow for cross-system data linkage where records from distributed systems with their own URI resolution behaviour can be interlinked with web-based URLs. 107 | 108 | 109 | 110 | 111 | ## Development setup 112 | 113 | ### Prerequisites 114 | 115 | - If you don't have Yarn- `npm i -g yarn` using the version of node you plan on developing this project against *(for recommended, see `.nvmrc`)*. You can setup your modules manually using `npm link` if you prefer, but Yarn's workspaces feature will save you a lot of time. 116 | 117 | ### Initialising for development 118 | 119 | 1. Run `yarn` from the top level folder of this repository to install and wire up all dependencies. 120 | 2. Run `npm run build` to compile the schema files. 121 | 122 | ### Available commands 123 | 124 | See `scripts` in `package.json` for the available commands. For quickly spinning up the full system, you should usually be able to simply run `npm start`. This will load up: 125 | 126 | - Test runner for the schemas. **It is recommended when authoring schemas to save often and watch the test output, as no line number information is available when debugging.** 127 | - A GraphiQL query UI at `http://localhost:3000/graphql` which you can use to test queries against a mock GraphQL API derived from the schema. 128 | - A [GraphQL Voyager](https://apis.guru/graphql-voyager/) UI at `http://localhost:3000/viewer` which shows an interactive visual representation useful for exploring the schema. 129 | 130 | 131 | ## Contributing 132 | 133 | The recommended way to contribute to this repo is via the `npm run dev:schema` command (also run as part of `npm start`). This will watch the code for changes and build & run tests every time you save a file. It's best to do it this way as the errors from the GraphQL parser can be hard to track down- more frequent feedback means you will catch any errors sooner. 134 | 135 | ### Directory structure 136 | 137 | The `lib/` directory contains all source of the reference schema & validation helpers: 138 | 139 | - `index.js` is the main entrypoint to the module, used by other packages wishing to validate schemas against the spec. 140 | - `tests/` contains tests for ensuring the schemas compile successfully. 141 | - `schemas/` contains the actual GraphQL schema definition files. **These are the files you should edit.** 142 | - `schemas/bridging/` contains files which are automatically loaded in `buildSchema`. The filenames are dot-separated, and if all of the filename components are present in the module IDs passed then the schema is injected. For a list of available module IDs, see `schema-manifest.js`. 143 | - `build/`, `json-schema.json` and the other `*.js` files are excluded from version control. They are generated from the schema definition files, using helper code in `lib/scripts/`. 144 | 145 | 146 | ### Code structure 147 | 148 | The "bridging" schema files in `schemas/bridging/` create non-obvious behaviour within the top-level schema modules in `schemas/`. On first glance, some fields (eg. `EconomicEvent.realizationOf`) may appear to be missing from the record type definitions. However, this field's presence in the `observation.agreement` "bridging" schema means that it will automatically be added to the output schema if both `observation` and `agreement` are included. So— always check these files for a property before consider it missing as it may be part of a cross-module relationship or index. 149 | 150 | The `buildSchema` helper defined in the module root manages all the logic for managing "bridging" schemas internally. 151 | 152 | 153 | ### Publishing to NPM 154 | 155 | - You will need to be given access to the [VF NPM org](https://www.npmjs.com/org/valueflows) in order to update the module on the registry. You can request access in https://gitter.im/valueflows/welcome 156 | - Bump the version in `lib/package.json` & commit to the repository 157 | - Update `CHANGELOG.md` with the new version ID and list of changes, and commit 158 | - Run `npm run publish` from this directory 159 | - Tag the current release in git and push the tag to `origin` 160 | 161 | 162 | 163 | 164 | ## License 165 | 166 | Released under an Apache 2.0 license. 167 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Entrypoint for inflated GraphQL schema and validation helpers 3 | * 4 | * @package: HoloREA 5 | * @since: 2019-02-11 6 | */ 7 | 8 | const { buildASTSchema, findBreakingChanges, printSchema } = require('graphql') 9 | const { mergeTypeDefs } = require('@graphql-tools/merge') 10 | 11 | const { schemaModules, bridgingSchemas } = require('./schema-manifest') 12 | 13 | function buildSchema(moduleIds, extensionSchemas, merge_options, build_options) { 14 | // default to all modules 15 | if (!moduleIds || !moduleIds.length) { 16 | moduleIds = Object.keys(schemaModules) 17 | } 18 | 19 | if (!merge_options) { 20 | merge_options = { throwOnConflict: true } 21 | } 22 | 23 | if (!build_options) { 24 | build_options = { assumeValidSDL: false } 25 | } 26 | 27 | 28 | // util types are always required 29 | moduleIds.push('util') 30 | 31 | // ensure each schema is only loaded once 32 | moduleIds = moduleIds.filter((value, index, self) => { 33 | return self.indexOf(value) === index 34 | }).sort() 35 | 36 | // automatically load in any 'bridging' schemas implied by the provided module IDs 37 | const bridgingModules = Object.keys(bridgingSchemas) 38 | .filter((bridge) => { 39 | const bridgeDependencies = bridge.split('.') 40 | for (let i = 0, l = bridgeDependencies.length; i < l; ++i) { 41 | if (moduleIds.indexOf(bridgeDependencies[i]) === -1) { 42 | return false 43 | } 44 | } 45 | return true 46 | }) 47 | 48 | // bring in the schema fragment strings 49 | const fragments = moduleIds.concat(bridgingModules).map(td => { 50 | const schemaData = schemaModules[td] || bridgingSchemas[td] 51 | if (!schemaData) { 52 | throw new Error(`Unknown Holo-REA schema module ID: ${td}`) 53 | } 54 | return schemaData 55 | }) 56 | 57 | // merge fragments and build GraphQLSchema object 58 | return buildASTSchema(mergeTypeDefs(fragments.concat(extensionSchemas || []), merge_options), build_options) 59 | } 60 | 61 | module.exports = { 62 | buildSchema, 63 | printSchema, 64 | validate: (oSchema, moduleIds, extensionSchemas) => findBreakingChanges(buildSchema(moduleIds, extensionSchemas), oSchema), 65 | } 66 | -------------------------------------------------------------------------------- /lib/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@valueflows/vf-graphql", 3 | "version": "0.8.4", 4 | "description": "Reference GraphQL implementation of the ValueFlows spec", 5 | "main": "index.js", 6 | "types": "index.d.ts", 7 | "files": [ 8 | "build/*", 9 | "schemas/*", 10 | "ALL_VF_SDL.js", 11 | "json-schema.json", 12 | "index.d.ts", 13 | "index.flow.js", 14 | "index.js", 15 | "package.json", 16 | "schema-manifest.js", 17 | "LICENSE", 18 | "CHANGELOG.md", 19 | "README.md" 20 | ], 21 | "scripts": { 22 | "dev": "npm-watch", 23 | "build": "mkdir build; graphql-codegen --config scripts/codegen.yml; node scripts/build.js", 24 | "test": "cd ../tests && npm test", 25 | "clean": "scripts/clean.sh", 26 | "prepare": "npm run clean; npm run build" 27 | }, 28 | "watch": { 29 | "build": { 30 | "patterns": [ 31 | "schemas" 32 | ], 33 | "extensions": "gql" 34 | }, 35 | "test": { 36 | "patterns": [ 37 | "tests", 38 | "build" 39 | ], 40 | "extensions": "js" 41 | } 42 | }, 43 | "repository": { 44 | "type": "git", 45 | "url": "git+ssh://git@github.com/valueflows/vf-graphql.git" 46 | }, 47 | "keywords": [ 48 | "ValueFlows", 49 | "REA", 50 | "GraphQL", 51 | "grammar" 52 | ], 53 | "author": "ValueFlows contributors", 54 | "license": "Apache-2.0", 55 | "bugs": { 56 | "url": "https://github.com/valueflows/vf-graphql/issues" 57 | }, 58 | "homepage": "https://github.com/valueflows/vf-graphql#readme", 59 | "dependencies": { 60 | "@graphql-tools/merge": "^6.0.7" 61 | }, 62 | "peerDependencies": { 63 | "graphql": ">=14" 64 | }, 65 | "devDependencies": { 66 | "@graphql-codegen/cli": "^1.15.1", 67 | "@graphql-codegen/flow": "^1.15.1", 68 | "@graphql-codegen/typescript": "^1.15.1", 69 | "@graphql-tools/merge": "^6.0.7", 70 | "globby": "^11.0.0", 71 | "graphql-2-json-schema": "^0.2.0", 72 | "npm-watch": "^0.6.0" 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /lib/schemas/agent.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Agent module 4 | # 5 | # All functionality related to the definition of autonomous agents 6 | # (people, organizations, groups) and their relationships. 7 | # 8 | # @package vf-graphql 9 | # @since 2019-02-11 10 | # 11 | ## 12 | 13 | """ 14 | A boundary or context grouped around some other record- used for documenting, accounting, planning. 15 | """ 16 | union AccountingScope = Person | Organization 17 | 18 | """ 19 | A person or group or organization with economic agency. 20 | """ 21 | interface Agent { 22 | id: ID! 23 | 24 | "An informal or formal textual identifier for an agent. Does not imply uniqueness." 25 | name: String! 26 | 27 | "The uri to an image relevant to the agent, such as a logo, avatar, photo, etc." 28 | image: URI 29 | 30 | "A textual description or comment." 31 | note: String 32 | 33 | ############################################################################## 34 | # inverse relationships and queries 35 | 36 | relationships(roleId: ID): [AgentRelationship!] # :TODO: category filtering 37 | relationshipsAsSubject(roleId: ID): [AgentRelationship!] # :TODO: category filtering 38 | relationshipsAsObject(roleId: ID): [AgentRelationship!] # :TODO: category filtering 39 | 40 | roles: [AgentRelationshipRole!] 41 | } 42 | 43 | """ 44 | A natural person. 45 | """ 46 | type Person implements Agent { 47 | id: ID! 48 | 49 | "The name that this agent will be referred to by." 50 | name: String! 51 | 52 | "The uri to an image relevant to the agent, such as a logo, avatar, photo, etc." 53 | image: URI 54 | 55 | "A textual description or comment." 56 | note: String 57 | 58 | ############################################################################## 59 | # inverse relationships and queries 60 | 61 | relationships(roleId: ID): [AgentRelationship!] # :TODO: category filtering 62 | relationshipsAsSubject(roleId: ID): [AgentRelationship!] # :TODO: category filtering 63 | relationshipsAsObject(roleId: ID): [AgentRelationship!] # :TODO: category filtering 64 | 65 | roles: [AgentRelationshipRole!] 66 | } 67 | 68 | """ 69 | A formal or informal group, or legal organization. 70 | """ 71 | type Organization implements Agent { 72 | id: ID! 73 | 74 | # :TODO: define how people can create further typing of Organization 75 | # type: OrganizationClassification 76 | 77 | "The name that this agent will be referred to by." 78 | name: String! 79 | 80 | "The uri to an image relevant to the agent, such as a logo, avatar, photo, etc." 81 | image: URI 82 | 83 | "References one or more concepts in a common taxonomy or other classification scheme for purposes of categorization or grouping." 84 | classifiedAs: [URI!] 85 | 86 | "A textual description or comment." 87 | note: String 88 | 89 | ############################################################################## 90 | # inverse relationships and queries 91 | 92 | relationships(roleId: ID): [AgentRelationship!] # :TODO: category filtering 93 | relationshipsAsSubject(roleId: ID): [AgentRelationship!] # :TODO: category filtering 94 | relationshipsAsObject(roleId: ID): [AgentRelationship!] # :TODO: category filtering 95 | 96 | roles: [AgentRelationshipRole!] 97 | } 98 | 99 | # Relationships between agents 100 | 101 | """ 102 | The role of an economic relationship that exists between 2 agents, such as member, trading partner. 103 | """ 104 | type AgentRelationship { 105 | id: ID! 106 | 107 | "The subject of a relationship between 2 agents. For example, if Mary is a member of a group, then Mary is the subject." 108 | subject: Agent! 109 | 110 | "The object of a relationship between 2 agents. For example, if Mary is a member of a group, then the group is the object." 111 | object: Agent! 112 | 113 | "A kind of relationship that exists between 2 agents." 114 | relationship: AgentRelationshipRole! 115 | 116 | "Grouping around something to create a boundary or context, used for documenting, accounting, planning." 117 | inScopeOf: [AccountingScope!] 118 | 119 | "A textual description or comment." 120 | note: String 121 | } 122 | 123 | """ 124 | A relationship role defining the kind of association one agent can have with another. 125 | """ 126 | type AgentRelationshipRole { 127 | id: ID! 128 | 129 | "The human readable name of the role, from the subject to the object." 130 | roleLabel: String! 131 | 132 | "The human readable name of the role, from the object to the subject." 133 | inverseRoleLabel: String 134 | 135 | "A textual description or comment." 136 | note: String 137 | 138 | # :TODO: https://github.com/valueflows/valueflows/issues/494 139 | } 140 | 141 | # :TODO: how do we want to do this concept? 142 | # """ 143 | # Generalized behaviors for agent relationship roles 144 | # """ 145 | # enum AgentRelationshipCategory { 146 | # LEGALPARTNER 147 | # MEMBER 148 | # PART 149 | # PEER 150 | # TRADINGPARTNER 151 | # } 152 | 153 | 154 | 155 | input AgentCreateParams { # implements AgentParams 156 | "An informal or formal textual identifier for an agent. Does not imply uniqueness." 157 | name: String! 158 | 159 | "The uri to an image relevant to the agent, such as a logo, avatar, photo, etc." 160 | image: URI 161 | 162 | "(`SpatialThing`) The main place an agent is located, often an address where activities occur and mail can be sent. This is usually a mappable geographic location. It also could be a website address, as in the case of agents who have no physical location." 163 | primaryLocation: ID 164 | 165 | "A textual description or comment." 166 | note: String 167 | } 168 | 169 | input AgentUpdateParams { # implements UpdateParams & AgentParams 170 | id: ID! 171 | 172 | "An informal or formal textual identifier for an agent. Does not imply uniqueness." 173 | name: String 174 | 175 | "The uri to an image relevant to the agent, such as a logo, avatar, photo, etc." 176 | image: URI 177 | 178 | "(`SpatialThing`) The main place an agent is located, often an address where activities occur and mail can be sent. This is usually a mappable geographic location. It also could be a website address, as in the case of agents who have no physical location." 179 | primaryLocation: ID 180 | 181 | "A textual description or comment." 182 | note: String 183 | } 184 | 185 | 186 | input OrganizationCreateParams { # implements AgentParams 187 | "An informal or formal textual identifier for an agent. Does not imply uniqueness." 188 | name: String! 189 | 190 | "The uri to an image relevant to the agent, such as a logo, avatar, photo, etc." 191 | image: URI 192 | 193 | "(`SpatialThing`) The main place an agent is located, often an address where activities occur and mail can be sent. This is usually a mappable geographic location. It also could be a website address, as in the case of agents who have no physical location." 194 | primaryLocation: ID 195 | 196 | "References one or more concepts in a common taxonomy or other classification scheme for purposes of categorization or grouping." 197 | classifiedAs: [URI!] 198 | 199 | "A textual description or comment." 200 | note: String 201 | } 202 | 203 | input OrganizationUpdateParams { # implements UpdateParams & AgentParams 204 | id: ID! 205 | 206 | "An informal or formal textual identifier for an agent. Does not imply uniqueness." 207 | name: String 208 | 209 | "The uri to an image relevant to the agent, such as a logo, avatar, photo, etc." 210 | image: URI 211 | 212 | "(`SpatialThing`) The main place an agent is located, often an address where activities occur and mail can be sent. This is usually a mappable geographic location. It also could be a website address, as in the case of agents who have no physical location." 213 | primaryLocation: ID 214 | 215 | "References one or more concepts in a common taxonomy or other classification scheme for purposes of categorization or grouping." 216 | classifiedAs: [URI!] 217 | 218 | "A textual description or comment." 219 | note: String 220 | } 221 | 222 | type PersonResponse { 223 | agent: Person! 224 | } 225 | 226 | type OrganizationResponse { 227 | agent: Organization! 228 | } 229 | 230 | 231 | 232 | input AgentRelationshipCreateParams { # implements AgentRelationshipParams 233 | "(`Agent`) The subject of a relationship between 2 agents. For example, if Mary is a member of a group, then Mary is the subject." 234 | subject: ID! # Agent 235 | 236 | "(`Agent`) The object of a relationship between 2 agents. For example, if Mary is a member of a group, then the group is the object." 237 | object: ID! # Agent 238 | 239 | "(`AgentRelationshipRole`) The role of an economic relationship that exists between 2 agents, such as member, trading partner." 240 | relationship: ID! # AgentRelationshipRole 241 | 242 | "A textual description or comment." 243 | note: String 244 | } 245 | 246 | input AgentRelationshipUpdateParams { # implements UpdateParams & AgentRelationshipParams 247 | id: ID! 248 | 249 | "(`Agent`) The subject of a relationship between 2 agents. For example, if Mary is a member of a group, then Mary is the subject." 250 | subject: ID 251 | 252 | "(`Agent`) The object of a relationship between 2 agents. For example, if Mary is a member of a group, then the group is the object." 253 | object: ID 254 | 255 | "(`AgentRelationshipRole`) The role of an economic relationship that exists between 2 agents, such as member, trading partner." 256 | relationship: ID 257 | 258 | "A textual description or comment." 259 | note: String 260 | } 261 | 262 | type AgentRelationshipResponse { 263 | agentRelationship: AgentRelationship! 264 | } 265 | 266 | 267 | 268 | input AgentRelationshipRoleCreateParams { # implements AgentRelationshipRoleParams 269 | "The human readable name of the role, inverse from the object to the subject. For example, 'is member of'." 270 | roleLabel: String! 271 | 272 | "The human readable name of the role, inverse from the object to the subject. For example, 'has member'." 273 | inverseRoleLabel: String 274 | 275 | "A textual description or comment." 276 | note: String 277 | } 278 | 279 | input AgentRelationshipRoleUpdateParams { # implements UpdateParams & AgentRelationshipRoleParams 280 | id: ID! 281 | 282 | "The human readable name of the role, inverse from the object to the subject. For example, 'is member of'." 283 | roleLabel: String 284 | 285 | "The human readable name of the role, inverse from the object to the subject. For example, 'has member'." 286 | inverseRoleLabel: String 287 | 288 | "A textual description or comment." 289 | note: String 290 | } 291 | 292 | type AgentRelationshipRoleResponse { 293 | agentRelationshipRole: AgentRelationshipRole 294 | } 295 | 296 | type Query { 297 | "Loads details of the currently authenticated REA agent" 298 | myAgent: Agent 299 | 300 | "Find an agent (person or organization) by their ID" 301 | agent(id: ID): Agent 302 | "Loads all agents publicly registered within this collaboration space" 303 | agents(start: ID, limit: Int): [Agent!] 304 | 305 | "Find an organization (group) agent by its ID" 306 | organization(id: ID): Organization 307 | "Loads all organizations publicly registered within this collaboration space" 308 | organizations(start: ID, limit: Int): [Organization!] 309 | 310 | "Find a person by their ID" 311 | person(id: ID): Person 312 | "Loads all people who have publicly registered with this collaboration space." 313 | people(start: ID, limit: Int): [Person!] 314 | 315 | "Retrieve details of an agent relationship by its ID" 316 | agentRelationship(id: ID): AgentRelationship 317 | "Retrieve details of all the relationships between all agents registered in this collaboration space" 318 | agentRelationships(start: ID, limit: Int): [AgentRelationship!] 319 | "Retrieve details of an agent relationship role by its ID" 320 | agentRelationshipRole(id: ID): AgentRelationshipRole 321 | "Retrieve all possible kinds of associations that agents may have with one another in this collaboration space" 322 | agentRelationshipRoles(start: ID, limit: Int): [AgentRelationshipRole!] 323 | } 324 | 325 | type Mutation { 326 | "Registers a new (human) person with the collaboration space" 327 | createPerson(person: AgentCreateParams!): PersonResponse 328 | "Update profile details" 329 | updatePerson(person: AgentUpdateParams!): PersonResponse 330 | "Erase record of a person and thus remove them from the collaboration space" 331 | deletePerson(id: ID!): Boolean 332 | 333 | "Registers a new organization (group agent) with the collaboration space" 334 | createOrganization(organization: OrganizationCreateParams!): OrganizationResponse 335 | "Update organization profile details" 336 | updateOrganization(organization: OrganizationUpdateParams!): OrganizationResponse 337 | "Erase record of an organization and thus remove it from the collaboration space" 338 | deleteOrganization(id: ID!): Boolean 339 | 340 | createAgentRelationship(relationship: AgentRelationshipCreateParams!): AgentRelationshipResponse 341 | updateAgentRelationship(relationship: AgentRelationshipUpdateParams!): AgentRelationshipResponse 342 | deleteAgentRelationship(id: ID!): Boolean 343 | 344 | createAgentRelationshipRole(agentRelationshipRole: AgentRelationshipRoleCreateParams): AgentRelationshipRoleResponse 345 | updateAgentRelationshipRole(agentRelationshipRole: AgentRelationshipRoleUpdateParams): AgentRelationshipRoleResponse 346 | deleteAgentRelationshipRole(id: ID!): Boolean 347 | } 348 | -------------------------------------------------------------------------------- /lib/schemas/agreement.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Agreement module 4 | # 5 | # Simple module to manage shared agreements between agents in order for such 6 | # agreements to be referenced in actual commitments made. 7 | # 8 | # Often referenced by file upload functionality or similar for attaching 9 | # legal documents or more detailed information. 10 | # 11 | # @package vf-graphql 12 | # @since 2019-02-11 13 | # 14 | ## 15 | 16 | """ 17 | Any type of agreement among economic agents. 18 | """ 19 | type Agreement { 20 | id: ID! 21 | 22 | "An informal or formal textual identifier for an agreement. Does not imply uniqueness." 23 | name: String 24 | 25 | "The date and time the agreement was created." 26 | created: DateTime 27 | 28 | "A textual description or comment." 29 | note: String 30 | } 31 | 32 | 33 | 34 | input AgreementCreateParams { # implements AgreementParams 35 | "An informal or formal textual identifier for an agreement. Does not imply uniqueness." 36 | name: String! 37 | 38 | "The date and time the agreement was created." 39 | created: DateTime! 40 | 41 | "A textual description or comment." 42 | note: String 43 | } 44 | 45 | input AgreementUpdateParams { # implements UpdateParams & AgreementParams 46 | id: ID! 47 | 48 | "An informal or formal textual identifier for an agreement. Does not imply uniqueness." 49 | name: String 50 | 51 | "The date and time the agreement was created." 52 | created: DateTime 53 | 54 | "A textual description or comment." 55 | note: String 56 | } 57 | 58 | type AgreementResponse { 59 | agreement: Agreement 60 | } 61 | 62 | 63 | 64 | type Query { 65 | agreement(id: ID): Agreement 66 | agreements(start: ID, limit: Int): [Agreement!] 67 | } 68 | 69 | type Mutation { 70 | createAgreement(agreement: AgreementCreateParams): AgreementResponse 71 | updateAgreement(agreement: AgreementUpdateParams): AgreementResponse 72 | deleteAgreement(id: ID!): Boolean 73 | } 74 | -------------------------------------------------------------------------------- /lib/schemas/appreciation.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Appreciation module 4 | # 5 | # Allows linking EconomicEvents to indicate that some contribution was given in loose appreciation for another. 6 | # 7 | # @depends observation.gql 8 | # @package vf-graphql 9 | # @since 2019-02-11 10 | # 11 | ## 12 | 13 | """ 14 | A way to tie an economic event that is given in loose fulfilment for another economic event, without commitments or expectations. 15 | Supports the gift economy. 16 | """ 17 | type Appreciation { 18 | id: ID! 19 | 20 | "The economic event this appreciation has been given in acknowledgement of." 21 | appreciationOf: EconomicEvent! 22 | 23 | "The economic event provided as a gift in this appreciation." 24 | appreciationWith: EconomicEvent! 25 | 26 | "A textual description or comment." 27 | note: String 28 | } 29 | 30 | 31 | 32 | input AppreciationCreateParams { 33 | "(`EconomicEvent`) The economic event this appreciation has been given in acknowledgement of." 34 | appreciationOf: ID! 35 | 36 | "(`EconomicEvent`) The economic event provided as a gift in this appreciation." 37 | appreciationWith: ID! 38 | 39 | "A textual description or comment." 40 | note: String 41 | } 42 | 43 | input AppreciationUpdateParams { 44 | id: ID! 45 | 46 | "(`EconomicEvent`) The economic event this appreciation has been given in acknowledgement of." 47 | appreciationOf: ID 48 | 49 | "(`EconomicEvent`) The economic event provided as a gift in this appreciation." 50 | appreciationWith: ID 51 | 52 | "A textual description or comment." 53 | note: String 54 | } 55 | 56 | type AppreciationResponse { 57 | appreciation: Appreciation 58 | } 59 | 60 | 61 | 62 | type Mutation { 63 | createAppreciation(appreciation: AppreciationCreateParams!): AppreciationResponse 64 | updateAppreciation(appreciation: AppreciationUpdateParams!): AppreciationResponse 65 | deleteAppreciation(id: ID!): Boolean 66 | } 67 | -------------------------------------------------------------------------------- /lib/schemas/bridging/agent.agreement.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Agent <> Agreement query API 4 | # 5 | # Provides information about the agents involved in agreements. 6 | # 7 | # @package HoloREA 8 | # @author pospi 9 | # @since 2020-02-12 10 | # 11 | ## 12 | 13 | type Agreement { 14 | involvedAgents: [Agent!] 15 | } 16 | -------------------------------------------------------------------------------- /lib/schemas/bridging/agent.geolocation.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Location <> Agent query indexes 4 | # 5 | # @package vf-graphql 6 | # @since 2020-02-12 7 | # 8 | ## 9 | 10 | interface Agent { 11 | "The main place an agent is located, often an address where activities occur and mail can be sent. This is usually a mappable geographic location. It also could be a website address, as in the case of agents who have no physical location." 12 | primaryLocation: SpatialThing 13 | } 14 | 15 | type Person implements Agent { 16 | "The main place an agent is located, often an address where activities occur and mail can be sent. This is usually a mappable geographic location. It also could be a website address, as in the case of agents who have no physical location." 17 | primaryLocation: SpatialThing 18 | } 19 | 20 | type Organization implements Agent { 21 | "The main place an agent is located, often an address where activities occur and mail can be sent. This is usually a mappable geographic location. It also could be a website address, as in the case of agents who have no physical location." 22 | primaryLocation: SpatialThing 23 | } 24 | 25 | type SpatialThing { 26 | agents: [Agent!] 27 | } 28 | -------------------------------------------------------------------------------- /lib/schemas/bridging/agent.observation.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Agent <> Observation API 4 | # 5 | # Queries & related to observation-level data exposed within an agent context, 6 | # and identifiers linking Agents to observation record types. 7 | # 8 | # @package vf-graphql 9 | # @since 2020-02-11 10 | # 11 | ## 12 | 13 | type EconomicEvent { 14 | "The economic agent from whom the actual economic event is initiated." 15 | provider: Agent! 16 | 17 | "The economic agent whom the actual economic event is for." 18 | receiver: Agent! 19 | } 20 | 21 | type EconomicResource { 22 | "The agent currently with primary rights and responsibilites for the economic resource. It is the agent that is associated with the accountingQuantity of the economic resource." 23 | primaryAccountable: Agent 24 | } 25 | 26 | type Process { 27 | workingAgents: [Agent!] 28 | } 29 | 30 | 31 | input EconomicEventCreateParams { 32 | "(`Agent`) The economic agent from whom the actual economic event is initiated." 33 | provider: ID! 34 | 35 | "(`Agent`) The economic agent whom the actual economic event is for." 36 | receiver: ID! 37 | } 38 | 39 | 40 | "Query parameters for reading `EconomicEvent`s related to an `Agent`" 41 | input agentEventSearchParams { 42 | searchString: String 43 | action: ID 44 | startDate: DateTime 45 | endDate: DateTime 46 | } 47 | 48 | "Query parameters for reading `EconomicResource`s related to an `Agent`" 49 | input agentResourceSearchParams { 50 | searchString: String 51 | resourceClassification: URI 52 | page: Int 53 | } 54 | 55 | "Query parameters for reading `Process`es related to an `Agent`" 56 | input agentProcessSearchParams { 57 | searchString: String 58 | finished: Boolean 59 | } 60 | 61 | interface Agent { 62 | economicEvents(filter: agentEventSearchParams): [EconomicEvent!] 63 | inventoriedEconomicResources(filter: agentResourceSearchParams): [EconomicResource!] 64 | processes(filter: agentProcessSearchParams): [Process!] 65 | } 66 | 67 | type Person implements Agent { 68 | economicEvents(filter: agentEventSearchParams): [EconomicEvent!] 69 | inventoriedEconomicResources(filter: agentResourceSearchParams): [EconomicResource!] 70 | processes(filter: agentProcessSearchParams): [Process!] 71 | } 72 | 73 | type Organization implements Agent { 74 | economicEvents(filter: agentEventSearchParams): [EconomicEvent!] 75 | inventoriedEconomicResources(filter: agentResourceSearchParams): [EconomicResource!] 76 | processes(filter: agentProcessSearchParams): [Process!] 77 | } 78 | -------------------------------------------------------------------------------- /lib/schemas/bridging/agent.plan.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Agent <> Plan API 4 | # 5 | # Provides information about the relationships between agents and plans. 6 | # 7 | # @package vf-graphql 8 | # @since 2020-02-11 9 | # 10 | ## 11 | 12 | "Query parameters for reading `Plan`s related to an `Agent`" 13 | input agentPlanSearchParams { 14 | searchString: String 15 | finished: Boolean 16 | } 17 | 18 | interface Agent { 19 | plans(filter: agentPlanSearchParams): [Plan!] 20 | } 21 | 22 | type Person implements Agent { 23 | plans(filter: agentPlanSearchParams): [Plan!] 24 | } 25 | 26 | type Organization implements Agent { 27 | plans(filter: agentPlanSearchParams): [Plan!] 28 | } 29 | -------------------------------------------------------------------------------- /lib/schemas/bridging/agent.planning.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Agent <> Planning API 4 | # 5 | # Queries related to planning-level data exposed within an agent context, 6 | # and identifiers linking Agents to planning record types. 7 | # 8 | # @package vf-graphql 9 | # @since 2020-02-11 10 | # 11 | ## 12 | 13 | type Intent { 14 | "The economic agent from whom the intent is initiated. This implies that the intent is an offer." 15 | provider: Agent 16 | 17 | "The economic agent whom the intent is for. This implies that the intent is a request." 18 | receiver: Agent 19 | } 20 | 21 | type Commitment { 22 | "The economic agent from whom the commitment is initiated." 23 | provider: Agent! 24 | 25 | "The economic agent whom the commitment is for." 26 | receiver: Agent! 27 | 28 | ############################################################################## 29 | # inverse relationships and queries 30 | 31 | involvedAgents: [Agent!] 32 | } 33 | 34 | 35 | input IntentCreateParams { 36 | "(`Agent`) The economic agent from whom the intent is initiated. This implies that the intent is an offer." 37 | provider: ID 38 | 39 | "(`Agent`) The economic agent whom the intent is for. This implies that the intent is a request." 40 | receiver: ID 41 | } 42 | 43 | input IntentUpdateParams { 44 | "(`Agent`) The economic agent from whom the intent is initiated. This implies that the intent is an offer." 45 | provider: ID 46 | 47 | "(`Agent`) The economic agent whom the intent is for. This implies that the intent is a request." 48 | receiver: ID 49 | } 50 | 51 | input CommitmentCreateParams { 52 | "(`Agent`) The economic agent from whom the commitment is initiated." 53 | provider: ID! 54 | 55 | "(`Agent`) The economic agent whom the commitment is for." 56 | receiver: ID! 57 | } 58 | 59 | input CommitmentUpdateParams { 60 | "(`Agent`) The economic agent from whom the commitment is initiated." 61 | provider: ID 62 | 63 | "(`Agent`) The economic agent whom the commitment is for." 64 | receiver: ID 65 | } 66 | 67 | 68 | "Query parameters for reading `Commitment`s related to an `Agent`" 69 | input agentCommitmentSearchParams { 70 | searchString: String 71 | action: ID 72 | startDate: DateTime 73 | endDate: DateTime 74 | finished: Boolean 75 | } 76 | 77 | "Query parameters for reading `Intent`s related to an `Agent`" 78 | input agentIntentSearchParams { 79 | searchString: String 80 | action: ID 81 | startDate: DateTime 82 | endDate: DateTime 83 | finished: Boolean 84 | } 85 | 86 | interface Agent { 87 | commitments(filter: agentCommitmentSearchParams): [Commitment!] 88 | intents(filter: agentIntentSearchParams): [Intent!] 89 | } 90 | 91 | type Person implements Agent { 92 | commitments(filter: agentCommitmentSearchParams): [Commitment!] 93 | intents(filter: agentIntentSearchParams): [Intent!] 94 | } 95 | 96 | type Organization implements Agent { 97 | commitments(filter: agentCommitmentSearchParams): [Commitment!] 98 | intents(filter: agentIntentSearchParams): [Intent!] 99 | } 100 | -------------------------------------------------------------------------------- /lib/schemas/bridging/knowledge.observation.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Knowledge <> Observation indexes 4 | # 5 | # Provides search intelligence for Observation module records via the 6 | # Knowledge module, enabling type-based queries. 7 | # 8 | # @package vf-graphql 9 | # @since 2020-02-12 10 | # 11 | ## 12 | 13 | type ResourceSpecification { 14 | conformingResources: [EconomicResource!] 15 | } 16 | -------------------------------------------------------------------------------- /lib/schemas/bridging/observation.agreement.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Observation <> Agreement API 4 | # 5 | # Augments EconomicEvent with properties that link events to Agreements 6 | # which have governed the execution of those events. 7 | # 8 | # @package vf-graphql 9 | # @since 2020-02-12 10 | # 11 | ## 12 | 13 | type EconomicEvent { 14 | "This economic event occurs as part of this agreement." 15 | realizationOf: Agreement 16 | } 17 | 18 | type Agreement { 19 | economicEvents: [EconomicEvent!] 20 | } 21 | -------------------------------------------------------------------------------- /lib/schemas/bridging/observation.appreciation.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Observation <> Appreciation indexes 4 | # 5 | # Augments EconomicEvent with read-only fields for retrieving reciprocal events. 6 | # 7 | # @package vf-graphql 8 | # @since 2020-02-12 9 | # 10 | ## 11 | 12 | type EconomicEvent { 13 | appreciationOf: [Appreciation!] 14 | appreciatedBy: [Appreciation!] 15 | } 16 | -------------------------------------------------------------------------------- /lib/schemas/bridging/observation.geolocation.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Observation <> Geolocation API 4 | # 5 | # Augments records of real-world resources and observations with geospatial information. 6 | # 7 | # @package vf-graphql 8 | # @since 2020-02-12 9 | # 10 | ## 11 | 12 | type EconomicEvent { 13 | "The place where an economic event occurs. Usually mappable." 14 | atLocation: SpatialThing 15 | } 16 | 17 | type EconomicResource { 18 | "The current place an economic resource is located. Could be at any level of granularity, from a town to an address to a warehouse location. Usually mappable." 19 | currentLocation: SpatialThing 20 | } 21 | 22 | type SpatialThing { 23 | economicResources: [EconomicResource!] 24 | economicEvents: [EconomicEvent!] 25 | } 26 | -------------------------------------------------------------------------------- /lib/schemas/bridging/observation.plan.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Observation <> Plan API 4 | # 5 | # Augments observation records with the ability to be referenced in Plans. 6 | # 7 | # @package vf-graphql 8 | # @since 2020-02-12 9 | # 10 | ## 11 | 12 | type Process { 13 | "The process with its inputs and outputs is part of the plan." 14 | plannedWithin: Plan 15 | } 16 | 17 | "Query parameters for reading `Process`es related to a `Plan`" 18 | input planProcessSearchParams { 19 | searchString: String 20 | after: DateTime 21 | before: DateTime 22 | finished: Boolean 23 | } 24 | 25 | type Plan { 26 | processes(filter: planProcessSearchParams): [Process!] 27 | } 28 | -------------------------------------------------------------------------------- /lib/schemas/bridging/observation.planning.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Observation <> Planning indexes 4 | # 5 | # Provides linkage between the observation and planning spaces within 6 | # economic networks. 7 | # 8 | # @package vf-graphql 9 | # @since 2020-02-12 10 | # 11 | ## 12 | 13 | type EconomicEvent { 14 | "The commitment which is completely or partially fulfilled by an economic event." 15 | fulfills: [Fulfillment!] 16 | 17 | "An intent satisfied fully or partially by an economic event or commitment." 18 | satisfies: [Satisfaction!] 19 | } 20 | 21 | type Process { 22 | committedInputs(action: ID): [Commitment!] 23 | committedOutputs(action: ID): [Commitment!] 24 | 25 | intendedInputs(action: ID): [Intent!] 26 | intendedOutputs(action: ID): [Intent!] 27 | } 28 | -------------------------------------------------------------------------------- /lib/schemas/bridging/observation.scenario.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Observation <> Scenario API 4 | # 5 | # Augments observation records with the ability to be referenced in Scenarios. 6 | # 7 | # @package vf-graphql 8 | # @since 2020-02-12 9 | # 10 | ## 11 | 12 | type Process { 13 | "The process with its inputs and outputs is part of the scenario." 14 | nestedIn: Scenario 15 | } 16 | -------------------------------------------------------------------------------- /lib/schemas/bridging/planning.agreement.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Planning <> Agreement API 4 | # 5 | # Augments planning records with properties that link events to Agreements 6 | # which have influenced the planning process. 7 | # 8 | # @package vf-graphql 9 | # @since 2020-02-12 10 | # 11 | ## 12 | 13 | type Commitment { 14 | "This commitment is part of the exchange agreement." 15 | clauseOf: Agreement 16 | } 17 | 18 | type Agreement { 19 | commitments: [Commitment!] 20 | } 21 | -------------------------------------------------------------------------------- /lib/schemas/bridging/planning.geolocation.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Planning <> Geolocation API 4 | # 5 | # Augments records of planned events with geospatial information. 6 | # 7 | # @package vf-graphql 8 | # @since 2020-02-12 9 | # 10 | ## 11 | 12 | type Commitment { 13 | "The place where a commitment occurs. Usually mappable." 14 | atLocation: SpatialThing 15 | } 16 | 17 | type Intent { 18 | "The place where an intent would occur. Usually mappable." 19 | atLocation: SpatialThing 20 | } 21 | 22 | type SpatialThing { 23 | commitments: [Commitment!] 24 | intents: [Intent!] 25 | } 26 | -------------------------------------------------------------------------------- /lib/schemas/bridging/planning.plan.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Planning <> Plan API 4 | # 5 | # Augments commitments with the ability to be referenced in Plans. 6 | # 7 | # @package vf-graphql 8 | # @since 2020-02-12 9 | # 10 | ## 11 | 12 | type Commitment { 13 | "Represents a desired deliverable expected from this plan." 14 | independentDemandOf: Plan 15 | } 16 | 17 | type Plan { 18 | independentDemands: [Commitment!] 19 | } 20 | -------------------------------------------------------------------------------- /lib/schemas/bridging/planning.proposal.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Planning <> Proposal indexes 4 | # 5 | # Enables traversing Intent links into related Proposal modules. 6 | # 7 | # @package vf-graphql 8 | # @since 2020-02-12 9 | # 10 | ## 11 | 12 | type Intent { 13 | publishedIn: [ProposedIntent!] 14 | } 15 | -------------------------------------------------------------------------------- /lib/schemas/bridging/proposal.agent.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Proposal-related functionality that interacts with Agents 4 | # 5 | # Allows flagging Proposals for interest by agents who have an interest in 6 | # completing them. 7 | # 8 | # @package Holo-REA 9 | # @since 2020-06-03 10 | # 11 | ## 12 | 13 | type Proposal { 14 | publishedTo: [ProposedTo!] 15 | } 16 | 17 | """ 18 | An agent to which the proposal is to be published. A proposal can be published to many agents. 19 | """ 20 | type ProposedTo { 21 | id: ID! 22 | 23 | "The agent to which the proposal is published." 24 | proposedTo: Agent! 25 | 26 | "The proposal that is published to a specific agent." 27 | proposed: Proposal! 28 | } 29 | 30 | type ProposedToResponse { 31 | proposedTo: ProposedTo 32 | } 33 | 34 | type Mutation { 35 | """ 36 | Send a proposal to another agent. 37 | @param proposed the (`Proposal`) to send to an involved agent 38 | @param proposedTo the (`Agent`) to include in the proposal 39 | """ 40 | proposeTo(proposed: ID!, proposedTo: ID!): ProposedToResponse 41 | deleteProposedTo(id: ID!): Boolean 42 | } 43 | -------------------------------------------------------------------------------- /lib/schemas/bridging/proposal.geolocation.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Proposal <> Geolocation API 4 | # 5 | # Augments proposals with geospatial information. 6 | # 7 | # @package vf-graphql 8 | # @since 2020-02-12 9 | # 10 | ## 11 | 12 | type Proposal { 13 | "Location or area where the proposal is valid." 14 | eligibleLocation: SpatialThing 15 | } 16 | -------------------------------------------------------------------------------- /lib/schemas/claim.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Claim module 4 | # 5 | # Facilitates claiming of future events in return for contributions already given. 6 | # 7 | # @depends measurement.gql 8 | # @depends knowledge.gql 9 | # @depends observation.gql 10 | # @package vf-graphql 11 | # @since 2019-02-11 12 | # 13 | ## 14 | 15 | """ 16 | A claim for a future economic event(s) in reciprocity for an economic event that already occurred. For example, a claim for payment for goods received. 17 | """ 18 | type Claim { 19 | id: ID! 20 | 21 | "Relates a claim to a verb, such as consume, produce, work, improve, etc." 22 | action: Action! 23 | 24 | "References a concept in a common taxonomy or other classification scheme for purposes of categorization or grouping." 25 | resourceClassifiedAs: [URI!] 26 | 27 | "The primary resource specification or definition of an existing or potential economic resource. A resource will have only one, as this specifies exactly what the resource is." 28 | resourceConformsTo: ResourceSpecification 29 | 30 | "The amount and unit of the economic resource counted or inventoried." 31 | resourceQuantity: Measure 32 | 33 | "The amount and unit of the work or use or citation effort-based action. This is often a time duration, but also could be cycle counts or other measures of effort or usefulness." 34 | effortQuantity: Measure 35 | 36 | "The economic event which already occurred which this claim has been made against." 37 | triggeredBy: EconomicEvent! 38 | 39 | "The time the claim is expected to be settled." 40 | due: DateTime 41 | 42 | "The data on which the claim was made." 43 | created: DateTime 44 | 45 | "The claim is complete or not. This is irrespective of if the original goal has been met, and indicates that no more will be done." 46 | finished: Boolean 47 | 48 | "A textual description or comment." 49 | note: String 50 | 51 | "Reference to an agreement between agents which specifies the rules or policies or calculations which govern this claim." 52 | agreedIn: URI 53 | 54 | "Grouping around something to create a boundary or context, used for documenting, accounting, planning." 55 | inScopeOf: [AccountingScope!] 56 | } 57 | 58 | """ 59 | Represents many-to-many relationships between claim and economic events that fully or partially settle one or more claims. 60 | """ 61 | type Settlement { 62 | id: ID! 63 | 64 | "A claim which is fully or partially settled by an economic event." 65 | settles: Claim! 66 | 67 | "The economic event fully or partially settling a claim." 68 | settledBy: EconomicEvent! 69 | 70 | "The amount and unit of the economic resource counted or inventoried." 71 | resourceQuantity: Measure 72 | 73 | "The amount and unit of the work or use or citation effort-based action. This is often a time duration, but also could be cycle counts or other measures of effort or usefulness." 74 | effortQuantity: Measure 75 | 76 | "A textual description or comment." 77 | note: String 78 | } 79 | 80 | 81 | 82 | input ClaimCreateParams { 83 | "(`Action`) Relates a claim to a verb, such as consume, produce, work, improve, etc." 84 | action: ID! 85 | 86 | "References a concept in a common taxonomy or other classification scheme for purposes of categorization or grouping." 87 | resourceClassifiedAs: [URI!] 88 | 89 | "(`ResourceSpecification`) The primary resource specification or definition of an existing or potential economic resource. A resource will have only one, as this specifies exactly what the resource is." 90 | resourceConformsTo: ID 91 | 92 | "The amount and unit of the economic resource counted or inventoried." 93 | resourceQuantity: IMeasure 94 | 95 | "The amount and unit of the work or use or citation effort-based action. This is often a time duration, but also could be cycle counts or other measures of effort or usefulness." 96 | effortQuantity: IMeasure 97 | 98 | "The time the claim is expected to be settled." 99 | due: DateTime 100 | 101 | "(`EconomicEvent`) The economic event which already occurred which this claim has been made against." 102 | triggeredBy: ID 103 | 104 | "The data on which the claim was made." 105 | created: DateTime 106 | 107 | "The claim is complete or not. This is irrespective of if the original goal has been met, and indicates that no more will be done." 108 | finished: Boolean 109 | 110 | "A textual description or comment." 111 | note: String 112 | 113 | "Reference to an agreement between agents which specifies the rules or policies or calculations which govern this claim." 114 | agreedIn: URI 115 | 116 | "Grouping around something to create a boundary or context, used for documenting, accounting, planning." 117 | inScopeOf: [ID!] 118 | } 119 | 120 | input ClaimUpdateParams { 121 | id: ID! 122 | 123 | "(`Action`) Relates a claim to a verb, such as consume, produce, work, improve, etc." 124 | action: ID 125 | 126 | "References a concept in a common taxonomy or other classification scheme for purposes of categorization or grouping." 127 | resourceClassifiedAs: [URI!] 128 | 129 | "(`ResourceSpecification`) The primary resource specification or definition of an existing or potential economic resource. A resource will have only one, as this specifies exactly what the resource is." 130 | resourceConformsTo: ID 131 | 132 | "The amount and unit of the economic resource counted or inventoried." 133 | resourceQuantity: IMeasure 134 | 135 | "The amount and unit of the work or use or citation effort-based action. This is often a time duration, but also could be cycle counts or other measures of effort or usefulness." 136 | effortQuantity: IMeasure 137 | 138 | "The time the claim is expected to be settled." 139 | due: DateTime 140 | 141 | "(`EconomicEvent`) The economic event which already occurred which this claim has been made against." 142 | triggeredBy: ID 143 | 144 | "The data on which the claim was made." 145 | created: DateTime 146 | 147 | "The claim is complete or not. This is irrespective of if the original goal has been met, and indicates that no more will be done." 148 | finished: Boolean 149 | 150 | "A textual description or comment." 151 | note: String 152 | 153 | "Reference to an agreement between agents which specifies the rules or policies or calculations which govern this claim." 154 | agreedIn: URI 155 | 156 | "Grouping around something to create a boundary or context, used for documenting, accounting, planning." 157 | inScopeOf: [ID!] 158 | } 159 | 160 | type ClaimResponse { 161 | claim: Claim 162 | } 163 | 164 | 165 | 166 | input SettlementCreateParams { 167 | "(`Claim`) A claim which is fully or partially settled by an economic event." 168 | settles: ID! 169 | 170 | "(`EconomicEvent`) The economic event fully or partially settling a claim." 171 | settledBy: ID! 172 | 173 | "The amount and unit of the economic resource counted or inventoried." 174 | resourceQuantity: IMeasure 175 | 176 | "The amount and unit of the work or use or citation effort-based action. This is often a time duration, but also could be cycle counts or other measures of effort or usefulness." 177 | effortQuantity: IMeasure 178 | 179 | "A textual description or comment." 180 | note: String 181 | } 182 | 183 | input SettlementUpdateParams { 184 | id: ID! 185 | 186 | "(`Claim`) A claim which is fully or partially settled by an economic event." 187 | settles: ID 188 | 189 | "(`EconomicEvent`) The economic event fully or partially settling a claim." 190 | settledBy: ID 191 | 192 | "The amount and unit of the economic resource counted or inventoried." 193 | resourceQuantity: IMeasure 194 | 195 | "The amount and unit of the work or use or citation effort-based action. This is often a time duration, but also could be cycle counts or other measures of effort or usefulness." 196 | effortQuantity: IMeasure 197 | 198 | "A textual description or comment." 199 | note: String 200 | } 201 | 202 | type SettlementResponse { 203 | settlement: Settlement 204 | } 205 | 206 | 207 | 208 | type Query { 209 | claim(id: ID): Claim 210 | claims(start: ID, limit: Int): [Claim!] 211 | 212 | settlement(id: ID): Settlement 213 | settlements(start: ID, limit: Int): [Settlement!] 214 | } 215 | 216 | type Mutation { 217 | createClaim(claim: ClaimCreateParams!): ClaimResponse 218 | updateClaim(claim: ClaimUpdateParams!): ClaimResponse 219 | deleteClaim(id: ID!): Boolean 220 | 221 | createSettlement(settlement: SettlementCreateParams!): SettlementResponse 222 | updateSettlement(s0ettlement: SettlementUpdateParams!): SettlementResponse 223 | deleteSettlement(id: ID!): Boolean 224 | } 225 | -------------------------------------------------------------------------------- /lib/schemas/geolocation.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Geolocation module 4 | # 5 | # Defines a generic data structure to represent a physical location 6 | # 7 | # @package vf-graphql 8 | # @since 2019-02-11 9 | # 10 | ## 11 | 12 | """ 13 | A physical mappable location. 14 | """ 15 | type SpatialThing { 16 | id: ID! 17 | 18 | "An informal or formal textual identifier for a location. Does not imply uniqueness." 19 | name: String! 20 | 21 | "An address that will be recognized as mappable by mapping software." 22 | mappableAddress: String 23 | 24 | "Latitude." 25 | lat: Float 26 | 27 | "Longitude." 28 | long: Float 29 | 30 | "Altitude." 31 | alt: Float 32 | 33 | "A textual description or comment." 34 | note: String 35 | } 36 | 37 | 38 | 39 | input SpatialThingCreateParams { 40 | "An informal or formal textual identifier for a location. Does not imply uniqueness." 41 | name: String! 42 | 43 | "An address that will be recognized as mappable by mapping software." 44 | mappableAddress: String 45 | 46 | "Latitude." 47 | lat: Float 48 | 49 | "Longitude." 50 | long: Float 51 | 52 | "Altitude." 53 | alt: Float 54 | 55 | "A textual description or comment." 56 | note: String 57 | } 58 | 59 | input SpatialThingUpdateParams { 60 | id: ID! 61 | 62 | "An informal or formal textual identifier for a location. Does not imply uniqueness." 63 | name: String 64 | 65 | "An address that will be recognized as mappable by mapping software." 66 | mappableAddress: String 67 | 68 | "Latitude." 69 | lat: Float 70 | 71 | "Longitude." 72 | long: Float 73 | 74 | "Altitude." 75 | alt: Float 76 | 77 | "A textual description or comment." 78 | note: String 79 | } 80 | 81 | type SpatialThingResponse { 82 | spatialThing: SpatialThing 83 | } 84 | 85 | 86 | 87 | type Query { 88 | spatialThing(id: ID): SpatialThing 89 | spatialThings(start: ID, limit: Int): [SpatialThing!] 90 | } 91 | 92 | type Mutation { 93 | createSpatialThing(spatialThing: SpatialThingCreateParams!): SpatialThingResponse 94 | updateSpatialThing(spatialThing: SpatialThingUpdateParams!): SpatialThingResponse 95 | deleteSpatialThing(id: ID!): Boolean 96 | } 97 | -------------------------------------------------------------------------------- /lib/schemas/knowledge.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Knowledge module 4 | # 5 | # Provides functionality for classifying and organising other parts of the system, including recipes. 6 | # 7 | # @depends measurement.gql 8 | # @package vf-graphql 9 | # @since 2019-02-11 10 | # 11 | ## 12 | 13 | 14 | """ 15 | An action verb defining the kind of event, commitment, or intent. 16 | It is recommended that the lowercase action verb should be used as the record ID 17 | in order that references to `Action`s elsewhere in the system are easily readable. 18 | """ 19 | type Action { 20 | id: ID! 21 | 22 | "A unique verb which defines the action." 23 | label: String! 24 | 25 | "The accounting effect of an economic event on a resource, increment, decrement, no effect, or decrement resource and increment 'to' resource." 26 | resourceEffect: String! # "increment", "decrement", "noEffect", "decrementIncrement" 27 | 28 | "The onhand effect of an economic event on a resource, increment, decrement, no effect, or decrement resource and increment 'to' resource." 29 | onhandEffect: String! # "increment", "decrement", "noEffect", "decrementIncrement" 30 | 31 | "Denotes if a process input or output, or not related to a process." 32 | inputOutput: String # "input", "output", "notApplicable" 33 | 34 | "The action that should be included on the other direction of the process, for example accept with modify." 35 | pairsWith: String # "notApplicable", (any of the action labels) 36 | } 37 | 38 | # Core VF action IDs & `resourceEffect`s: 39 | # @see https://valueflo.ws/introduction/flows.html#actions 40 | 41 | """ 42 | Specification of a kind of resource. Could define a material item, service, digital item, currency account, etc. 43 | Used instead of a classification when more information is needed, particularly for recipes. 44 | """ 45 | type ResourceSpecification { 46 | id: ID! 47 | 48 | "An informal or formal textual identifier for a type of resource. Does not imply uniqueness." 49 | name: String! 50 | 51 | "The uri to an image relevant to the entity, such as a photo, diagram, etc." 52 | image: URI 53 | 54 | "References a concept in a common taxonomy or other classification scheme for purposes of categorization or grouping." 55 | resourceClassifiedAs: [URI!] 56 | 57 | "A textual description or comment." 58 | note: String 59 | 60 | "The default unit used for the resource itself." 61 | defaultUnitOfResource: Unit 62 | 63 | "The default unit used for use or work." 64 | defaultUnitOfEffort: Unit 65 | } 66 | 67 | """ 68 | Specifies the kind of process. 69 | """ 70 | type ProcessSpecification { 71 | id: ID! 72 | 73 | "An informal or formal textual identifier for the process. Does not imply uniqueness." 74 | name: String! 75 | 76 | "A textual description or comment." 77 | note: String 78 | } 79 | 80 | 81 | 82 | input ResourceSpecificationCreateParams { 83 | "An informal or formal textual identifier for a type of resource. Does not imply uniqueness." 84 | name: String! 85 | 86 | "The uri to an image relevant to the entity, such as a photo, diagram, etc." 87 | image: URI 88 | 89 | "References a concept in a common taxonomy or other classification scheme for purposes of categorization or grouping." 90 | resourceClassifiedAs: [URI!] 91 | 92 | "A textual description or comment." 93 | note: String 94 | 95 | "(`Unit`) The default unit used for the resource itself." 96 | defaultUnitOfResource: ID 97 | 98 | "(`Unit`) The default unit used for use or work." 99 | defaultUnitOfEffort: ID 100 | } 101 | 102 | input ResourceSpecificationUpdateParams { 103 | id: ID! 104 | 105 | "An informal or formal textual identifier for a type of resource. Does not imply uniqueness." 106 | name: String 107 | 108 | "The uri to an image relevant to the entity, such as a photo, diagram, etc." 109 | image: URI 110 | 111 | "References a concept in a common taxonomy or other classification scheme for purposes of categorization or grouping." 112 | resourceClassifiedAs: [URI!] 113 | 114 | "A textual description or comment." 115 | note: String 116 | 117 | "(`Unit`) The default unit used for the resource itself." 118 | defaultUnitOfResource: ID 119 | 120 | "(`Unit`) The default unit used for use or work." 121 | defaultUnitOfEffort: ID 122 | } 123 | 124 | type ResourceSpecificationResponse { 125 | resourceSpecification: ResourceSpecification 126 | } 127 | 128 | 129 | 130 | input ProcessSpecificationCreateParams { 131 | "An informal or formal textual identifier for the process. Does not imply uniqueness." 132 | name: String! 133 | 134 | "A textual description or comment." 135 | note: String 136 | } 137 | 138 | input ProcessSpecificationUpdateParams { 139 | id: ID! 140 | 141 | "An informal or formal textual identifier for the process. Does not imply uniqueness." 142 | name: String 143 | 144 | "A textual description or comment." 145 | note: String 146 | } 147 | 148 | type ProcessSpecificationResponse { 149 | processSpecification: ProcessSpecification 150 | } 151 | 152 | 153 | 154 | type Query { 155 | action(id: ID): Action 156 | actions: [Action!] 157 | 158 | resourceSpecification(id: ID): ResourceSpecification 159 | resourceSpecifications(start: ID, limit: Int): [ResourceSpecification!] 160 | 161 | processSpecification(id: ID): ProcessSpecification 162 | processSpecifications(start: ID, limit: Int): [ProcessSpecification!] 163 | } 164 | 165 | type Mutation { 166 | createResourceSpecification(resourceSpecification: ResourceSpecificationCreateParams): ResourceSpecificationResponse 167 | updateResourceSpecification(resourceSpecification: ResourceSpecificationUpdateParams): ResourceSpecificationResponse 168 | deleteResourceSpecification(id: ID!): Boolean 169 | 170 | createProcessSpecification(processSpecification: ProcessSpecificationCreateParams): ProcessSpecificationResponse 171 | updateProcessSpecification(processSpecification: ProcessSpecificationUpdateParams): ProcessSpecificationResponse 172 | deleteProcessSpecification(id: ID!): Boolean 173 | } 174 | -------------------------------------------------------------------------------- /lib/schemas/measurement.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Measurement module 4 | # 5 | # Typedefs used for defining and representing measurements 6 | # in the real (physical) world. 7 | # 8 | # @package vf-graphql 9 | # @since 2019-02-11 10 | # 11 | ## 12 | 13 | """ 14 | Defines the unit of time measured in a temporal `Duration`. 15 | """ 16 | enum TimeUnit { 17 | year, month, week, day, hour, minute, second 18 | } 19 | 20 | """ 21 | A `Duration` represents an interval between two `DateTime` values. 22 | """ 23 | type Duration { 24 | "A number representing the duration, will be paired with a unit." 25 | numericDuration: Float! 26 | 27 | "A unit of measure." 28 | unitType: TimeUnit! 29 | } 30 | 31 | """ 32 | Mutation input structure for defining time durations. 33 | """ 34 | input IDuration { 35 | "A number representing the duration, will be paired with a unit." 36 | numericDuration: Float! 37 | 38 | "A unit of measure." 39 | unitType: TimeUnit! 40 | } 41 | 42 | 43 | 44 | """ 45 | Defines a unit of measurement, along with its display symbol. 46 | From OM2 vocabulary. 47 | """ 48 | type Unit { 49 | id: ID! 50 | 51 | "A human readable label for the unit, can be language specific." 52 | label: String! 53 | 54 | "A standard display symbol for a unit of measure." 55 | symbol: String! 56 | } 57 | 58 | 59 | 60 | """ 61 | Semantic meaning for measurements: binds a quantity to its measurement unit. 62 | See http://www.qudt.org/pages/QUDToverviewPage.html 63 | """ 64 | type Measure { 65 | "A number representing the quantity, will be paired with a unit." 66 | hasNumericalValue: Float! 67 | 68 | "A unit of measure." 69 | hasUnit: Unit 70 | } 71 | 72 | """ 73 | Mutation input structure for defining measurements. Should be nulled if not present, rather than empty. 74 | """ 75 | input IMeasure { 76 | "A number representing the quantity, will be paired with a unit." 77 | hasNumericalValue: Float! 78 | 79 | "(`Unit`) A unit of measure." 80 | hasUnit: ID 81 | } 82 | 83 | 84 | 85 | input UnitCreateParams { 86 | "A human readable label for the unit, can be language specific." 87 | label: String! 88 | 89 | "A standard display symbol for a unit of measure." 90 | symbol: String! 91 | } 92 | 93 | input UnitUpdateParams { 94 | id: ID! 95 | 96 | "A human readable label for the unit, can be language specific." 97 | label: String 98 | 99 | "A standard display symbol for a unit of measure." 100 | symbol: String 101 | } 102 | 103 | type UnitResponse { 104 | unit: Unit 105 | } 106 | 107 | 108 | 109 | type Query { 110 | unit(id: ID): Unit 111 | units(start: ID, limit: Int): [Unit!] 112 | } 113 | 114 | type Mutation { 115 | createUnit(unit: UnitCreateParams): UnitResponse 116 | updateUnit(unit: UnitUpdateParams): UnitResponse 117 | deleteUnit(id: ID!): Boolean 118 | } 119 | -------------------------------------------------------------------------------- /lib/schemas/observation.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Observation module 4 | # 5 | # Record of what actually happened affecting the economic ecosystem. 6 | # 7 | # @depends measurement.gql 8 | # @depends knowledge.gql 9 | # @package vf-graphql 10 | # @since 2019-02-11 11 | # 12 | ## 13 | 14 | union ProductionFlowItem = Process | EconomicResource 15 | 16 | """ 17 | An observed economic flow, as opposed to a flow planned to happen in the future. This could reflect a change in the quantity of an economic resource. It is also defined by its behavior in relation to the economic resource (see `Action`) 18 | """ 19 | type EconomicEvent { 20 | id: ID! 21 | 22 | "Relates an economic event to a verb, such as consume, produce, work, improve, etc." 23 | action: Action! 24 | 25 | "Defines the process to which this event is an input." 26 | inputOf: Process 27 | 28 | "Defines the process for which this event is an output." 29 | outputOf: Process 30 | 31 | "Economic resource involved in the economic event." 32 | resourceInventoriedAs: EconomicResource 33 | 34 | "Additional economic resource on the economic event when needed by the receiver. Used when a transfer or move, or sometimes other actions, requires explicitly identifying an economic resource on the receiving side." 35 | toResourceInventoriedAs: EconomicResource 36 | 37 | "References a concept in a common taxonomy or other classification scheme for purposes of categorization or grouping." 38 | resourceClassifiedAs: [URI!] 39 | 40 | "The primary resource specification or definition of an existing or potential economic resource. A resource will have only one, as this specifies exactly what the resource is." 41 | resourceConformsTo: ResourceSpecification 42 | 43 | "The amount and unit of the economic resource counted or inventoried. This is the quantity that could be used to increment or decrement a resource, depending on the type of resource and resource effect of action." 44 | resourceQuantity: Measure 45 | 46 | "The amount and unit of the work or use or citation effort-based action. This is often a time duration, but also could be cycle counts or other measures of effort or usefulness." 47 | effortQuantity: Measure 48 | 49 | "The beginning of the economic event." 50 | hasBeginning: DateTime 51 | 52 | "The end of the economic event." 53 | hasEnd: DateTime 54 | 55 | "The date/time at which the economic event occurred. Can be used instead of beginning and end." 56 | hasPointInTime: DateTime 57 | 58 | "A textual description or comment." 59 | note: String 60 | 61 | "Grouping around something to create a boundary or context, used for documenting, accounting, planning." 62 | inScopeOf: [AccountingScope!] 63 | 64 | "Reference to an agreement between agents which specifies the rules or policies or calculations which govern this economic event." 65 | agreedIn: URI 66 | 67 | "References another economic event that implied this economic event, often based on a prior agreement." 68 | triggeredBy: EconomicEvent 69 | 70 | ############################################################################## 71 | # inverse relationships and queries 72 | 73 | track: [ProductionFlowItem!] 74 | trace: [ProductionFlowItem!] 75 | 76 | "The economic event can be safely deleted, has no dependent information." 77 | deletable: Boolean 78 | } 79 | 80 | """ 81 | A resource which is useful to people or the ecosystem. 82 | """ 83 | type EconomicResource { 84 | id: ID! 85 | 86 | "An informal or formal textual identifier for an item. Does not imply uniqueness." 87 | name: String 88 | 89 | "References one or more concepts in a common taxonomy or other classification scheme for purposes of categorization or grouping." 90 | classifiedAs: [URI!] 91 | 92 | "The primary resource specification or definition of an existing or potential economic resource. A resource will have only one, as this specifies exactly what the resource is." 93 | conformsTo: ResourceSpecification! 94 | 95 | "Sometimes called serial number, used when each item must have a traceable identifier (like a computer). Could also be used for other unique tracking identifiers needed for resources." 96 | trackingIdentifier: String 97 | 98 | "Lot or batch of an economic resource, used to track forward or backwards to all occurrences of resources of that lot. Note more than one resource can be of the same lot." 99 | lot: ProductBatch 100 | 101 | "The uri to an image relevant to the resource, such as a photo, diagram, etc." 102 | image: URI 103 | 104 | "The current amount and unit of the economic resource for which the agent has primary rights and responsibilities, sometimes thought of as ownership. This can be either stored or derived from economic events affecting the resource." 105 | accountingQuantity: Measure 106 | 107 | "The current amount and unit of the economic resource which is under direct control of the agent. It may be more or less than the accounting quantity. This can be either stored or derived from economic events affecting the resource." 108 | onhandQuantity: Measure 109 | 110 | "A textual description or comment." 111 | note: String 112 | 113 | "The unit used for use or work or cite actions for this resource." 114 | unitOfEffort: Unit 115 | 116 | "References the ProcessSpecification of the last process the desired economic resource went through. Stage is used when the last process is important for finding proper resources, such as where the publishing process wants only documents that have gone through the editing process." 117 | stage: ProcessSpecification 118 | 119 | "The state of the desired economic resource (pass or fail), after coming out of a test or review process. Can be derived from the last event if a pass or fail event." 120 | state: Action 121 | 122 | "Used when a stock economic resource contains items also defined as economic resources." 123 | containedIn: EconomicResource 124 | 125 | ############################################################################## 126 | # inverse relationships and queries 127 | 128 | "Used when a stock economic resource contains units also defined as economic resources." 129 | contains: [EconomicResource!] 130 | 131 | trace: [EconomicEvent!] 132 | track: [EconomicEvent!] 133 | } 134 | 135 | """ 136 | A lot or batch, defining a resource produced at the same time in the same way. 137 | From DataFoodConsortium vocabulary https://datafoodconsortium.gitbook.io/dfc-standard-documentation/. 138 | """ 139 | type ProductBatch { 140 | id: ID! 141 | 142 | "The standard unique identifier of the batch." 143 | batchNumber: String! 144 | 145 | "Expiration date of the batch, commonly used for food." 146 | expiryDate: DateTime 147 | 148 | "Date the batch was produced. Can be derived from the economic event of production." 149 | productionDate: DateTime 150 | } 151 | 152 | """ 153 | An activity that changes inputs into outputs. It could transform or transport economic resource(s). 154 | """ 155 | type Process { 156 | id: ID! 157 | 158 | "An informal or formal textual identifier for a process. Does not imply uniqueness." 159 | name: String! 160 | 161 | "The planned beginning of the process." 162 | hasBeginning: DateTime 163 | 164 | "The planned end of the process." 165 | hasEnd: DateTime 166 | 167 | "The process is complete or not. This is irrespective of if the original goal has been met, and indicates that no more will be done." 168 | finished: Boolean 169 | 170 | "The definition or specification for a process." 171 | basedOn: ProcessSpecification 172 | 173 | "References one or more concepts in a common taxonomy or other classification scheme for purposes of categorization or grouping." 174 | classifiedAs: [URI!] 175 | 176 | "A textual description or comment." 177 | note: String 178 | 179 | "Grouping around something to create a boundary or context, used for documenting, accounting, planning." 180 | inScopeOf: [AccountingScope!] 181 | 182 | ############################################################################## 183 | # inverse relationships and queries 184 | 185 | inputs(action: ID): [EconomicEvent!] 186 | outputs(action: ID): [EconomicEvent!] 187 | unplannedEconomicEvents(action: ID): [EconomicEvent!] 188 | 189 | nextProcesses: [Process!] 190 | previousProcesses: [Process!] 191 | 192 | trace: [EconomicEvent!] 193 | track: [EconomicEvent!] 194 | 195 | "The process can be safely deleted, has no dependent information." 196 | deletable: Boolean 197 | } 198 | 199 | 200 | 201 | input EconomicEventCreateParams { 202 | "(`Action`) Relates an economic event to a verb, such as consume, produce, work, improve, etc." 203 | action: ID! 204 | 205 | "(`Process`) Defines the process to which this event is an input." 206 | inputOf: ID 207 | 208 | "(`Process`) Defines the process for which this event is an output." 209 | outputOf: ID 210 | 211 | "Grouping around something to create a boundary or context, used for documenting, accounting, planning." 212 | inScopeOf: [ID!] 213 | 214 | "(`EconomicResource`) Economic resource involved in the economic event." 215 | resourceInventoriedAs: ID 216 | 217 | "References a concept in a common taxonomy or other classification scheme for purposes of categorization or grouping." 218 | resourceClassifiedAs: [URI!] 219 | 220 | "(`ResourceSpecification`) The primary resource specification or definition of an existing or potential economic resource. A resource will have only one, as this specifies exactly what the resource is." 221 | resourceConformsTo: ID 222 | 223 | "The amount and unit of the economic resource counted or inventoried. This is the quantity that could be used to increment or decrement a resource, depending on the type of resource and resource effect of action." 224 | resourceQuantity: IMeasure 225 | 226 | "The amount and unit of the work or use or citation effort-based action. This is often a time duration, but also could be cycle counts or other measures of effort or usefulness." 227 | effortQuantity: IMeasure 228 | 229 | "(`SpatialThing`) The place where an economic event occurs. Usually mappable." 230 | atLocation: ID 231 | 232 | "The beginning of the economic event." 233 | hasBeginning: DateTime 234 | 235 | "The end of the economic event." 236 | hasEnd: DateTime 237 | 238 | "The date/time at which the economic event occurred. Can be used instead of beginning and end." 239 | hasPointInTime: DateTime 240 | 241 | "A textual description or comment." 242 | note: String 243 | 244 | "Reference to an agreement between agents which specifies the rules or policies or calculations which govern this economic event." 245 | agreedIn: URI 246 | 247 | "(`Agreement`) This economic event occurs as part of this agreement." 248 | realizationOf: ID 249 | 250 | "(`EconomicEvent`) References another economic event that implied this economic event, often based on a prior agreement." 251 | triggeredBy: ID 252 | 253 | "(`EconomicResource`) Additional economic resource on the economic event when needed by the receiver. Used when a transfer or move, or sometimes other actions, requires explicitly identifying an economic resource on the receiving side." 254 | toResourceInventoriedAs: ID 255 | } 256 | 257 | input EconomicEventUpdateParams { 258 | id: ID! 259 | 260 | "A textual description or comment." 261 | note: String 262 | 263 | "Reference to an agreement between agents which specifies the rules or policies or calculations which govern this economic event." 264 | agreedIn: URI 265 | 266 | "(`Agreement`) This economic event occurs as part of this agreement." 267 | realizationOf: ID 268 | 269 | "(`EconomicEvent`) References another economic event that implied this economic event, often based on a prior agreement." 270 | triggeredBy: ID 271 | 272 | "Grouping around something to create a boundary or context, used for documenting, accounting, planning." 273 | inScopeOf: [ID!] 274 | } 275 | 276 | type EconomicEventResponse { 277 | "Details of the newly created event." 278 | economicEvent: EconomicEvent! 279 | "Details of any newly created `EconomicResource`, for events that create new resources." 280 | economicResource: EconomicResource 281 | } 282 | 283 | 284 | 285 | """ 286 | Input `EconomicResource` type used when sending events to setup initial resource recordings 287 | """ 288 | input EconomicResourceCreateParams { 289 | "An informal or formal textual identifier for an item. Does not imply uniqueness." 290 | name: String 291 | 292 | "(`ResourceSpecification`) The primary resource specification or definition of an existing or potential economic resource. A resource will have only one, as this specifies exactly what the resource is." 293 | conformsTo: ID 294 | 295 | "Sometimes called serial number, used when each item must have a traceable identifier (like a computer). Could also be used for other unique tracking identifiers needed for resources." 296 | trackingIdentifier: String 297 | 298 | "(`ProductBatch`) Lot or batch of an economic resource, used to track forward or backwards to all occurrences of resources of that lot. Note more than one resource can be of the same lot." 299 | lot: ID 300 | 301 | "The uri to an image relevant to the resource, such as a photo, diagram, etc." 302 | image: URI 303 | 304 | "(`EconomicResource`) Used when a stock economic resource contains items also defined as economic resources." 305 | containedIn: ID 306 | 307 | "(`SpatialThing`) The current place an economic resource is located. Could be at any level of granularity, from a town to an address to a warehouse location. Usually mappable." 308 | currentLocation: ID 309 | 310 | "A textual description or comment." 311 | note: String 312 | } 313 | 314 | input EconomicResourceUpdateParams { 315 | id: ID! 316 | 317 | "References one or more concepts in a common taxonomy or other classification scheme for purposes of categorization or grouping." 318 | classifiedAs: [URI!] 319 | 320 | "The uri to an image relevant to the resource, such as a photo, diagram, etc." 321 | image: URI 322 | 323 | "(`EconomicResource`) Used when a stock economic resource contains items also defined as economic resources." 324 | containedIn: ID 325 | 326 | "(`Unit`) The unit used for use or work or cite actions for this resource." 327 | unitOfEffort: ID 328 | 329 | "A textual description or comment." 330 | note: String 331 | } 332 | 333 | type EconomicResourceResponse { 334 | economicResource: EconomicResource! 335 | } 336 | 337 | 338 | 339 | input ProductBatchCreateParams { 340 | "The standard unique identifier of the batch." 341 | batchNumber: String! 342 | 343 | "Expiration date of the batch, commonly used for food." 344 | expiryDate: DateTime 345 | 346 | "Date the batch was produced. Can be derived from the economic event of production." 347 | productionDate: DateTime 348 | } 349 | 350 | input ProductBatchUpdateParams { 351 | id: ID! 352 | 353 | "The standard unique identifier of the batch." 354 | batchNumber: String 355 | 356 | "Expiration date of the batch, commonly used for food." 357 | expiryDate: DateTime 358 | 359 | "Date the batch was produced. Can be derived from the economic event of production." 360 | productionDate: DateTime 361 | } 362 | 363 | type ProductBatchResponse { 364 | productBatch: ProductBatch! 365 | } 366 | 367 | 368 | 369 | input ProcessCreateParams { 370 | "An informal or formal textual identifier for a process. Does not imply uniqueness." 371 | name: String! 372 | 373 | "The planned beginning of the process." 374 | hasBeginning: DateTime 375 | 376 | "The planned end of the process." 377 | hasEnd: DateTime 378 | 379 | "The process is complete or not. This is irrespective of if the original goal has been met, and indicates that no more will be done." 380 | finished: Boolean 381 | 382 | "A textual description or comment." 383 | note: String 384 | 385 | "Grouping around something to create a boundary or context, used for documenting, accounting, planning." 386 | inScopeOf: [ID!] 387 | 388 | "(`Plan`) The process with its inputs and outputs is part of the plan." 389 | plannedWithin: ID 390 | 391 | "(`ProcessSpecification`) The definition or specification for a process." 392 | basedOn: ID 393 | 394 | "References one or more concepts in a common taxonomy or other classification scheme for purposes of categorization or grouping." 395 | classifiedAs: [URI!] 396 | } 397 | 398 | input ProcessUpdateParams { 399 | id: ID! 400 | 401 | "An informal or formal textual identifier for a process. Does not imply uniqueness." 402 | name: String 403 | 404 | "The planned beginning of the process." 405 | hasBeginning: DateTime 406 | 407 | "The planned end of the process." 408 | hasEnd: DateTime 409 | 410 | "The process is complete or not. This is irrespective of if the original goal has been met, and indicates that no more will be done." 411 | finished: Boolean 412 | 413 | "A textual description or comment." 414 | note: String 415 | 416 | "Grouping around something to create a boundary or context, used for documenting, accounting, planning." 417 | inScopeOf: [ID!] 418 | 419 | "(`Plan`) The process with its inputs and outputs is part of the plan." 420 | plannedWithin: ID 421 | 422 | "(`ProcessSpecification`) The definition or specification for a process." 423 | basedOn: ID 424 | 425 | "References one or more concepts in a common taxonomy or other classification scheme for purposes of categorization or grouping." 426 | classifiedAs: [URI!] 427 | } 428 | 429 | type ProcessResponse { 430 | process: Process 431 | } 432 | 433 | 434 | 435 | type Query { 436 | economicEvent(id: ID): EconomicEvent 437 | economicEvents(start: ID, limit: Int): [EconomicEvent!] 438 | economicEventsFiltered( 439 | providerId: ID, 440 | receiverId: ID, 441 | resourceClassifiedAs: [URI!], 442 | action: ID, 443 | startDate: String, 444 | endDate: String 445 | ): [EconomicEvent!] 446 | 447 | economicResource(id: ID): EconomicResource 448 | economicResources(start: ID, limit: Int): [EconomicResource!] 449 | 450 | productBatch(id: ID): ProductBatch 451 | productBatches(start: ID, limit: Int): [ProductBatch!] 452 | 453 | process(id: ID): Process 454 | processes(start: ID, limit: Int): [Process!] 455 | } 456 | 457 | type Mutation { 458 | createEconomicEvent(event: EconomicEventCreateParams!, newInventoriedResource: EconomicResourceCreateParams): EconomicEventResponse 459 | updateEconomicEvent(event: EconomicEventUpdateParams!): EconomicEventResponse 460 | deleteEconomicEvent(id: ID!): Boolean 461 | 462 | # :TODO: should this be allowed without an originating event? Or should the event be recorded transparently? 463 | updateEconomicResource(resource: EconomicResourceUpdateParams!): EconomicResourceResponse 464 | deleteEconomicResource(id: ID!): Boolean 465 | 466 | createProductBatch(productBatch: ProductBatchCreateParams!): ProductBatchResponse 467 | updateProductBatch(productBatch: ProductBatchUpdateParams!): ProductBatchResponse 468 | deleteProductBatch(id: ID!): Boolean 469 | 470 | createProcess(process: ProcessCreateParams!): ProcessResponse 471 | updateProcess(process: ProcessUpdateParams!): ProcessResponse 472 | deleteProcess(id: ID!): Boolean 473 | } 474 | -------------------------------------------------------------------------------- /lib/schemas/plan.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Plan module 4 | # 5 | # Allows for grouping processes into related groups of work with defined deliverables. 6 | # 7 | # @depends scenario.gql 8 | # @package vf-graphql 9 | # @since 2019-02-11 10 | # 11 | ## 12 | 13 | """ 14 | A logical collection of processes that constitute a body of planned work with defined deliverable(s). 15 | """ 16 | type Plan { 17 | id: ID! 18 | 19 | "An informal or formal textual identifier for a plan. Does not imply uniqueness." 20 | name: String 21 | 22 | "The time the plan was made." 23 | created: DateTime 24 | 25 | "The time the plan is expected to be complete." 26 | due: DateTime 27 | 28 | "A textual description or comment." 29 | note: String 30 | 31 | "This plan refines a scenario, making it operational." 32 | refinementOf: Scenario 33 | 34 | ############################################################################## 35 | # inverse relationships and queries 36 | 37 | "Grouping around something to create a boundary or context, used for documenting, accounting, planning." 38 | inScopeOf: [AccountingScope!] 39 | 40 | "The plan is able to be deleted or not." 41 | deletable: Boolean 42 | } 43 | 44 | 45 | 46 | input PlanCreateParams { 47 | "An informal or formal textual identifier for a plan. Does not imply uniqueness." 48 | name: String! 49 | 50 | "The time the plan was made." 51 | created: DateTime 52 | 53 | "The time the plan is expected to be complete." 54 | due: DateTime 55 | 56 | "A textual description or comment." 57 | note: String 58 | 59 | "(`Scenario`) This plan refines a scenario, making it operational." 60 | refinementOf: ID 61 | } 62 | 63 | input PlanUpdateParams { 64 | id: ID! 65 | 66 | "An informal or formal textual identifier for a plan. Does not imply uniqueness." 67 | name: String 68 | 69 | "The time the plan was made." 70 | created: DateTime 71 | 72 | "The time the plan is expected to be complete." 73 | due: DateTime 74 | 75 | "A textual description or comment." 76 | note: String 77 | 78 | "(`Scenario`) This plan refines a scenario, making it operational." 79 | refinementOf: ID 80 | } 81 | 82 | type PlanResponse { 83 | plan: Plan 84 | } 85 | 86 | 87 | 88 | type Query { 89 | plan(id: ID): Plan 90 | plans(start: ID, limit: Int): [Plan!] 91 | } 92 | 93 | type Mutation { 94 | createPlan(plan: PlanCreateParams!): PlanResponse 95 | # :TODO: 96 | # createPlanFromRecipe(): PlanResponse 97 | updatePlan(plan: PlanUpdateParams!): PlanResponse 98 | deletePlan(id: ID!): Boolean 99 | } 100 | -------------------------------------------------------------------------------- /lib/schemas/planning.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Planning layer 4 | # 5 | # Allows agents to coordinate economic activity by agreeing on a series of 6 | # future events to be undertaken. 7 | # 8 | # :TODO: split out observation fields into bridging schema to allow planning 9 | # systems to operate without observed events 10 | # 11 | # @depends measurement.gql 12 | # @depends knowledge.gql 13 | # @depends observation.gql 14 | # @package vf-graphql 15 | # @since 2019-02-11 16 | # 17 | ## 18 | 19 | union EventOrCommitment = EconomicEvent | Commitment 20 | 21 | """ 22 | A planned economic flow that has been promised by an agent to another agent. 23 | """ 24 | type Commitment { 25 | id: ID! 26 | 27 | "Relates a commitment to a verb, such as consume, produce, work, improve, etc." 28 | action: Action! 29 | 30 | "Defines the process to which this commitment is an input." 31 | inputOf: Process 32 | 33 | "Defines the process for which this commitment is an output." 34 | outputOf: Process 35 | 36 | "References a concept in a common taxonomy or other classification scheme for purposes of categorization or grouping." 37 | resourceClassifiedAs: [URI!] 38 | 39 | "The primary resource specification or definition of an existing or potential economic resource. A resource will have only one, as this specifies exactly what the resource is." 40 | resourceConformsTo: ResourceSpecification 41 | 42 | "Exact economic resource involved in the commitment." 43 | resourceInventoriedAs: EconomicResource 44 | 45 | "The amount and unit of the economic resource counted or inventoried." 46 | resourceQuantity: Measure 47 | 48 | "The amount and unit of the work or use or citation effort-based action. This is often a time duration, but also could be cycle counts or other measures of effort or usefulness." 49 | effortQuantity: Measure 50 | 51 | "The planned beginning of the commitment." 52 | hasBeginning: DateTime 53 | 54 | "The planned end of the commitment." 55 | hasEnd: DateTime 56 | 57 | "The planned date/time for the commitment. Can be used instead of beginning and end." 58 | hasPointInTime: DateTime 59 | 60 | "The time something is expected to be complete." 61 | due: DateTime 62 | 63 | "The creation time of the commitment." 64 | created: DateTime 65 | 66 | "The commitment is complete or not. This is irrespective of if the original goal has been met, and indicates that no more will be done." 67 | finished: Boolean 68 | 69 | "A textual description or comment." 70 | note: String 71 | 72 | "Grouping around something to create a boundary or context, used for documenting, accounting, planning." 73 | inScopeOf: [AccountingScope!] 74 | 75 | "Reference to an agreement between agents which specifies the rules or policies or calculations which govern this commitment." 76 | agreedIn: URI 77 | 78 | ############################################################################## 79 | # inverse relationships and queries 80 | 81 | "The economic event which completely or partially fulfills a commitment." 82 | fulfilledBy: [Fulfillment!] 83 | 84 | "An intent satisfied fully or partially by an economic event or commitment." 85 | satisfies: [Satisfaction!] 86 | 87 | "The commitment can be safely deleted, has no dependent information." 88 | deletable: Boolean 89 | } 90 | 91 | """ 92 | A planned economic flow which has not been committed to, which can lead to economic events (sometimes through commitments). 93 | """ 94 | type Intent { 95 | id: ID! 96 | 97 | "An informal or formal textual identifier for an intent. Does not imply uniqueness." 98 | name: String 99 | 100 | "Relates an intent to a verb, such as consume, produce, work, improve, etc." 101 | action: Action! 102 | 103 | "Defines the process to which this intent is an input." 104 | inputOf: Process 105 | 106 | "Defines the process to which this intent is an output." 107 | outputOf: Process 108 | 109 | "References a concept in a common taxonomy or other classification scheme for purposes of categorization or grouping." 110 | resourceClassifiedAs: [URI!] 111 | 112 | "The primary resource specification or definition of an existing or potential economic resource. A resource will have only one, as this specifies exactly what the resource is." 113 | resourceConformsTo: ResourceSpecification 114 | 115 | "When a specific `EconomicResource` is known which can service the `Intent`, this defines that resource." 116 | resourceInventoriedAs: EconomicResource 117 | 118 | "The amount and unit of the economic resource counted or inventoried. This is the quantity that could be used to increment or decrement a resource, depending on the type of resource and resource effect of action." 119 | resourceQuantity: Measure 120 | 121 | "The amount and unit of the work or use or citation effort-based action. This is often a time duration, but also could be cycle counts or other measures of effort or usefulness." 122 | effortQuantity: Measure 123 | 124 | "The total quantity of the offered resource available." 125 | availableQuantity: Measure 126 | 127 | "The planned beginning of the intent." 128 | hasBeginning: DateTime 129 | 130 | "The planned end of the intent." 131 | hasEnd: DateTime 132 | 133 | "The planned date/time for the intent. Can be used instead of beginning and end." 134 | hasPointInTime: DateTime 135 | 136 | "The time something is expected to be complete." 137 | due: DateTime 138 | 139 | "The intent is complete or not. This is irrespective of if the original goal has been met, and indicates that no more will be done." 140 | finished: Boolean 141 | 142 | "The uri to an image relevant to the intent, such as a photo." 143 | image: URI 144 | 145 | "A textual description or comment." 146 | note: String 147 | 148 | "Grouping around something to create a boundary or context, used for documenting, accounting, planning." 149 | inScopeOf: [AccountingScope!] 150 | 151 | "Reference to an agreement between agents which specifies the rules or policies or calculations which govern this intent." 152 | agreedIn: URI 153 | 154 | ############################################################################## 155 | # inverse relationships and queries 156 | 157 | "The intent can be safely deleted, has no dependent information." 158 | deletable: Boolean 159 | 160 | satisfiedBy: [Satisfaction!] 161 | } 162 | 163 | """ 164 | Represents many-to-many relationships between commitments and economic events that fully or partially satisfy one or more commitments. 165 | """ 166 | type Fulfillment { 167 | id: ID! 168 | 169 | "The economic event which completely or partially fulfills a commitment." 170 | fulfilledBy: EconomicEvent! 171 | 172 | "The commitment which is completely or partially fulfilled by an economic event." 173 | fulfills: Commitment! 174 | 175 | "The amount and unit of the economic resource counted or inventoried." 176 | resourceQuantity: Measure 177 | 178 | "The amount and unit of the work or use or citation effort-based action. This is often a time duration, but also could be cycle counts or other measures of effort or usefulness." 179 | effortQuantity: Measure 180 | 181 | "A textual description or comment." 182 | note: String 183 | } 184 | 185 | """ 186 | Represents many-to-many relationships between intents and commitments or events that partially or full satisfy one or more intents. 187 | """ 188 | type Satisfaction { 189 | id: ID! 190 | 191 | "An intent satisfied fully or partially by an economic event or commitment." 192 | satisfies: Intent! 193 | 194 | "A commitment or economic event fully or partially satisfying an intent." 195 | satisfiedBy: EventOrCommitment! 196 | 197 | "The amount and unit of the economic resource counted or inventoried." 198 | resourceQuantity: Measure 199 | 200 | "The amount and unit of the work or use or citation effort-based action. This is often a time duration, but also could be cycle counts or other measures of effort or usefulness." 201 | effortQuantity: Measure 202 | 203 | "A textual description or comment." 204 | note: String 205 | } 206 | 207 | 208 | 209 | input IntentCreateParams { 210 | "(`Action`) Relates an intent to a verb, such as consume, produce, work, improve, etc." 211 | action: ID! 212 | 213 | "An informal or formal textual identifier for an intent. Does not imply uniqueness." 214 | name: String 215 | 216 | "(`Process`) Defines the process to which this intent is an input." 217 | inputOf: ID 218 | 219 | "(`Process`) Defines the process to which this intent is an output." 220 | outputOf: ID 221 | 222 | "(`ResourceSpecification`) The primary resource specification or definition of an existing or potential economic resource. A resource will have only one, as this specifies exactly what the resource is." 223 | resourceConformsTo: ID 224 | 225 | "References a concept in a common taxonomy or other classification scheme for purposes of categorization or grouping." 226 | resourceClassifiedAs: [URI!] 227 | 228 | "(`EconomicResource`) When a specific `EconomicResource` is known which can service the `Intent`, this defines that resource." 229 | resourceInventoriedAs: ID 230 | 231 | "The amount and unit of the economic resource counted or inventoried. This is the quantity that could be used to increment or decrement a resource, depending on the type of resource and resource effect of action." 232 | resourceQuantity: IMeasure 233 | 234 | "The amount and unit of the work or use or citation effort-based action. This is often a time duration, but also could be cycle counts or other measures of effort or usefulness." 235 | effortQuantity: IMeasure 236 | 237 | "The total quantity of the offered resource available." 238 | availableQuantity: IMeasure 239 | 240 | "The planned beginning of the intent." 241 | hasBeginning: DateTime 242 | 243 | "The planned end of the intent." 244 | hasEnd: DateTime 245 | 246 | "The planned date/time for the intent. Can be used instead of beginning and end." 247 | hasPointInTime: DateTime 248 | 249 | "The time something is expected to be complete." 250 | due: DateTime 251 | 252 | "The uri to an image relevant to the intent, such as a photo." 253 | image: URI 254 | 255 | "A textual description or comment." 256 | note: String 257 | 258 | "Grouping around something to create a boundary or context, used for documenting, accounting, planning." 259 | inScopeOf: [ID!] 260 | 261 | "(`SpatialThing`) The place where an intent occurs. Usually mappable." 262 | atLocation: ID 263 | 264 | "Reference to an agreement between agents which specifies the rules or policies or calculations which govern this intent." 265 | agreedIn: URI 266 | 267 | "The intent is complete or not. This is irrespective of if the original goal has been met, and indicates that no more will be done." 268 | finished: Boolean 269 | } 270 | 271 | input IntentUpdateParams { 272 | id: ID! 273 | 274 | "An informal or formal textual identifier for an intent. Does not imply uniqueness." 275 | name: String 276 | 277 | "(`Action`) Relates an intent to a verb, such as consume, produce, work, improve, etc." 278 | action: ID 279 | 280 | "(`Process`) Defines the process to which this intent is an input." 281 | inputOf: ID 282 | 283 | "(`Process`) Defines the process to which this intent is an output." 284 | outputOf: ID 285 | 286 | "(`ResourceSpecification`) The primary resource specification or definition of an existing or potential economic resource. A resource will have only one, as this specifies exactly what the resource is." 287 | resourceConformsTo: ID 288 | 289 | "References a concept in a common taxonomy or other classification scheme for purposes of categorization or grouping." 290 | resourceClassifiedAs: [URI!] 291 | 292 | "(`EconomicResource`) When a specific `EconomicResource` is known which can service the `Intent`, this defines that resource." 293 | resourceInventoriedAs: ID 294 | 295 | "The amount and unit of the economic resource counted or inventoried. This is the quantity that could be used to increment or decrement a resource, depending on the type of resource and resource effect of action." 296 | resourceQuantity: IMeasure 297 | 298 | "The amount and unit of the work or use or citation effort-based action. This is often a time duration, but also could be cycle counts or other measures of effort or usefulness." 299 | effortQuantity: IMeasure 300 | 301 | "The total quantity of the offered resource available." 302 | availableQuantity: IMeasure 303 | 304 | "The planned beginning of the intent." 305 | hasBeginning: DateTime 306 | 307 | "The planned end of the intent." 308 | hasEnd: DateTime 309 | 310 | "The planned date/time for the intent. Can be used instead of beginning and end." 311 | hasPointInTime: DateTime 312 | 313 | "The time something is expected to be complete." 314 | due: DateTime 315 | 316 | "The uri to an image relevant to the intent, such as a photo." 317 | image: URI 318 | 319 | "The intent is complete or not. This is irrespective of if the original goal has been met, and indicates that no more will be done." 320 | finished: Boolean 321 | 322 | "A textual description or comment." 323 | note: String 324 | 325 | "Grouping around something to create a boundary or context, used for documenting, accounting, planning." 326 | inScopeOf: [ID!] 327 | 328 | "(`SpatialThing`) The place where an intent occurs. Usually mappable." 329 | atLocation: ID 330 | 331 | "Reference to an agreement between agents which specifies the rules or policies or calculations which govern this intent." 332 | agreedIn: URI 333 | } 334 | 335 | type IntentResponse { 336 | intent: Intent! 337 | } 338 | 339 | 340 | 341 | input CommitmentCreateParams { 342 | "(`Action`) Relates a commitment to a verb, such as consume, produce, work, improve, etc." 343 | action: ID! 344 | 345 | "(`Process`) Defines the process to which this commitment is an input." 346 | inputOf: ID 347 | 348 | "(`Process`) Defines the process for which this commitment is an output." 349 | outputOf: ID 350 | 351 | "References a concept in a common taxonomy or other classification scheme for purposes of categorization or grouping." 352 | resourceClassifiedAs: [URI!] 353 | 354 | "(`ResourceSpecification`) The primary resource specification or definition of an existing or potential economic resource. A resource will have only one, as this specifies exactly what the resource is." 355 | resourceConformsTo: ID 356 | 357 | "(`EconomicResource`) Exact economic resource involved in the commitment." 358 | resourceInventoriedAs: ID 359 | 360 | "The amount and unit of the economic resource counted or inventoried." 361 | resourceQuantity: IMeasure 362 | 363 | "The amount and unit of the work or use or citation effort-based action. This is often a time duration, but also could be cycle counts or other measures of effort or usefulness." 364 | effortQuantity: IMeasure 365 | 366 | "The planned beginning of the commitment." 367 | hasBeginning: DateTime 368 | 369 | "The planned end of the commitment." 370 | hasEnd: DateTime 371 | 372 | "The planned date/time for the commitment. Can be used instead of beginning and end." 373 | hasPointInTime: DateTime 374 | 375 | "The time something is expected to be complete." 376 | due: DateTime 377 | 378 | "The commitment is complete or not. This is irrespective of if the original goal has been met, and indicates that no more will be done." 379 | finished: Boolean 380 | 381 | "A textual description or comment." 382 | note: String 383 | 384 | "Grouping around something to create a boundary or context, used for documenting, accounting, planning." 385 | inScopeOf: [ID!] 386 | 387 | "(`Plan`) Represents a desired deliverable expected from this plan." 388 | independentDemandOf: ID 389 | 390 | "(`SpatialThing`) The place where an commitment occurs. Usually mappable." 391 | atLocation: ID 392 | 393 | "Reference to an agreement between agents which specifies the rules or policies or calculations which govern this commitment." 394 | agreedIn: URI 395 | 396 | "(`Agreement`) This commitment is part of the agreement." 397 | clauseOf: ID 398 | } 399 | 400 | input CommitmentUpdateParams { 401 | id: ID! 402 | 403 | "(`Process`) Defines the process to which this commitment is an input." 404 | inputOf: ID 405 | 406 | "(`Process`) Defines the process for which this commitment is an output." 407 | outputOf: ID 408 | 409 | "References a concept in a common taxonomy or other classification scheme for purposes of categorization or grouping." 410 | resourceClassifiedAs: [URI!] 411 | 412 | "(`ResourceSpecification`) The primary resource specification or definition of an existing or potential economic resource. A resource will have only one, as this specifies exactly what the resource is." 413 | resourceConformsTo: ID 414 | 415 | "(`EconomicResource`) Exact economic resource involved in the commitment." 416 | resourceInventoriedAs: ID 417 | 418 | "The amount and unit of the economic resource counted or inventoried." 419 | resourceQuantity: IMeasure 420 | 421 | "The amount and unit of the work or use or citation effort-based action. This is often a time duration, but also could be cycle counts or other measures of effort or usefulness." 422 | effortQuantity: IMeasure 423 | 424 | "The planned beginning of the commitment." 425 | hasBeginning: DateTime 426 | 427 | "The planned end of the commitment." 428 | hasEnd: DateTime 429 | 430 | "The planned date/time for the commitment. Can be used instead of beginning and end." 431 | hasPointInTime: DateTime 432 | 433 | "The time something is expected to be complete." 434 | due: DateTime 435 | 436 | "The commitment is complete or not. This is irrespective of if the original goal has been met, and indicates that no more will be done." 437 | finished: Boolean 438 | 439 | "A textual description or comment." 440 | note: String 441 | 442 | "Grouping around something to create a boundary or context, used for documenting, accounting, planning." 443 | inScopeOf: [ID!] 444 | 445 | "(`Plan`) Represents a desired deliverable expected from this plan." 446 | independentDemandOf: ID 447 | 448 | "(`SpatialThing`) The place where an commitment occurs. Usually mappable." 449 | atLocation: ID 450 | 451 | "Reference to an agreement between agents which specifies the rules or policies or calculations which govern this commitment." 452 | agreedIn: URI 453 | 454 | "(`Agreement`) This commitment is part of the agreement." 455 | clauseOf: ID 456 | } 457 | 458 | type CommitmentResponse { 459 | commitment: Commitment 460 | } 461 | 462 | 463 | 464 | input FulfillmentCreateParams { 465 | "(`EconomicEvent`) The economic event which completely or partially fulfills a commitment." 466 | fulfilledBy: ID! 467 | 468 | "(`Commitment`) The commitment which is completely or partially fulfilled by an economic event." 469 | fulfills: ID! 470 | 471 | "The amount and unit of the economic resource counted or inventoried." 472 | resourceQuantity: IMeasure 473 | 474 | "The amount and unit of the work or use or citation effort-based action. This is often a time duration, but also could be cycle counts or other measures of effort or usefulness." 475 | effortQuantity: IMeasure 476 | 477 | "A textual description or comment." 478 | note: String 479 | } 480 | 481 | input FulfillmentUpdateParams { 482 | id: ID! 483 | 484 | "(`EconomicEvent`) The economic event which completely or partially fulfills a commitment." 485 | fulfilledBy: ID 486 | 487 | "(`Commitment`) The commitment which is completely or partially fulfilled by an economic event." 488 | fulfills: ID 489 | 490 | "The amount and unit of the economic resource counted or inventoried." 491 | resourceQuantity: IMeasure 492 | 493 | "The amount and unit of the work or use or citation effort-based action. This is often a time duration, but also could be cycle counts or other measures of effort or usefulness." 494 | effortQuantity: IMeasure 495 | 496 | "A textual description or comment." 497 | note: String 498 | } 499 | 500 | type FulfillmentResponse { 501 | fulfillment: Fulfillment 502 | } 503 | 504 | 505 | 506 | input SatisfactionCreateParams { 507 | "(`Intent`) An intent satisfied fully or partially by an economic event or commitment." 508 | satisfies: ID! 509 | 510 | "(`Commitment`|`EconomicEvent`) A commitment or economic event fully or partially satisfying an intent." 511 | satisfiedBy: ID! 512 | 513 | "The amount and unit of the economic resource counted or inventoried." 514 | resourceQuantity: IMeasure 515 | 516 | "The amount and unit of the work or use or citation effort-based action. This is often a time duration, but also could be cycle counts or other measures of effort or usefulness." 517 | effortQuantity: IMeasure 518 | 519 | "A textual description or comment." 520 | note: String 521 | } 522 | 523 | input SatisfactionUpdateParams { 524 | id: ID! 525 | 526 | "(`Intent`) An intent satisfied fully or partially by an economic event or commitment." 527 | satisfies: ID 528 | 529 | "(`Commitment`|`EconomicEvent`) A commitment or economic event fully or partially satisfying an intent." 530 | satisfiedBy: ID 531 | 532 | "The amount and unit of the economic resource counted or inventoried." 533 | resourceQuantity: IMeasure 534 | 535 | "The amount and unit of the work or use or citation effort-based action. This is often a time duration, but also could be cycle counts or other measures of effort or usefulness." 536 | effortQuantity: IMeasure 537 | 538 | "A textual description or comment." 539 | note: String 540 | } 541 | 542 | type SatisfactionResponse { 543 | satisfaction: Satisfaction 544 | } 545 | 546 | 547 | 548 | type Query { 549 | commitment(id: ID): Commitment 550 | commitments(start: ID, limit: Int): [Commitment!] 551 | 552 | intent(id: ID): Intent 553 | intents(start: ID, limit: Int): [Intent!] 554 | 555 | fulfillment(id: ID): Fulfillment 556 | fulfillments(start: ID, limit: Int): [Fulfillment!] 557 | 558 | satisfaction(id: ID): Satisfaction 559 | satisfactions(start: ID, limit: Int): [Satisfaction!] 560 | } 561 | 562 | type Mutation { 563 | createCommitment(commitment: CommitmentCreateParams): CommitmentResponse 564 | updateCommitment(commitment: CommitmentUpdateParams): CommitmentResponse 565 | deleteCommitment(id: ID!): Boolean 566 | 567 | createIntent(intent: IntentCreateParams): IntentResponse 568 | updateIntent(intent: IntentUpdateParams): IntentResponse 569 | deleteIntent(id: ID!): Boolean 570 | 571 | createFulfillment(fulfillment: FulfillmentCreateParams!): FulfillmentResponse 572 | updateFulfillment(fulfillment: FulfillmentUpdateParams!): FulfillmentResponse 573 | deleteFulfillment(id: ID!): Boolean 574 | 575 | createSatisfaction(satisfaction: SatisfactionCreateParams): SatisfactionResponse 576 | updateSatisfaction(satisfaction: SatisfactionUpdateParams): SatisfactionResponse 577 | deleteSatisfaction(id: ID!): Boolean 578 | } 579 | -------------------------------------------------------------------------------- /lib/schemas/proposal.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Proposal module 4 | # 5 | # Allows grouping of many intents (requests or offers) into a related proposal for actioning. 6 | # 7 | # @depends planning.gql 8 | # @package vf-graphql 9 | # @since 2019-02-11 10 | # 11 | ## 12 | 13 | """ 14 | Published requests or offers, sometimes with what is expected in return. 15 | """ 16 | type Proposal { 17 | id: ID! 18 | 19 | "An informal or formal textual identifier for a proposal. Does not imply uniqueness." 20 | name: String 21 | 22 | "The beginning time of proposal publication." 23 | hasBeginning: DateTime 24 | 25 | "The end time of proposal publication." 26 | hasEnd: DateTime 27 | 28 | "Grouping around something to create a boundary or context, used for documenting, accounting, planning." 29 | inScopeOf: [AccountingScope!] 30 | 31 | "This proposal contains unit based quantities, which can be multipied to create commitments; commonly seen in a price list or e-commerce." 32 | unitBased: Boolean 33 | 34 | "The date and time the proposal was created." 35 | created: DateTime 36 | 37 | "A textual description or comment." 38 | note: String 39 | 40 | ############################################################################## 41 | # inverse relationships and queries 42 | 43 | publishes: [ProposedIntent!] 44 | } 45 | 46 | """ 47 | Represents many-to-many relationships between Proposals and Intents, supporting including intents in multiple proposals, as well as a proposal including multiple intents. 48 | """ 49 | type ProposedIntent { 50 | id: ID! 51 | 52 | "This is a reciprocal intent of this proposal, not primary. Not meant to be used for intent matching." 53 | reciprocal: Boolean 54 | 55 | "The intent which is part of this published proposal." 56 | publishes: Intent! 57 | 58 | "The published proposal which this intent is part of." 59 | publishedIn: Proposal! 60 | } 61 | 62 | 63 | 64 | 65 | 66 | input ProposalCreateParams { 67 | "An informal or formal textual identifier for a proposal. Does not imply uniqueness." 68 | name: String 69 | 70 | "The beginning time of proposal publication." 71 | hasBeginning: DateTime 72 | 73 | "The end time of proposal publication." 74 | hasEnd: DateTime 75 | 76 | "(`SpatialThing`) The location at which this proposal is eligible." 77 | eligibleLocation: ID 78 | 79 | "Grouping around something to create a boundary or context, used for documenting, accounting, planning." 80 | inScopeOf: [ID!] 81 | 82 | "This proposal contains unit based quantities, which can be multipied to create commitments; commonly seen in a price list or e-commerce." 83 | unitBased: Boolean 84 | 85 | "A textual description or comment." 86 | note: String 87 | 88 | "The date and time the proposal was created." 89 | created: DateTime # :TODO: should this be generated by the backend, or is it human-provided data? 90 | } 91 | 92 | input ProposalUpdateParams { 93 | id: ID! 94 | 95 | "An informal or formal textual identifier for a proposal. Does not imply uniqueness." 96 | name: String 97 | 98 | "The beginning date/time of proposal publication." 99 | hasBeginning: DateTime 100 | 101 | "The end time of proposal publication." 102 | hasEnd: DateTime 103 | 104 | "(`SpatialThing`) The location at which this proposal is eligible." 105 | eligibleLocation: ID 106 | 107 | "Grouping around something to create a boundary or context, used for documenting, accounting, planning." 108 | inScopeOf: [ID!] 109 | 110 | "This proposal contains unit based quantities, which can be multipied to create commitments; commonly seen in a price list or e-commerce." 111 | unitBased: Boolean 112 | 113 | "A textual description or comment." 114 | note: String 115 | } 116 | 117 | type ProposalResponse { 118 | proposal: Proposal 119 | } 120 | 121 | 122 | 123 | type ProposedIntentResponse { 124 | proposedIntent: ProposedIntent 125 | } 126 | 127 | 128 | 129 | type Query { 130 | proposal(id: ID): Proposal 131 | proposals(start: ID, limit: Int): [Proposal!] 132 | } 133 | 134 | type Mutation { 135 | createProposal(proposal: ProposalCreateParams): ProposalResponse 136 | updateProposal(proposal: ProposalUpdateParams): ProposalResponse 137 | deleteProposal(id: ID!): Boolean 138 | 139 | """ 140 | Include an existing intent as part of a proposal. 141 | @param publishedIn the (`Proposal`) to include the intent in 142 | @param publishes the (`Intent`) to include as part of the proposal 143 | """ 144 | proposeIntent(publishedIn: ID!, publishes: ID!, reciprocal: Boolean): ProposedIntentResponse 145 | deleteProposedIntent(id: ID!): Boolean 146 | } 147 | -------------------------------------------------------------------------------- /lib/schemas/recipe.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Recipe module 4 | # 5 | # Provides for creating shareable blueprints of potential workflows that can be 6 | # deployed as work plans for undertaking the actual work. 7 | # 8 | # @depends measurement.gql 9 | # @depends knowledge.gql 10 | # @package vf-graphql 11 | # @since 2019-02-11 12 | # 13 | ## 14 | 15 | """ 16 | Specifies the resource as part of a recipe, for use in planning from recipe. 17 | """ 18 | type RecipeResource { 19 | id: ID! 20 | 21 | "An informal or formal textual identifier for a recipe resource. Does not imply uniqueness." 22 | name: String! 23 | 24 | "The unit of inventory used for this resource in the recipe." 25 | unitOfResource: Unit 26 | 27 | "The unit used for use action on this resource or work action in the recipe." 28 | unitOfEffort: Unit 29 | 30 | "The uri to an image relevant to the entity, such as a photo, diagram, etc." 31 | image: URI 32 | 33 | "A textual description or comment." 34 | note: String 35 | 36 | "The primary resource specification or definition of an existing or potential economic resource. A resource will have only one, as this specifies exactly what the resource is." 37 | resourceConformsTo: ResourceSpecification 38 | 39 | "References a concept in a common taxonomy or other classification scheme for purposes of categorization or grouping." 40 | resourceClassifiedAs: [URI!] 41 | 42 | "Defines if any resource of that type can be freely substituted for any other resource of that type when used, consumed, traded, etc." 43 | substitutable: Boolean 44 | 45 | ############################################################################## 46 | # inverse relationships and queries 47 | 48 | } 49 | 50 | """ 51 | The specification of a resource inflow to, or outflow from, a recipe process. 52 | """ 53 | type RecipeFlow { 54 | id: ID! 55 | 56 | "The amount and unit of the economic resource counted or inventoried." 57 | resourceQuantity: Measure 58 | 59 | "The amount and unit of the work or use or citation effort-based action. This is often a time duration, but also could be cycle counts or other measures of effort or usefulness." 60 | effortQuantity: Measure 61 | 62 | "The resource definition referenced by this flow in the recipe." 63 | recipeFlowResource: RecipeResource 64 | 65 | "Relates a process input or output to a verb, such as consume, produce, work, modify, etc." 66 | action: Action! 67 | 68 | "Relates an input flow to its process in a recipe." 69 | recipeInputOf: RecipeProcess 70 | 71 | "Relates an output flow to its process in a recipe." 72 | recipeOutputOf: RecipeProcess 73 | 74 | "Relates a flow to its exchange agreement in a recipe." 75 | recipeClauseOf: RecipeExchange 76 | 77 | "A textual description or comment." 78 | note: String 79 | } 80 | 81 | """ 82 | Specifies a process in a recipe for use in planning from recipe. 83 | """ 84 | type RecipeProcess { 85 | id: ID! 86 | 87 | "An informal or formal textual identifier for a recipe process. Does not imply uniqueness." 88 | name: String! 89 | 90 | "The planned calendar duration of the process as defined for the recipe batch." 91 | hasDuration: Duration 92 | 93 | "References a concept in a common taxonomy or other classification scheme for purposes of categorization." 94 | processClassifiedAs: [URI!] 95 | 96 | "The standard specification or definition of a process." 97 | processConformsTo: ProcessSpecification! 98 | 99 | "A textual description or comment." 100 | note: String 101 | } 102 | 103 | """ 104 | Specifies an exchange agreement as part of a recipe. 105 | """ 106 | type RecipeExchange { 107 | id: ID! 108 | 109 | "An informal or formal textual identifier for a recipe exchange. Does not imply uniqueness." 110 | name: String! 111 | 112 | "A textual description or comment." 113 | note: String 114 | } 115 | 116 | input RecipeResourceCreateParams { 117 | "An informal or formal textual identifier for a recipe resource. Does not imply uniqueness." 118 | name: String! 119 | 120 | "(`Unit`) The unit of inventory used for this resource in the recipe." 121 | unitOfResource: ID 122 | 123 | "(`Unit`) The unit used for use action on this resource or work action in the recipe." 124 | unitOfEffort: ID 125 | 126 | "Defines if any resource of that type can be freely substituted for any other resource of that type when used, consumed, traded, etc." 127 | substitutable: Boolean 128 | 129 | "The uri to an image relevant to the entity, such as a photo, diagram, etc." 130 | image: URI 131 | 132 | "(`ResourceSpecification`) The primary resource specification or definition of an existing or potential economic resource. A resource will have only one, as this specifies exactly what the resource is." 133 | resourceConformsTo: ID 134 | 135 | "References a concept in a common taxonomy or other classification scheme for purposes of categorization or grouping." 136 | resourceClassifiedAs: [URI!] 137 | 138 | "A textual description or comment." 139 | note: String 140 | } 141 | 142 | input RecipeResourceUpdateParams { 143 | id: ID! 144 | 145 | "An informal or formal textual identifier for a recipe resource. Does not imply uniqueness." 146 | name: String 147 | 148 | "(`Unit`) The unit of inventory used for this resource in the recipe." 149 | unitOfResource: ID 150 | 151 | "(`Unit`) The unit used for use action on this resource or work action in the recipe." 152 | unitOfEffort: ID 153 | 154 | "Defines if any resource of that type can be freely substituted for any other resource of that type when used, consumed, traded, etc." 155 | substitutable: Boolean 156 | 157 | "The uri to an image relevant to the entity, such as a photo, diagram, etc." 158 | image: URI 159 | 160 | "(`ResourceSpecification`) The primary resource specification or definition of an existing or potential economic resource. A resource will have only one, as this specifies exactly what the resource is." 161 | resourceConformsTo: ID 162 | 163 | "References a concept in a common taxonomy or other classification scheme for purposes of categorization or grouping." 164 | resourceClassifiedAs: [URI!] 165 | 166 | "A textual description or comment." 167 | note: String 168 | } 169 | 170 | type RecipeResourceResponse { 171 | recipeResource: RecipeResource 172 | } 173 | 174 | 175 | 176 | input RecipeProcessCreateParams { 177 | "An informal or formal textual identifier for a recipe process. Does not imply uniqueness." 178 | name: String! 179 | 180 | "The planned calendar duration of the process as defined for the recipe batch." 181 | hasDuration: IDuration 182 | 183 | "(`ProcessSpecification`) The standard specification or definition of a process." 184 | processConformsTo: ID! 185 | 186 | "References a concept in a common taxonomy or other classification scheme for purposes of categorization." 187 | processClassifiedAs: [URI!] 188 | 189 | "A textual description or comment." 190 | note: String 191 | } 192 | 193 | input RecipeProcessUpdateParams { 194 | id: ID! 195 | 196 | "An informal or formal textual identifier for a recipe process. Does not imply uniqueness." 197 | name: String 198 | 199 | "The planned calendar duration of the process as defined for the recipe batch." 200 | hasDuration: IDuration 201 | 202 | "(`ProcessSpecification`) The standard specification or definition of a process." 203 | processConformsTo: ID! 204 | 205 | "References a concept in a common taxonomy or other classification scheme for purposes of categorization." 206 | processClassifiedAs: [URI!] 207 | 208 | "A textual description or comment." 209 | note: String 210 | } 211 | 212 | type RecipeProcessResponse { 213 | recipeProcess: RecipeProcess 214 | } 215 | 216 | 217 | 218 | input RecipeExchangeCreateParams { 219 | "An informal or formal textual identifier for a recipe exchange. Does not imply uniqueness." 220 | name: String! 221 | 222 | "A textual description or comment." 223 | note: String 224 | } 225 | 226 | input RecipeExchangeUpdateParams { 227 | id: ID! 228 | 229 | "An informal or formal textual identifier for a recipe exchange. Does not imply uniqueness." 230 | name: String 231 | 232 | "A textual description or comment." 233 | note: String 234 | } 235 | 236 | type RecipeExchangeResponse { 237 | recipeExchange: RecipeExchange 238 | } 239 | 240 | 241 | 242 | input RecipeFlowCreateParams { 243 | "(`Action`) Relates a process input or output to a verb, such as consume, produce, work, modify, etc." 244 | action: ID! 245 | 246 | "(`RecipeResource`) The resource definition referenced by this flow in the recipe." 247 | recipeFlowResource: ID! 248 | 249 | "The amount and unit of the economic resource counted or inventoried." 250 | resourceQuantity: IMeasure 251 | 252 | "The amount and unit of the work or use or citation effort-based action. This is often a time duration, but also could be cycle counts or other measures of effort or usefulness." 253 | effortQuantity: IMeasure 254 | 255 | "(`RecipeProcess`) Relates an input flow to its process in a recipe." 256 | recipeInputOf: ID 257 | 258 | "(`RecipeProcess`) Relates an output flow to its process in a recipe." 259 | recipeOutputOf: ID 260 | 261 | "(`RecipeExchange`) Relates a flow to its exchange agreement in a recipe." 262 | recipeClauseOf: ID 263 | 264 | "(`ProcessSpecification`) References the ProcessSpecification of the last process the economic resource went through. Stage is used when the last process is important for finding proper resources, such as where the publishing process wants only documents that have gone through the editing process." 265 | stage: ID 266 | 267 | "The state of the desired economic resource (pass or fail), after coming out of a test or review process." 268 | state: String 269 | 270 | "A textual description or comment." 271 | note: String 272 | } 273 | 274 | input RecipeFlowUpdateParams { 275 | id: ID! 276 | 277 | "(`Action`) Relates a process input or output to a verb, such as consume, produce, work, modify, etc." 278 | action: ID 279 | 280 | "(`RecipeResource`) The resource definition referenced by this flow in the recipe." 281 | recipeFlowResource: ID 282 | 283 | "The amount and unit of the economic resource counted or inventoried." 284 | resourceQuantity: IMeasure 285 | 286 | "The amount and unit of the work or use or citation effort-based action. This is often a time duration, but also could be cycle counts or other measures of effort or usefulness." 287 | effortQuantity: IMeasure 288 | 289 | "(`RecipeProcess`) Relates an input flow to its process in a recipe." 290 | recipeInputOf: ID 291 | 292 | "(`RecipeProcess`) Relates an output flow to its process in a recipe." 293 | recipeOutputOf: ID 294 | 295 | "(`RecipeExchange`) Relates a flow to its exchange agreement in a recipe." 296 | recipeClauseOf: ID 297 | 298 | "(`ProcessSpecification`) References the ProcessSpecification of the last process the economic resource went through. Stage is used when the last process is important for finding proper resources, such as where the publishing process wants only documents that have gone through the editing process." 299 | stage: ID 300 | 301 | "The state of the desired economic resource (pass or fail), after coming out of a test or review process." 302 | state: String 303 | 304 | "A textual description or comment." 305 | note: String 306 | } 307 | 308 | type RecipeFlowResponse { 309 | recipeFlow: RecipeFlow 310 | } 311 | 312 | 313 | 314 | type Query { 315 | recipeFlow(id: ID): RecipeFlow 316 | recipeFlows(start: ID, limit: Int): [RecipeFlow!] 317 | 318 | recipeResource(id: ID): RecipeResource 319 | recipeResources(start: ID, limit: Int): [RecipeResource!] 320 | 321 | recipeProcess(id: ID): RecipeProcess 322 | recipeProcesses(start: ID, limit: Int): [RecipeProcess!] 323 | 324 | recipeExchange(id: ID): RecipeExchange 325 | recipeExchanges(start: ID, limit: Int): [RecipeExchange!] 326 | } 327 | 328 | type Mutation { 329 | createRecipeFlow(recipeFlow: RecipeFlowCreateParams): RecipeFlowResponse 330 | updateRecipeFlow(recipeFlow: RecipeFlowUpdateParams): RecipeFlowResponse 331 | deleteRecipeFlow(id: ID!): Boolean 332 | 333 | createRecipeResource(recipeResource: RecipeResourceCreateParams): RecipeResourceResponse 334 | updateRecipeResource(recipeResource: RecipeResourceUpdateParams): RecipeResourceResponse 335 | deleteRecipeResource(id: ID!): Boolean 336 | 337 | createRecipeProcess(recipeProcess: RecipeProcessCreateParams): RecipeProcessResponse 338 | updateRecipeProcess(recipeProcess: RecipeProcessUpdateParams): RecipeProcessResponse 339 | deleteRecipeProcess(id: ID!): Boolean 340 | 341 | createRecipeExchange(recipeExchange: RecipeExchangeCreateParams): RecipeExchangeResponse 342 | updateRecipeExchange(recipeExchange: RecipeExchangeUpdateParams): RecipeExchangeResponse 343 | deleteRecipeExchange(id: ID!): Boolean 344 | } 345 | -------------------------------------------------------------------------------- /lib/schemas/scenario.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Scenario module 4 | # 5 | # Facilitates grouping of processes together into logical collections of higher level processes. 6 | # 7 | # @depends measurement.gql 8 | # @package vf-graphql 9 | # @since 2019-02-11 10 | # 11 | ## 12 | 13 | """ 14 | An estimated or analytical logical collection of higher level processes used for budgeting, analysis, plan refinement, etc. 15 | """ 16 | type Scenario { 17 | id: ID! 18 | 19 | "An informal or formal textual identifier for a scenario. Does not imply uniqueness." 20 | name: String! 21 | 22 | "The beginning date/time of the scenario, often the beginning of an accounting period." 23 | hasBeginning: DateTime 24 | 25 | "The ending date/time of the scenario, often the end of an accounting period." 26 | hasEnd: DateTime 27 | 28 | "Grouping around something to create a boundary or context, used for documenting, accounting, planning." 29 | inScopeOf: [AccountingScope!] 30 | 31 | "The scenario definition for this scenario, for example yearly budget." 32 | definedAs: ScenarioDefinition 33 | 34 | "This scenario refines another scenario, often as time moves closer or for more detail." 35 | refinementOf: Scenario 36 | 37 | "A textual description or comment." 38 | note: String 39 | } 40 | 41 | """ 42 | The type definition of one or more scenarios, such as Yearly Budget. 43 | """ 44 | type ScenarioDefinition { 45 | id: ID! 46 | 47 | "An informal or formal textual identifier for a scenario definition. Does not imply uniqueness." 48 | name: String! 49 | 50 | "The duration of the scenario, often an accounting period." 51 | hasDuration: Duration 52 | 53 | "A textual description or comment." 54 | note: String 55 | } 56 | 57 | 58 | 59 | input ScenarioCreateParams { 60 | "An informal or formal textual identifier for a scenario. Does not imply uniqueness." 61 | name: String! 62 | 63 | "(`ScenarioDefinition`) The scenario definition for this scenario, for example yearly budget." 64 | definedAs: ID! 65 | 66 | "The beginning date/time of the scenario, often the beginning of an accounting period." 67 | hasBeginning: DateTime 68 | 69 | "The ending date/time of the scenario, often the end of an accounting period." 70 | hasEnd: DateTime 71 | 72 | "Grouping around something to create a boundary or context, used for documenting, accounting, planning." 73 | inScopeOf: [ID!] 74 | 75 | "(`Scenario`) This scenario refines another scenario, often as time moves closer or for more detail." 76 | refinementOf: ID 77 | 78 | "A textual description or comment." 79 | note: String 80 | } 81 | 82 | input ScenarioUpdateParams { 83 | id: ID! 84 | 85 | "An informal or formal textual identifier for a scenario. Does not imply uniqueness." 86 | name: String 87 | 88 | "(`ScenarioDefinition`) The scenario definition for this scenario, for example yearly budget." 89 | definedAs: ID! 90 | 91 | "The beginning date/time of the scenario, often the beginning of an accounting period." 92 | hasBeginning: DateTime 93 | 94 | "The ending date/time of the scenario, often the end of an accounting period." 95 | hasEnd: DateTime 96 | 97 | "Grouping around something to create a boundary or context, used for documenting, accounting, planning." 98 | inScopeOf: [ID!] 99 | 100 | "(`Scenario`) This scenario refines another scenario, often as time moves closer or for more detail." 101 | refinementOf: ID 102 | 103 | "A textual description or comment." 104 | note: String 105 | } 106 | 107 | type ScenarioResponse { 108 | scenario: Scenario 109 | } 110 | 111 | 112 | 113 | input ScenarioDefinitionCreateParams { 114 | "An informal or formal textual identifier for a scenario definition. Does not imply uniqueness." 115 | name: String 116 | 117 | "The duration of the scenario, often an accounting period." 118 | hasDuration: IDuration 119 | 120 | "A textual description or comment." 121 | note: String 122 | } 123 | 124 | input ScenarioDefinitionUpdateParams { 125 | id: ID! 126 | 127 | "An informal or formal textual identifier for a scenario definition. Does not imply uniqueness." 128 | name: String! 129 | 130 | "The duration of the scenario, often an accounting period." 131 | hasDuration: IDuration 132 | 133 | "A textual description or comment." 134 | note: String 135 | } 136 | 137 | type ScenarioDefinitionResponse { 138 | scenarioDefinition: ScenarioDefinition 139 | } 140 | 141 | 142 | 143 | type Query { 144 | scenario(id: ID): Scenario 145 | scenarios(start: ID, limit: Int): [Scenario!] 146 | 147 | scenarioDefinition(id: ID): ScenarioDefinition 148 | scenarioDefinitions(start: ID, limit: Int): [ScenarioDefinition!] 149 | } 150 | 151 | type Mutation { 152 | createScenario(plan: ScenarioCreateParams!): ScenarioResponse 153 | updateScenario(plan: ScenarioUpdateParams!): ScenarioResponse 154 | deleteScenario(id: ID!): Boolean 155 | 156 | createScenarioDefinition(plan: ScenarioDefinitionCreateParams!): ScenarioDefinitionResponse 157 | updateScenarioDefinition(plan: ScenarioDefinitionUpdateParams!): ScenarioDefinitionResponse 158 | deleteScenarioDefinition(id: ID!): Boolean 159 | } 160 | -------------------------------------------------------------------------------- /lib/schemas/util.gql: -------------------------------------------------------------------------------- 1 | ## 2 | # 3 | # Utility structs 4 | # 5 | # These are common data structures used throughout the API 6 | # 7 | ## 8 | 9 | """ 10 | The `URI` type simply declares a reference to an external web URL, Holochain entry or other resource. 11 | """ 12 | scalar URI 13 | 14 | """ 15 | The `DateTime` scalar type represents a DateTime value as specified by 16 | [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601). 17 | """ 18 | scalar DateTime 19 | -------------------------------------------------------------------------------- /lib/scripts/build.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Build script for packaging the GraphQL source files as nodejs modules 3 | * 4 | * @package: HoloREA 5 | * @since: 2019-05-22 6 | * @flow 7 | */ 8 | 9 | const fs = require('fs') 10 | const path = require('path') 11 | const globby = require('globby') 12 | 13 | const { 14 | graphqlSync, 15 | getIntrospectionQuery, 16 | buildASTSchema, 17 | printSchema, 18 | } = require('graphql') 19 | const { mergeTypeDefs } = require('@graphql-tools/merge') 20 | const { fromIntrospectionQuery } = require('graphql-2-json-schema') 21 | 22 | // template for precompiled output JS files 23 | const TEMPLATE = ` 24 | // Generated by scripts/build.js - edit the *.gql file instead! 25 | 26 | module.exports = \` 27 | $SCHEMA_DOCUMENT 28 | \` 29 | ` 30 | 31 | // templates for schemas manifest 32 | const TYPEDEFS_TEMPLATE = ` 33 | // Generated by scripts/build.js - any edits to this file will be wiped upon building! 34 | 35 | module.exports = { 36 | schemaModules: { 37 | $SCHEMA_MODULES 38 | }, 39 | bridgingSchemas: { 40 | $BRIDGING_SCHEMAS 41 | }, 42 | } 43 | ` 44 | const REQUIRE_BLOCK = (builtSchemaFilename) => ` '${builtSchemaFilename}': require('./build/${builtSchemaFilename}'),` 45 | 46 | // BEGIN BUILD SCRIPT LOGIC 47 | ;(async() => { 48 | const typeDefs = [] 49 | const schemaModules = [] 50 | const bridgingSchemas = [] 51 | 52 | for await (const filePath of globby.stream(path.resolve(__dirname, `../schemas/**/*.gql`))) { 53 | const doc = fs.readFileSync(filePath) 54 | const docString = doc.toString() 55 | const fileId = path.basename(filePath, '.gql') 56 | 57 | // bundle each schema file as a nodejs module that exports a string 58 | fs.writeFileSync( 59 | path.resolve(__dirname, `../build/${fileId}.js`), 60 | TEMPLATE.replace('$SCHEMA_DOCUMENT', docString.replace(/`/g, '\\`')) 61 | ) 62 | 63 | // append to complete schema 64 | typeDefs.push(docString) 65 | 66 | // track module IDs 67 | if (path.dirname(filePath).match(/bridging$/)) { 68 | bridgingSchemas.push(fileId) 69 | } else { 70 | schemaModules.push(fileId) 71 | } 72 | } 73 | 74 | // compile full schema by merging all parts. This also has the side effect of validating the input files. 75 | const schema = buildASTSchema(mergeTypeDefs(typeDefs, { throwOnConflict: true })) 76 | 77 | // write an SDL version of the full merged schema 78 | fs.writeFileSync( 79 | path.resolve(__dirname, `../ALL_VF_SDL.js`), 80 | TEMPLATE.replace('$SCHEMA_DOCUMENT', printSchema(schema).replace(/`/g, '\\`')) 81 | ) 82 | 83 | // generate & write JSON Schema version by running introspection query. Also performs runtime validation of the schema. 84 | const introspection = graphqlSync({ schema, source: getIntrospectionQuery() }) 85 | 86 | if (!introspection) { 87 | throw new Error('Unknown error executing introspection query. Schema may be invalid- does `npm run test` pass?') 88 | } else if (introspection.error) { 89 | throw introspection.error 90 | } else if (introspection.errors) { 91 | introspection.errors.forEach(e => console.error('\x1b[1m\x1b[31mGraphQL schema error\x1b[0m ' + e.message)) 92 | process.exit(1) 93 | } 94 | 95 | fs.writeFileSync( 96 | path.resolve(__dirname, `../json-schema.json`), 97 | JSON.stringify(fromIntrospectionQuery(introspection.data), undefined, 2) 98 | ) 99 | 100 | // write schemas manifest 101 | fs.writeFileSync( 102 | path.resolve(__dirname, `../schema-manifest.js`), 103 | TYPEDEFS_TEMPLATE 104 | .replace('$SCHEMA_MODULES', schemaModules.map(REQUIRE_BLOCK).join('\n')) 105 | .replace('$BRIDGING_SCHEMAS', bridgingSchemas.map(REQUIRE_BLOCK).join('\n')) 106 | ) 107 | 108 | // copy meta files from project root 109 | fs.copyFileSync(path.resolve(__dirname, '../../LICENSE'), path.resolve(__dirname, '../LICENSE')) 110 | fs.copyFileSync(path.resolve(__dirname, '../../README.md'), path.resolve(__dirname, '../README.md')) 111 | fs.copyFileSync(path.resolve(__dirname, '../../CHANGELOG.md'), path.resolve(__dirname, '../CHANGELOG.md')) 112 | })() 113 | -------------------------------------------------------------------------------- /lib/scripts/clean.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Build clean script 4 | # 5 | # @package: 6 | # @author: pospi 7 | # @since: 2020-06-06 8 | # 9 | ## 10 | 11 | rm -Rf build >/dev/null 2>&1 12 | rm json-schema.json >/dev/null 2>&1 13 | rm schema-manifest.js >/dev/null 2>&1 14 | rm ALL_VF_SDL.js >/dev/null 2>&1 15 | rm index.d.ts >/dev/null 2>&1 16 | rm index.flow.js >/dev/null 2>&1 17 | rm LICENSE >/dev/null 2>&1 18 | rm CHANGELOG.md >/dev/null 2>&1 19 | rm README.md >/dev/null 2>&1 20 | 21 | exit 0 22 | -------------------------------------------------------------------------------- /lib/scripts/codegen.yml: -------------------------------------------------------------------------------- 1 | overwrite: true 2 | schema: "./schemas/**/*.gql" 3 | # documents: "./ops" 4 | config: 5 | scalars: 6 | DateTime: Date 7 | URI: string 8 | generates: 9 | index.d.ts: 10 | plugins: 11 | - "typescript" 12 | # :TODO: does not support interface types yet 13 | # index.re: 14 | # - reason-client 15 | index.flow.js: 16 | plugins: 17 | - flow 18 | #build/graphql.tsx: 19 | #plugins: 20 | #- "typescript-react-apollo" 21 | #- "typescript-operations" 22 | #build/graphql.d.ts: 23 | #plugins: 24 | #- "typescript-graphql-files-modules" 25 | -------------------------------------------------------------------------------- /lib/tests/helpers.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Test helpers 3 | * 4 | * @package: vf-graphql 5 | * @since: 2020-03-29 6 | */ 7 | 8 | const { 9 | graphqlSync, 10 | introspectionQuery, 11 | } = require('graphql') 12 | const { makeExecutableSchema, addMockFunctionsToSchema } = require('graphql-tools') 13 | 14 | function makeMockSchema(typeDefs) { 15 | const schema = makeExecutableSchema({ typeDefs }) 16 | addMockFunctionsToSchema({ schema }) 17 | return schema 18 | } 19 | 20 | function exerciseSchema(schema) { 21 | // Perform runtime validation of the schema via introspection query 22 | const introspection = graphqlSync(schema, introspectionQuery) 23 | if (!introspection) { 24 | throw new Error('Unknown error executing introspection query. Schema may be invalid.') 25 | } else if (introspection.error) { 26 | throw introspection.error 27 | } else if (introspection.errors) { 28 | const errsList = introspection.errors.map(e => e.message) 29 | throw new Error('Query runtime compilation failure:\n' + errsList.join('\n\t')) 30 | } 31 | } 32 | 33 | module.exports = { 34 | makeMockSchema, 35 | exerciseSchema, 36 | } 37 | -------------------------------------------------------------------------------- /lib/tests/test-custom-extensions.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Ensure custom schema extensions operate as expected 3 | * 4 | * @package: vf-graphql 5 | * @since: 2020-03-29 6 | */ 7 | 8 | const test = require('tape-catch') 9 | 10 | const { buildSchema, printSchema } = require('../') 11 | 12 | test('custom extensions', (t) => { 13 | const knowledgeExtensions = ` 14 | type ResourceSpecification { 15 | customResourceTypeAttribute: String 16 | } 17 | 18 | type NewCustomType { 19 | field: ID 20 | } 21 | ` 22 | 23 | const schema = printSchema(buildSchema([ 24 | 'measurement', 'knowledge', 25 | ], [ 26 | knowledgeExtensions, 27 | ])) 28 | 29 | t.ok(schema.match(/type ResourceSpecification \{(.|\n)*?customResourceTypeAttribute: String(.|\n)*?\}/gm), 'injected attribute not found') 30 | t.ok(schema.match(/type NewCustomType \{(\s|\n)+?field: ID(\s|\n)+?\}/gm), 'injected type not found') 31 | 32 | t.end() 33 | }) 34 | -------------------------------------------------------------------------------- /lib/tests/test-module-configurations.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Ensures that different module configurations compile OK (no fields are missing in given combinations) 3 | * 4 | * @package: vf-graphql 5 | * @since: 2020-03-29 6 | */ 7 | 8 | const test = require('tape-catch') 9 | 10 | const { makeMockSchema, exerciseSchema } = require('./helpers') 11 | const { buildSchema, printSchema } = require('../') 12 | 13 | test('configuration: standalone agent', (t) => { 14 | const schema = makeMockSchema(printSchema(buildSchema([ 15 | 'agent', 16 | ]))) 17 | exerciseSchema(schema) 18 | t.end() 19 | }) 20 | 21 | test('configuration: agent mapping', (t) => { 22 | const schema = makeMockSchema(printSchema(buildSchema([ 23 | 'agent', 'geolocation', 24 | ]))) 25 | exerciseSchema(schema) 26 | t.end() 27 | }) 28 | 29 | test('configuration: observation only', (t) => { 30 | const schema = makeMockSchema(printSchema(buildSchema([ 31 | 'knowledge', 'measurement', 32 | 'agent', 33 | 'observation', 34 | ]))) 35 | exerciseSchema(schema) 36 | t.end() 37 | }) 38 | 39 | test('configuration: observation + geo', (t) => { 40 | const schema = makeMockSchema(printSchema(buildSchema([ 41 | 'knowledge', 'measurement', 42 | 'agent', 43 | 'observation', 44 | 'geolocation', 45 | ]))) 46 | exerciseSchema(schema) 47 | t.end() 48 | }) 49 | 50 | test('configuration: observation & planning', (t) => { 51 | const schema = makeMockSchema(printSchema(buildSchema([ 52 | 'knowledge', 'measurement', 53 | 'agent', 54 | 'observation', 'planning', 55 | ]))) 56 | exerciseSchema(schema) 57 | t.end() 58 | }) 59 | 60 | test('configuration: observation & planning + geo', (t) => { 61 | const schema = makeMockSchema(printSchema(buildSchema([ 62 | 'knowledge', 'measurement', 63 | 'agent', 64 | 'observation', 'planning', 65 | 'geolocation', 66 | ]))) 67 | exerciseSchema(schema) 68 | t.end() 69 | }) 70 | 71 | test('configuration: observation, planning & recipe', (t) => { 72 | const schema = makeMockSchema(printSchema(buildSchema([ 73 | 'knowledge', 'measurement', 74 | 'agent', 75 | 'observation', 'planning', 'recipe', 76 | ]))) 77 | exerciseSchema(schema) 78 | t.end() 79 | }) 80 | 81 | test('configuration: observation, planning & recipe + geo', (t) => { 82 | const schema = makeMockSchema(printSchema(buildSchema([ 83 | 'knowledge', 'measurement', 84 | 'agent', 85 | 'observation', 'planning', 'recipe', 86 | 'geolocation', 87 | ]))) 88 | exerciseSchema(schema) 89 | t.end() 90 | }) 91 | 92 | test('configuration: recipe only', (t) => { 93 | const schema = makeMockSchema(printSchema(buildSchema([ 94 | 'knowledge', 'measurement', 95 | 'recipe', 96 | ]))) 97 | exerciseSchema(schema) 98 | t.end() 99 | }) 100 | 101 | // :TODO: support "planning only" 102 | 103 | test('configuration: observation, planning & proposal', (t) => { 104 | const schema = makeMockSchema(printSchema(buildSchema([ 105 | 'knowledge', 'measurement', 106 | 'agent', 107 | 'observation', 'planning', 108 | 'proposal', 109 | ]))) 110 | exerciseSchema(schema) 111 | t.end() 112 | }) 113 | 114 | test('configuration: observation, planning & proposal + geo', (t) => { 115 | const schema = makeMockSchema(printSchema(buildSchema([ 116 | 'knowledge', 'measurement', 117 | 'agent', 118 | 'observation', 'planning', 119 | 'proposal', 120 | 'geolocation', 121 | ]))) 122 | exerciseSchema(schema) 123 | t.end() 124 | }) 125 | 126 | test('configuration: observation, planning, recipe & proposal', (t) => { 127 | const schema = makeMockSchema(printSchema(buildSchema([ 128 | 'knowledge', 'measurement', 129 | 'agent', 130 | 'observation', 'planning', 'recipe', 131 | 'proposal', 132 | ]))) 133 | exerciseSchema(schema) 134 | t.end() 135 | }) 136 | 137 | test('configuration: observation, planning, recipe & proposal + geo', (t) => { 138 | const schema = makeMockSchema(printSchema(buildSchema([ 139 | 'knowledge', 'measurement', 140 | 'agent', 141 | 'observation', 'planning', 'recipe', 142 | 'proposal', 143 | 'geolocation', 144 | ]))) 145 | exerciseSchema(schema) 146 | t.end() 147 | }) 148 | 149 | test('configuration: observation, planning & agreement', (t) => { 150 | const schema = makeMockSchema(printSchema(buildSchema([ 151 | 'knowledge', 'measurement', 152 | 'agent', 153 | 'observation', 'planning', 154 | 'agreement', 155 | ]))) 156 | exerciseSchema(schema) 157 | t.end() 158 | }) 159 | 160 | test('configuration: observation, planning & agreement + geo', (t) => { 161 | const schema = makeMockSchema(printSchema(buildSchema([ 162 | 'knowledge', 'measurement', 163 | 'agent', 164 | 'observation', 'planning', 165 | 'agreement', 166 | 'geolocation', 167 | ]))) 168 | exerciseSchema(schema) 169 | t.end() 170 | }) 171 | 172 | test('configuration: observation, planning, recipe & agreement', (t) => { 173 | const schema = makeMockSchema(printSchema(buildSchema([ 174 | 'knowledge', 'measurement', 175 | 'agent', 176 | 'observation', 'planning', 'recipe', 177 | 'agreement', 178 | ]))) 179 | exerciseSchema(schema) 180 | t.end() 181 | }) 182 | 183 | test('configuration: observation, planning, recipe & agreement + geo', (t) => { 184 | const schema = makeMockSchema(printSchema(buildSchema([ 185 | 'knowledge', 'measurement', 186 | 'agent', 187 | 'observation', 'planning', 'recipe', 188 | 'agreement', 189 | 'geolocation', 190 | ]))) 191 | exerciseSchema(schema) 192 | t.end() 193 | }) 194 | 195 | test('configuration: observation, planning & governance', (t) => { 196 | const schema = makeMockSchema(printSchema(buildSchema([ 197 | 'knowledge', 'measurement', 198 | 'agent', 199 | 'observation', 'planning', 200 | 'proposal', 'agreement', 201 | ]))) 202 | exerciseSchema(schema) 203 | t.end() 204 | }) 205 | 206 | test('configuration: observation, planning & governance + geo', (t) => { 207 | const schema = makeMockSchema(printSchema(buildSchema([ 208 | 'knowledge', 'measurement', 209 | 'agent', 210 | 'observation', 'planning', 211 | 'proposal', 'agreement', 212 | 'geolocation', 213 | ]))) 214 | exerciseSchema(schema) 215 | t.end() 216 | }) 217 | 218 | test('configuration: observation, planning, recipe & governance', (t) => { 219 | const schema = makeMockSchema(printSchema(buildSchema([ 220 | 'knowledge', 'measurement', 221 | 'agent', 222 | 'observation', 'planning', 'recipe', 223 | 'proposal', 'agreement', 224 | ]))) 225 | exerciseSchema(schema) 226 | t.end() 227 | }) 228 | 229 | test('configuration: observation, planning, recipe & governance + geo', (t) => { 230 | const schema = makeMockSchema(printSchema(buildSchema([ 231 | 'knowledge', 'measurement', 232 | 'agent', 233 | 'observation', 'planning', 'recipe', 234 | 'proposal', 'agreement', 235 | 'geolocation', 236 | ]))) 237 | exerciseSchema(schema) 238 | t.end() 239 | }) 240 | 241 | // misc modules - testing in most isolated configurations only 242 | 243 | test('configuration: gift economies', (t) => { 244 | const schema = makeMockSchema(printSchema(buildSchema([ 245 | 'knowledge', 'measurement', 246 | 'agent', 247 | 'observation', 248 | 'appreciation', 249 | ]))) 250 | exerciseSchema(schema) 251 | t.end() 252 | }) 253 | 254 | test('configuration: future claims', (t) => { 255 | const schema = makeMockSchema(printSchema(buildSchema([ 256 | 'knowledge', 'measurement', 257 | 'agent', 258 | 'observation', 259 | 'claim', 260 | ]))) 261 | exerciseSchema(schema) 262 | t.end() 263 | }) 264 | 265 | -------------------------------------------------------------------------------- /lib/tests/test-schema-parse.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Ensures that the schema is valid 3 | * 4 | * @package: vf-graphql 5 | * @since: 2019-02-11 6 | */ 7 | 8 | const test = require('tape-catch') 9 | 10 | const { makeMockSchema, exerciseSchema } = require('./helpers') 11 | const { buildSchema, printSchema } = require('../') 12 | 13 | test('schema compiles', (t) => { 14 | const schema = makeMockSchema(printSchema(buildSchema())) 15 | exerciseSchema(schema) 16 | t.end() 17 | }) 18 | -------------------------------------------------------------------------------- /mock-client/README.md: -------------------------------------------------------------------------------- 1 | # ValueFlows GraphQL client mock 2 | 3 | Apollo `GraphQLClient` configuration to serve randomly generated mock data through the [ValueFlows GraphQL API spec](https://lab.allmende.io/valueflows/vf-schemas/vf-graphql). 4 | 5 | 6 | 7 | - [Other ValueFlows GraphQL clients](#other-valueflows-graphql-clients) 8 | - [License](#license) 9 | 10 | 11 | 12 | Exports an asynchronous function which (eventually) returns a GraphQL client ready to be plugged in to a testing framework or development application. 13 | 14 | Directly pluggable with other ValueFlows-compatible GraphQL client modules- simply change the module name! 15 | 16 | 17 | ## Other ValueFlows GraphQL clients 18 | 19 | - [Holochain API client](https://github.com/holo-rea/app-offers-needs-marketplace/tree/sprout/src/graphql-client) based on the [Holo-REA](https://github.com/holo-rea/holo-rea/tree/sprout/modules/vf-graphql-holochain) implementation 20 | 21 | 22 | ## License 23 | 24 | Released under an Apache 2.0 license. 25 | -------------------------------------------------------------------------------- /mock-client/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ValueFlows GraphQLClient mock 3 | * 4 | * Serves random mock datasources through the VF API 5 | * 6 | * @package: ValueFlows GraphQL client mock 7 | * @since: 2020-08-07 8 | */ 9 | 10 | import { ApolloClient } from 'apollo-client' 11 | import { SchemaLink } from 'apollo-link-schema' 12 | import { InMemoryCache } from 'apollo-cache-inmemory' 13 | import { addMocksToSchema } from '@graphql-tools/mock' 14 | import { buildSchema } from '@valueflows/vf-graphql' 15 | 16 | const schema = addMocksToSchema({ 17 | schema: buildSchema(), 18 | mocks: { 19 | URI: () => 'http://example.com/thing', 20 | DateTime: () => new Date().toISOString(), 21 | }, 22 | }) 23 | 24 | function initClient() { 25 | return new Promise((resolve, reject) => resolve( 26 | new ApolloClient({ 27 | cache: new InMemoryCache(), 28 | link: new SchemaLink({ schema }) 29 | }) 30 | )) 31 | } 32 | 33 | export default initClient 34 | -------------------------------------------------------------------------------- /mock-client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@vf-ui/graphql-client-mock", 3 | "version": "0.0.1", 4 | "description": "A preconfigured GraphQLClient for testing the ValueFlows schema with mock data.", 5 | "main": "index.js", 6 | "type": "module", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+ssh://git@github.com/valueflows/vf-graphql.git" 13 | }, 14 | "keywords": [ 15 | "ValueFlows", 16 | "GraphQL", 17 | "server", 18 | "mock" 19 | ], 20 | "author": "ValueFlows project contributors", 21 | "license": "Apache-2.0", 22 | "bugs": { 23 | "url": "https://github.com/valueflows/vf-graphql/issues" 24 | }, 25 | "homepage": "https://github.com/valueflows/vf-graphql#readme", 26 | "dependencies": { 27 | "apollo-client": "^2.6.0", 28 | "apollo-cache-inmemory": "^1.6.6", 29 | "apollo-link-schema": "^1.2.5", 30 | "@valueflows/vf-graphql": "^0.8", 31 | "@graphql-tools/mock": "^6.0.7" 32 | }, 33 | "peerDependencies": { 34 | "graphql": ">=14" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /mock-server/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * GraphQL / iQL server 3 | * 4 | * @package: HoloREA 5 | * @author: pospi 6 | * @since: 2019-03-18 7 | */ 8 | 9 | const express = require('express') 10 | const { ApolloServer } = require('apollo-server-express') 11 | const { express: voyagerMiddleware } = require('graphql-voyager/middleware') 12 | const { addMocksToSchema } = require('@graphql-tools/mock') 13 | 14 | const SERVER_PORT = process.env.PORT || 3000 15 | const SCHEMA_VIEWER_PATH = '/viewer' 16 | 17 | const { buildSchema } = require('@valueflows/vf-graphql') 18 | 19 | const schema = addMocksToSchema({ 20 | schema: buildSchema(), 21 | mocks: { 22 | URI: () => 'http://example.com/thing', 23 | DateTime: () => new Date().toISOString(), 24 | }, 25 | }) 26 | 27 | const server = new ApolloServer({ schema }) 28 | 29 | const app = express() 30 | server.applyMiddleware({ app }) 31 | 32 | app.use(SCHEMA_VIEWER_PATH, voyagerMiddleware({ 33 | endpointUrl: server.graphqlPath, 34 | displayOptions: { 35 | hideRoot: true, 36 | showLeafFields: true, 37 | }, 38 | })) 39 | 40 | app.listen({ port: SERVER_PORT }, () => 41 | console.log(`🚀🚀🚀 42 | Query browser at http://localhost:${SERVER_PORT}${server.graphqlPath} 43 | Schema visualiser at http://localhost:${SERVER_PORT}${SCHEMA_VIEWER_PATH} 44 | 🚀🚀🚀`) 45 | ) 46 | -------------------------------------------------------------------------------- /mock-server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@valueflows/vf-graphql-server-mock", 3 | "version": "0.0.1", 4 | "description": "GraphQL / GraphiQL interface to a static ValueFlows-based economic system", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "node index.js", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+ssh://git@github.com/valueflows/vf-graphql.git" 13 | }, 14 | "keywords": [ 15 | "ValueFlows", 16 | "GraphQL", 17 | "server", 18 | "mock" 19 | ], 20 | "author": "ValueFlows project contributors", 21 | "license": "MIT", 22 | "bugs": { 23 | "url": "https://github.com/valueflows/vf-graphql/issues" 24 | }, 25 | "homepage": "https://github.com/valueflows/vf-graphql#readme", 26 | "dependencies": { 27 | "@valueflows/vf-graphql": "^0.8", 28 | "@graphql-tools/mock": "^6.0.7", 29 | "apollo-server-express": "^2.14.2", 30 | "express": "^4.17.1", 31 | "graphql": "^15.0.0", 32 | "graphql-voyager": "^1.0.0-rc.31" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@valueflows/vf-graphql-monorepo", 3 | "version": "0.0.1", 4 | "private": true, 5 | "description": "ValueFlows reference GraphQL spec, authored in GraphQL SDL; plus validator methods for apps wishing to adhere to the spec.", 6 | "main": "/dev/null", 7 | "scripts": { 8 | "preinstall": "npx only-allow pnpm && npm run clean", 9 | "build": "cd lib && npm run build", 10 | "publish": "cd lib && npm publish --access public", 11 | "start": "npm-run-all --parallel dev:schema dev:demoUI", 12 | "test": "cd tests && npm run test", 13 | "dev:schema": "cd lib && npm run dev", 14 | "dev:demoUI": "cd mock-server && npm start", 15 | "clean": "rm -Rf node_modules; rm -Rf mock-server/node_modules; rm -Rf lib/node_modules; rm -Rf tests/node_modules; cd lib && npm run clean" 16 | }, 17 | "repository": { 18 | "type": "git", 19 | "url": "git+https://github.com/holo-rea/holo-rea-proto.git" 20 | }, 21 | "keywords": [ 22 | "REA", 23 | "Holochain", 24 | "Open Value Network", 25 | "OpenValueNetwork", 26 | "OVN", 27 | "economic", 28 | "cooperative", 29 | "coordination" 30 | ], 31 | "author": "HoloREA team & contributors", 32 | "license": "Apache-2.0", 33 | "bugs": { 34 | "url": "https://github.com/holo-rea/holo-rea-proto.git/issues" 35 | }, 36 | "homepage": "https://github.com/holo-rea/holo-rea-proto#readme", 37 | "dependencies": { 38 | "graphql": "^15.0.0" 39 | }, 40 | "devDependencies": { 41 | "npm-run-all": "^4.1.5" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - 'lib' 3 | - 'mock-client' 4 | - 'mock-server' 5 | - 'tests' 6 | -------------------------------------------------------------------------------- /tests/helpers.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Test helpers 3 | * 4 | * @package: vf-graphql 5 | * @since: 2020-03-29 6 | */ 7 | 8 | const { 9 | graphqlSync, 10 | getIntrospectionQuery, 11 | } = require('graphql') 12 | const { makeExecutableSchema } = require('@graphql-tools/schema') 13 | const { addMocksToSchema } = require('@graphql-tools/mock') 14 | 15 | function makeMockSchema(typeDefs) { 16 | const schema = makeExecutableSchema({ typeDefs }) 17 | addMocksToSchema({ schema }) 18 | return schema 19 | } 20 | 21 | function exerciseSchema(schema) { 22 | // Perform runtime validation of the schema via introspection query 23 | const introspection = graphqlSync({ schema, source: getIntrospectionQuery() }) 24 | if (!introspection) { 25 | throw new Error('Unknown error executing introspection query. Schema may be invalid.') 26 | } else if (introspection.error) { 27 | throw introspection.error 28 | } else if (introspection.errors) { 29 | const errsList = introspection.errors.map(e => e.message) 30 | throw new Error('Query runtime compilation failure:\n' + errsList.join('\n\t')) 31 | } 32 | } 33 | 34 | module.exports = { 35 | makeMockSchema, 36 | exerciseSchema, 37 | } 38 | -------------------------------------------------------------------------------- /tests/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@valueflows/vf-graphql-tests", 3 | "version": "0.0.0", 4 | "private": true, 5 | "description": "Test module for vf-graphql spec", 6 | "main": "/dev/null", 7 | "scripts": { 8 | "test": "tape test-*.js | faucet" 9 | }, 10 | "dependencies": { 11 | "graphql": "^15.0.0" 12 | }, 13 | "devDependencies": { 14 | "@graphql-tools/schema": "^6.0.7", 15 | "@graphql-tools/mock": "^6.0.7", 16 | "faucet": "0.0.1", 17 | "tape": "^4.10.0", 18 | "tape-catch": "^1.0.6" 19 | }, 20 | "author": "ValueFlows contributors", 21 | "license": "Apache-2.0" 22 | } 23 | -------------------------------------------------------------------------------- /tests/test-custom-extensions.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Ensure custom schema extensions operate as expected 3 | * 4 | * @package: vf-graphql 5 | * @since: 2020-03-29 6 | */ 7 | 8 | const test = require('tape-catch') 9 | 10 | const { buildSchema, printSchema } = require('../lib') 11 | 12 | test('custom extensions', (t) => { 13 | const knowledgeExtensions = ` 14 | type ResourceSpecification { 15 | customResourceTypeAttribute: String 16 | } 17 | 18 | type NewCustomType { 19 | field: ID 20 | } 21 | ` 22 | 23 | const schema = printSchema(buildSchema([ 24 | 'measurement', 'knowledge', 25 | ], [ 26 | knowledgeExtensions, 27 | ])) 28 | 29 | t.ok(schema.match(/type ResourceSpecification \{(.|\n)*?customResourceTypeAttribute: String(.|\n)*?\}/gm), 'injected attribute not found') 30 | t.ok(schema.match(/type NewCustomType \{(\s|\n)+?field: ID(\s|\n)+?\}/gm), 'injected type not found') 31 | 32 | t.end() 33 | }) 34 | -------------------------------------------------------------------------------- /tests/test-module-configurations.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Ensures that different module configurations compile OK (no fields are missing in given combinations) 3 | * 4 | * @package: vf-graphql 5 | * @since: 2020-03-29 6 | */ 7 | 8 | const test = require('tape-catch') 9 | 10 | const { makeMockSchema, exerciseSchema } = require('./helpers') 11 | const { buildSchema, printSchema } = require('../lib') 12 | 13 | test('configuration: standalone agent', (t) => { 14 | const schema = makeMockSchema(printSchema(buildSchema([ 15 | 'agent', 16 | ]))) 17 | exerciseSchema(schema) 18 | t.end() 19 | }) 20 | 21 | test('configuration: agent mapping', (t) => { 22 | const schema = makeMockSchema(printSchema(buildSchema([ 23 | 'agent', 'geolocation', 24 | ]))) 25 | exerciseSchema(schema) 26 | t.end() 27 | }) 28 | 29 | test('configuration: observation only', (t) => { 30 | const schema = makeMockSchema(printSchema(buildSchema([ 31 | 'knowledge', 'measurement', 32 | 'agent', 33 | 'observation', 34 | ]))) 35 | exerciseSchema(schema) 36 | t.end() 37 | }) 38 | 39 | test('configuration: observation + geo', (t) => { 40 | const schema = makeMockSchema(printSchema(buildSchema([ 41 | 'knowledge', 'measurement', 42 | 'agent', 43 | 'observation', 44 | 'geolocation', 45 | ]))) 46 | exerciseSchema(schema) 47 | t.end() 48 | }) 49 | 50 | test('configuration: observation & planning', (t) => { 51 | const schema = makeMockSchema(printSchema(buildSchema([ 52 | 'knowledge', 'measurement', 53 | 'agent', 54 | 'observation', 'planning', 55 | ]))) 56 | exerciseSchema(schema) 57 | t.end() 58 | }) 59 | 60 | test('configuration: observation & planning + geo', (t) => { 61 | const schema = makeMockSchema(printSchema(buildSchema([ 62 | 'knowledge', 'measurement', 63 | 'agent', 64 | 'observation', 'planning', 65 | 'geolocation', 66 | ]))) 67 | exerciseSchema(schema) 68 | t.end() 69 | }) 70 | 71 | test('configuration: observation, planning & recipe', (t) => { 72 | const schema = makeMockSchema(printSchema(buildSchema([ 73 | 'knowledge', 'measurement', 74 | 'agent', 75 | 'observation', 'planning', 'recipe', 76 | ]))) 77 | exerciseSchema(schema) 78 | t.end() 79 | }) 80 | 81 | test('configuration: observation, planning & recipe + geo', (t) => { 82 | const schema = makeMockSchema(printSchema(buildSchema([ 83 | 'knowledge', 'measurement', 84 | 'agent', 85 | 'observation', 'planning', 'recipe', 86 | 'geolocation', 87 | ]))) 88 | exerciseSchema(schema) 89 | t.end() 90 | }) 91 | 92 | test('configuration: recipe only', (t) => { 93 | const schema = makeMockSchema(printSchema(buildSchema([ 94 | 'knowledge', 'measurement', 95 | 'recipe', 96 | ]))) 97 | exerciseSchema(schema) 98 | t.end() 99 | }) 100 | 101 | // :TODO: support "planning only" 102 | 103 | test('configuration: observation, planning & proposal', (t) => { 104 | const schema = makeMockSchema(printSchema(buildSchema([ 105 | 'knowledge', 'measurement', 106 | 'agent', 107 | 'observation', 'planning', 108 | 'proposal', 109 | ]))) 110 | exerciseSchema(schema) 111 | t.end() 112 | }) 113 | 114 | test('configuration: observation, planning & proposal + geo', (t) => { 115 | const schema = makeMockSchema(printSchema(buildSchema([ 116 | 'knowledge', 'measurement', 117 | 'agent', 118 | 'observation', 'planning', 119 | 'proposal', 120 | 'geolocation', 121 | ]))) 122 | exerciseSchema(schema) 123 | t.end() 124 | }) 125 | 126 | test('configuration: observation, planning, recipe & proposal', (t) => { 127 | const schema = makeMockSchema(printSchema(buildSchema([ 128 | 'knowledge', 'measurement', 129 | 'agent', 130 | 'observation', 'planning', 'recipe', 131 | 'proposal', 132 | ]))) 133 | exerciseSchema(schema) 134 | t.end() 135 | }) 136 | 137 | test('configuration: observation, planning, recipe & proposal + geo', (t) => { 138 | const schema = makeMockSchema(printSchema(buildSchema([ 139 | 'knowledge', 'measurement', 140 | 'agent', 141 | 'observation', 'planning', 'recipe', 142 | 'proposal', 143 | 'geolocation', 144 | ]))) 145 | exerciseSchema(schema) 146 | t.end() 147 | }) 148 | 149 | test('configuration: observation, planning & agreement', (t) => { 150 | const schema = makeMockSchema(printSchema(buildSchema([ 151 | 'knowledge', 'measurement', 152 | 'agent', 153 | 'observation', 'planning', 154 | 'agreement', 155 | ]))) 156 | exerciseSchema(schema) 157 | t.end() 158 | }) 159 | 160 | test('configuration: observation, planning & agreement + geo', (t) => { 161 | const schema = makeMockSchema(printSchema(buildSchema([ 162 | 'knowledge', 'measurement', 163 | 'agent', 164 | 'observation', 'planning', 165 | 'agreement', 166 | 'geolocation', 167 | ]))) 168 | exerciseSchema(schema) 169 | t.end() 170 | }) 171 | 172 | test('configuration: observation, planning, recipe & agreement', (t) => { 173 | const schema = makeMockSchema(printSchema(buildSchema([ 174 | 'knowledge', 'measurement', 175 | 'agent', 176 | 'observation', 'planning', 'recipe', 177 | 'agreement', 178 | ]))) 179 | exerciseSchema(schema) 180 | t.end() 181 | }) 182 | 183 | test('configuration: observation, planning, recipe & agreement + geo', (t) => { 184 | const schema = makeMockSchema(printSchema(buildSchema([ 185 | 'knowledge', 'measurement', 186 | 'agent', 187 | 'observation', 'planning', 'recipe', 188 | 'agreement', 189 | 'geolocation', 190 | ]))) 191 | exerciseSchema(schema) 192 | t.end() 193 | }) 194 | 195 | test('configuration: observation, planning & governance', (t) => { 196 | const schema = makeMockSchema(printSchema(buildSchema([ 197 | 'knowledge', 'measurement', 198 | 'agent', 199 | 'observation', 'planning', 200 | 'proposal', 'agreement', 201 | ]))) 202 | exerciseSchema(schema) 203 | t.end() 204 | }) 205 | 206 | test('configuration: observation, planning & governance + geo', (t) => { 207 | const schema = makeMockSchema(printSchema(buildSchema([ 208 | 'knowledge', 'measurement', 209 | 'agent', 210 | 'observation', 'planning', 211 | 'proposal', 'agreement', 212 | 'geolocation', 213 | ]))) 214 | exerciseSchema(schema) 215 | t.end() 216 | }) 217 | 218 | test('configuration: observation, planning, recipe & governance', (t) => { 219 | const schema = makeMockSchema(printSchema(buildSchema([ 220 | 'knowledge', 'measurement', 221 | 'agent', 222 | 'observation', 'planning', 'recipe', 223 | 'proposal', 'agreement', 224 | ]))) 225 | exerciseSchema(schema) 226 | t.end() 227 | }) 228 | 229 | test('configuration: observation, planning, recipe & governance + geo', (t) => { 230 | const schema = makeMockSchema(printSchema(buildSchema([ 231 | 'knowledge', 'measurement', 232 | 'agent', 233 | 'observation', 'planning', 'recipe', 234 | 'proposal', 'agreement', 235 | 'geolocation', 236 | ]))) 237 | exerciseSchema(schema) 238 | t.end() 239 | }) 240 | 241 | // misc modules - testing in most isolated configurations only 242 | 243 | test('configuration: gift economies', (t) => { 244 | const schema = makeMockSchema(printSchema(buildSchema([ 245 | 'knowledge', 'measurement', 246 | 'agent', 247 | 'observation', 248 | 'appreciation', 249 | ]))) 250 | exerciseSchema(schema) 251 | t.end() 252 | }) 253 | 254 | test('configuration: future claims', (t) => { 255 | const schema = makeMockSchema(printSchema(buildSchema([ 256 | 'knowledge', 'measurement', 257 | 'agent', 258 | 'observation', 259 | 'claim', 260 | ]))) 261 | exerciseSchema(schema) 262 | t.end() 263 | }) 264 | 265 | -------------------------------------------------------------------------------- /tests/test-schema-parse.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Ensures that the schema is valid 3 | * 4 | * @package: vf-graphql 5 | * @since: 2019-02-11 6 | */ 7 | 8 | const test = require('tape-catch') 9 | 10 | const { makeMockSchema, exerciseSchema } = require('./helpers') 11 | const { buildSchema, printSchema } = require('../lib') 12 | 13 | test('schema compiles', (t) => { 14 | const schema = makeMockSchema(printSchema(buildSchema())) 15 | exerciseSchema(schema) 16 | t.end() 17 | }) 18 | --------------------------------------------------------------------------------