Skip to content

Commit 6fc557e

Browse files
Added initial state
1 parent a574ff3 commit 6fc557e

File tree

5 files changed

+75
-8
lines changed

5 files changed

+75
-8
lines changed

packages/core/graph.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Things, SchemaActions, Prepositions, ThingProperties, } from './schema'
22
import type { NounFields, NounProperties } from './properties'
3-
import type { BSON, Document, ObjectId, Collection as MongoCollection } from 'mongodb'
4-
import { App, Docs, Site, Brand, NounViews } from './ui'
3+
import { App, Docs, Site, Brand, NounViews, Story } from './ui'
54
import { API, Data } from './api'
65
import { stringify } from './utils'
6+
import { Machines } from './state'
77

88
export const createGraph = <G extends Graph<G>>(graph: { nouns: Nouns<G> } & Partial<G>) => {
99
graph.toString = () => stringify(graph)
@@ -17,6 +17,7 @@ export type Graph<G extends Graph<G> = DefaultGraph> = {
1717
events: Partial<Events<G>>
1818
plurals: Partial<Plurals<G>>
1919
properties: Partial<NounProperties<G>>
20+
machines: Partial<Machines<G>>
2021
fields: Partial<NounFields<G>>
2122
views: Partial<NounViews<G>>
2223
app: Partial<App<G>>
@@ -26,6 +27,7 @@ export type Graph<G extends Graph<G> = DefaultGraph> = {
2627
docs: Partial<Docs<G>>
2728
db: Partial<Data<G>>
2829
brand: Partial<Brand<G>>
30+
story: Partial<Story<G>>
2931
}
3032

3133
type DefaultGraph = {
@@ -57,6 +59,7 @@ type DefaultGraph = {
5759
actions: {},
5860
triggers: {},
5961
events: {},
62+
machines: {},
6063
plurals: {},
6164
properties: {},
6265
fields: {},
@@ -68,6 +71,7 @@ type DefaultGraph = {
6871
docs: {},
6972
db: {},
7073
brand: {},
74+
story: {},
7175
}
7276

7377
export type Noun<G extends Graph<G>> = Things | keyof G['nouns']

packages/core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@graphdl/core",
33
"description": "GraphDL Core",
4-
"version": "0.1.1",
4+
"version": "0.1.2",
55
"type": "module",
66
"main": "index.js",
77
"types": "index.ts",
@@ -25,6 +25,6 @@
2525
"tailwindcss": "^3.3.5",
2626
"typescript": "^5.2.2",
2727
"vitest": "^0.34.6",
28-
"xstate": "^4.38.3"
28+
"xstate": "^5.0.0-beta.41"
2929
}
3030
}

packages/core/state.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Graph, IsPresentTense } from '.'
2+
import {
3+
StateMachine,
4+
MachineContext,
5+
EventObject,
6+
Actor,
7+
AnyActorLogic,
8+
ProvidedActor,
9+
ParameterizedObject
10+
} from 'xstate'
11+
12+
export type Machines<G extends Graph<G>> = {
13+
[N in keyof G['nouns']]: StateMachine<any, any, any, any, any, any, any, any, any>
14+
}
15+
16+
export type Context<G extends Graph<G>, N extends keyof G['nouns']> = MachineContext
17+
18+
19+
// export type Actions<G extends Graph<G>> = {
20+
// [S in keyof G['nouns']]: {
21+
// [K in keyof G['verbs'][S]]: K extends IsPresentTense<K> ? {
22+
// [O in keyof G['nouns']]: Action<G, S, K, O>
23+
// } : never
24+
// }
25+
// }
26+
27+
export type Object<G extends Graph<G>, N extends keyof G['nouns']> = {
28+
29+
}
30+
31+
export type Subject<G extends Graph<G>, N extends keyof G['nouns']> = Actor<AnyActorLogic>
32+
export type Logic<G extends Graph<G>, N extends keyof G['nouns']> = AnyActorLogic

packages/core/ui.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,37 @@ export type Brand<G extends Graph<G>> = {
106106
darkAccent: Color
107107
}
108108

109+
export type Story<G extends Graph<G>> = {
110+
hero: {
111+
persona: string
112+
industry: string
113+
job: string
114+
},
115+
problem: {
116+
internal: string
117+
external: string
118+
philisophical: string
119+
villian: string
120+
},
121+
guide: {
122+
name: string
123+
offer: string
124+
}
125+
plan: {
126+
step1: string
127+
step2: string
128+
step3: string
129+
} | string | object,
130+
action: string | object
131+
failure: string | object
132+
stakes: string | object
133+
success: string | object
134+
transformation: string | {
135+
from: string
136+
to: string
137+
}
138+
}
139+
109140
export type BaseColors = 'black' | 'white' | 'slate' | 'gray' | 'zinc' | 'neutral' | 'stone' | 'red' | 'orange' | 'amber' | 'yellow'
110141
| 'lime' | 'green' | 'emerald' | 'teal' | 'cyan' | 'sky' | 'blue' | 'indigo' | 'violet' | 'purple' | 'fuchsia' | 'pink' | 'rose'
111142
export type ColorShades = '50' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | '950'

packages/core/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,10 +1060,10 @@ wrappy@1:
10601060
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
10611061
integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==
10621062

1063-
xstate@^4.38.3:
1064-
version "4.38.3"
1065-
resolved "https://registry.yarnpkg.com/xstate/-/xstate-4.38.3.tgz#4e15e7ad3aa0ca1eea2010548a5379966d8f1075"
1066-
integrity sha512-SH7nAaaPQx57dx6qvfcIgqKRXIh4L0A1iYEqim4s1u7c9VoCgzZc+63FY90AKU4ZzOC2cfJzTnpO4zK7fCUzzw==
1063+
xstate@^5.0.0-beta.41:
1064+
version "5.0.0-beta.41"
1065+
resolved "https://registry.yarnpkg.com/xstate/-/xstate-5.0.0-beta.41.tgz#15b59dea8d1f08277d6750bd0dffe7e9798adfdc"
1066+
integrity sha512-Tj/9hPflk8gKgmdqdy4l/nVbOOfwpsbkBD2aP63WJsOrvVZHSu7Mvgf9LUyhoa/uDeZ3i50YAkigxyk0rTkzhA==
10671067

10681068
yaml@^2.1.1:
10691069
version "2.3.3"

0 commit comments

Comments
 (0)