Skip to content

Commit 4e30720

Browse files
Working through simple things
1 parent 611e70c commit 4e30720

File tree

8 files changed

+11892
-7
lines changed

8 files changed

+11892
-7
lines changed

examples/CRM.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// import { createGraph } from '../graph'
2-
import { Things } from '../schema'
2+
// import { Things } from '../schema'
33

44

55
const sendEmail = (obj:any) => {}

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
{
22
"type": "module",
3-
"devDependencies": {
4-
"mongodb": "^6.2.0"
3+
"scripts": {
4+
"test": "vitest"
55
},
6-
"dependencies": {
7-
"tailwindcss": "^3.3.5"
6+
"devDependencies": {
7+
"mongodb": "^6.2.0",
8+
"tailwindcss": "^3.3.5",
9+
"vitest": "^0.34.6"
810
}
911
}

packages/things/index.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { describe, it, expect } from 'vitest'
2+
// import { Thing, Idea } from '@graphdl/things'
3+
// import { Thing, Idea } from './index.js'
4+
5+
describe('Thing', () => {
6+
it('should be a thing', () => {
7+
expect('Thing').toBe('Thing')
8+
})
9+
})

packages/things/index.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { PrepositionsAndActivities, Things } from './things'
2+
// import { Thing } from './schema'
3+
4+
export type ThingsAndPrepositions<T extends string> = ThingsWithInstances<T> | PrepositionsAndActivities
5+
export type ThingsWithInstances<T extends string> = T | Things | `InstanceOf${Things | T}`
6+
export type SimpleThings<T extends string> = Record<string, ThingsWithInstances<T>>
7+
// export type ExpandedThings<T extends Record<T extends string ? T : never, any>> = {
8+
// is: ThingsWithInstances<T> | ThingsWithInstances<T>[]
9+
// } & {
10+
// [K in PrepositionsAndActivities]?: ThingsAndPrepositions<T> | ThingsAndPrepositions<T>[]
11+
// }
12+
13+
// Keep this very simple as only Thing
14+
export const listThings = <T extends string>(things: Record<T, Things>) => things
15+
// export const defineThings = <T extends string>(things: Record<T, ThingsWithInstances<T> | ThingsWithInstances<T>[] | ExpandedThings<T>>) => things
16+
17+
18+
// listThings is only string value things
19+
// defineThings allows expanded definitions
20+
// defineDomain only allows prepositions to refer to things in the domain
21+
22+
23+
export const things = listThings({
24+
Dealer: 'AutoDealer',
25+
Vehicle: 'Vehicle',
26+
Website: 'WebSite',
27+
})
28+
29+
// export const definedThings = defineThings({
30+
// Dealer: 'AutoDealer',
31+
// // Dealer: { is: 'AutoDealer', selling: 'Vehicles', on: 'WebSite' },
32+
// Vehicle: { is: 'Car' },
33+
// })
34+
35+

packages/things/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "@graphdl/things",
3+
"type": "module"
4+
}

packages/things/schema.ts

Lines changed: 11317 additions & 0 deletions
Large diffs are not rendered by default.

packages/things/things.ts

Lines changed: 45 additions & 0 deletions
Large diffs are not rendered by default.

yarn.lock

Lines changed: 475 additions & 2 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)