From 62aa4f512ffda130e647d68aac88adb327c001e1 Mon Sep 17 00:00:00 2001 From: Florian Wendelborn <1133858+FlorianWendelborn@users.noreply.github.com> Date: Sat, 8 Jun 2024 04:13:58 +0200 Subject: [PATCH] feature(actions): Add Bits Actions --- .github/workflows/ci.yml | 7 + .vscode/actions.code-snippets | 39 ++ bun.lockb | Bin 107008 -> 107864 bytes packages/actions/data/actions.json | 60 -- packages/actions/data/bits-crafts.json | 921 +++++++++++++++++++++++++ packages/actions/data/bits.json | 350 ++++++++++ packages/actions/package.json | 1 + packages/actions/source/data.test.ts | 44 ++ packages/actions/source/data.ts | 8 + packages/actions/source/index.ts | 1 + packages/actions/source/schema.ts | 54 ++ packages/actions/tsconfig.json | 1 + turbo.json | 4 +- 13 files changed, 1429 insertions(+), 61 deletions(-) create mode 100644 .vscode/actions.code-snippets delete mode 100644 packages/actions/data/actions.json create mode 100644 packages/actions/data/bits-crafts.json create mode 100644 packages/actions/data/bits.json create mode 100644 packages/actions/source/data.test.ts create mode 100644 packages/actions/source/data.ts create mode 100644 packages/actions/source/index.ts create mode 100644 packages/actions/source/schema.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 63da1cd..14bd6f0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,13 @@ jobs: - uses: oven-sh/setup-bun@v1 - run: bun install - run: bun run check + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: oven-sh/setup-bun@v1 + - run: bun install + - run: bun run test validate-schemas: runs-on: ubuntu-latest steps: diff --git a/.vscode/actions.code-snippets b/.vscode/actions.code-snippets new file mode 100644 index 0000000..48db197 --- /dev/null +++ b/.vscode/actions.code-snippets @@ -0,0 +1,39 @@ +{ + "Action for Crafting": { + "prefix": "actr", + "body": [ + "{", + "\t\"inputs\": [", + "\t\t{ \"amount\": ${1:1}, \"id\": \"${2:TODO: Insert Item ID}\", \"type\": \"item\" }", + "\t],", + "\t\"outputs\": [", + "\t\t{ \"amount\": ${3:1}, \"id\": \"${4:TODO: Insert Item ID}\", \"type\": \"item\" }", + "\t],", + "\t\"place\": [", + "\t\t{", + "\t\t\t\"grid\": [", + "\t\t\t\t${5:null},", + "\t\t\t\t${6:null},", + "\t\t\t\t${7:null},", + "\t\t\t\t${8:null},", + "\t\t\t\t${9:null},", + "\t\t\t\t${10:null},", + "\t\t\t\t${11:null},", + "\t\t\t\t${12:null},", + "\t\t\t\t${13:null}", + "\t\t\t],", + "\t\t\t\"type\": \"workbench\"", + "\t\t}", + "\t]", + "},", + ], + "description": "Add Recipe Action", + }, + "Action Input/Output Item": { + "prefix": "acti", + "body": [ + "{ \"amount\": ${1:1}, \"id\": \"${2:TODO: Insert Item ID}\", \"type\": \"item\" }", + ], + "description": "Add item in action.inputs and action.outputs", + }, +} diff --git a/bun.lockb b/bun.lockb index a34a50e67cf2fceab9fbf5a22702d705ebf04ae2..e33f78feeb14cfc666df037c3b50fd5a51b3e5ef 100755 GIT binary patch delta 15888 zcmeHOe_T~nwmH{+H(pO~*T=Zq{0^-3LjZnUdo zd=G0$)>}K6LMdq7#86jUfX*mNbyZa@i7$b=DT=$arlPzOl9}xkr9Jrj47_OIcmsup zqI5-hMd`vys=o$2>CZN>7H9`wQd&AMro2WOhI(DV4+5$c$Oune@I8a|y|s{|L$`BARW)fRg{&y zo5f%KH}pl_{hlXS{KJ-EBFGi9oHa2psH_@18JFd)DCoz%o|jufUA@pRwWtCEfs4@t z4Q-~grglDBt}b0rQ$Dj!c^pb);xs?qq+bK6uY4fsml&311ABmv1_l8m{1qh_7zUnP z)eT7c-T|^bmwR?iOr3LXh2pF(o9C>qDfL7Fjd?KUoiGka<~9MzH#B`t`0^TJk3!=- zkUBJdxEws1aMzU1U07PJC^_hz>eV?bD#~kWl}}(*Z}90M)V`16K7mn^WiqCKg4eeT zbv=nTsajg7Ub-Aed~vmNMk&00&5)<})V;hGNabb#m6TV@NXrS+<&U5}@_s0~MOF9P zFoVq84MbJ<79b6C4G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`b5(59TZI+q~S1m%KQkuZ6*pa(hk{TcCg}ev9nUhwUJ@BU76GJ;~hm4CIRdQD`vLkXx!!TyR{z*141gULK3T5~Ycda(vz zH(&a%s2Y80+po8tzuwUc8|W~6_hHm5(;dZ*gOQ?E)*w;TQ1s(TO#6yvSiDNEKxZWM#qn zrKdYmBT>3G5UZn{@!$tvQrp$M3~pNCjJ)KOz`*4c6fRB4^PuR zN@2j`r(pSVMc4`SLz^hc$MVh-HTf{6RBX?Od5?b;`0+D_tu;bHzG=Tua6{Z z3$UA*UtDBXzgusnD@^0npfX#JX9Te_7sROFd~yJ z{JpX6j5B4Ra1LkTY_`}n9Mv8%i(t7}Hk|cSkKo}5zbJT&%6;P4a2%k_Z!SWXe|c?O z)WHoFb`p<+bfl^mIfZC_i@3dzRk!@(LxNl}a$TGnuIKoE@7SG%39Vn-EcEpTJ_S?E zuOdEpa&>)D@gvV;UCiRPCdZx)_7{>5+q8e$XmMc8{E$z&ZZXA8w|ida#Y`4vdC|I2IF z9X)hTMqchipB0Jki;z8+ibP2XZj}1YZMjw?4iw`?X?`B^<@O~HJZ$@Ox@?HWiC196 z0&MX&ZO!%>pVUh?dMXs2ik<33={q_>y zvpwm)CxeX}*vL{m#3aTi9~Lukr|M;XMYeLlgynsn%XD5}o=fQ06_orEak-S`inI|p zcvgs-5jYXQE|wC!E1np^w9txhJwxtIPd&iy>~if+`o#fd@j77{$p(lAMzTd> { + expect(() => z.array(actionSchema).parse(allActions)).not.toThrow() +}) + +describe('every action’s inputs match its outputs', () => { + /** + * Simplifies and "sorts" action input/output items + */ + const sumUp = (ios: ActionIoItem[]): Map => { + const result = new Map() + + for (const io of ios) { + if (!result.has(io.id)) result.set(io.id, 0) + + result.set(io.id, result.get(io.id) + io.amount) + } + + return result + } + + for (const action of allActions) { + for (const grid of action.place.filter((x) => x.type === 'workbench')) { + test(`${JSON.stringify(action.outputs)} is valid`, () => { + assert(grid.type === 'workbench') + + const actual = sumUp( + action.inputs.filter((x) => x.type === 'item') as ActionIoItem[], + ) + + const expected = sumUp( + grid.grid.filter((x) => x !== null) as ActionIoItem[], + ) + + expect(actual).toEqual(expected) + }) + } + } +}) diff --git a/packages/actions/source/data.ts b/packages/actions/source/data.ts new file mode 100644 index 0000000..d345585 --- /dev/null +++ b/packages/actions/source/data.ts @@ -0,0 +1,8 @@ +import { actions as _bits } from '../data/bits.json' +import { actions as _bitsCrafts } from '../data/bits-crafts.json' +import { Action } from './schema' + +export const bits = _bits as Action[] +export const bitsCrafts = _bitsCrafts as Action[] + +export const allActions = [...bits, ...bitsCrafts] diff --git a/packages/actions/source/index.ts b/packages/actions/source/index.ts new file mode 100644 index 0000000..3fb1645 --- /dev/null +++ b/packages/actions/source/index.ts @@ -0,0 +1 @@ +export { actions as bitsActions } from '../data/bits.json' diff --git a/packages/actions/source/schema.ts b/packages/actions/source/schema.ts new file mode 100644 index 0000000..f34d24f --- /dev/null +++ b/packages/actions/source/schema.ts @@ -0,0 +1,54 @@ +import { z } from 'zod' + +export const actionIoItemSchema = z + .object({ + amount: z.number().int().finite(), + id: z.string(), + type: z.literal('item'), + }) + .strict() + +export type ActionIoItem = z.output + +export const actionIoSchema = z.discriminatedUnion('type', [ + z + .object({ + amount: z.number().int().finite(), + type: z.literal('bit'), + }) + .strict(), + z + .object({ + amount: z.number().int().finite(), + type: z.literal('coin'), + }) + .strict(), + actionIoItemSchema, +]) + +export type ActionIo = z.output + +export const actionPlaceSchema = z.discriminatedUnion('type', [ + z + .object({ + id: z.string(), + type: z.literal('npc'), + }) + .strict(), + z + .object({ + grid: z.array(actionIoItemSchema.nullable()).length(9), + type: z.literal('workbench'), + }) + .strict(), +]) + +export const actionSchema = z + .object({ + inputs: z.array(actionIoSchema), + outputs: z.array(actionIoSchema), + place: z.array(actionPlaceSchema), + }) + .strict() + +export type Action = z.output diff --git a/packages/actions/tsconfig.json b/packages/actions/tsconfig.json index aef7945..c8bd326 100644 --- a/packages/actions/tsconfig.json +++ b/packages/actions/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "esModuleInterop": true, "module": "commonjs", "moduleResolution": "Node", "outDir": "./dist", diff --git a/turbo.json b/turbo.json index 074d7ba..aecc4ac 100644 --- a/turbo.json +++ b/turbo.json @@ -65,6 +65,8 @@ "cache": false, "dependsOn": ["build", "check", "test"] }, - "test": {} + "test": { + "outputMode": "new-only" + } } }