@bsv/create-dpp-app 0.0.0-stage → 0.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +203 -0
- package/NOTICE +2 -0
- package/PATENTS +12 -0
- package/README.md +93 -2
- package/dist/index.js +125 -0
- package/package.json +57 -4
- package/template/Dockerfile +37 -0
- package/template/README.md +389 -0
- package/template/_dockerignore +6 -0
- package/template/_env.example +122 -0
- package/template/_github/workflows/ci.yml +23 -0
- package/template/_gitignore +8 -0
- package/template/_prettierrc +6 -0
- package/template/apps/api/API.md +119 -0
- package/template/apps/api/package.json +39 -0
- package/template/apps/api/src/auth.ts +55 -0
- package/template/apps/api/src/bound-profiles.ts +590 -0
- package/template/apps/api/src/claims.ts +204 -0
- package/template/apps/api/src/cli.ts +99 -0
- package/template/apps/api/src/config.ts +180 -0
- package/template/apps/api/src/custody.ts +358 -0
- package/template/apps/api/src/dev-index.ts +120 -0
- package/template/apps/api/src/env-file.ts +55 -0
- package/template/apps/api/src/env.ts +14 -0
- package/template/apps/api/src/epcis/exchange.ts +434 -0
- package/template/apps/api/src/epcis/mongo-storage.ts +381 -0
- package/template/apps/api/src/epcis/routes.ts +364 -0
- package/template/apps/api/src/epcis/sources.ts +142 -0
- package/template/apps/api/src/go-live.ts +226 -0
- package/template/apps/api/src/http-error.ts +15 -0
- package/template/apps/api/src/identifiers.ts +57 -0
- package/template/apps/api/src/index-client.ts +261 -0
- package/template/apps/api/src/index-projects.ts +53 -0
- package/template/apps/api/src/lifecycle-authority.ts +49 -0
- package/template/apps/api/src/lifecycle.ts +485 -0
- package/template/apps/api/src/main.ts +58 -0
- package/template/apps/api/src/parties.ts +68 -0
- package/template/apps/api/src/platform.ts +176 -0
- package/template/apps/api/src/portability/commands.ts +224 -0
- package/template/apps/api/src/portability/export.ts +708 -0
- package/template/apps/api/src/portability/package.ts +270 -0
- package/template/apps/api/src/portability/restore.ts +863 -0
- package/template/apps/api/src/profiles.ts +125 -0
- package/template/apps/api/src/reader.ts +265 -0
- package/template/apps/api/src/resolver.ts +159 -0
- package/template/apps/api/src/sector-examples.ts +390 -0
- package/template/apps/api/src/server.ts +613 -0
- package/template/apps/api/src/store.ts +426 -0
- package/template/apps/api/src/validation-engine.ts +172 -0
- package/template/apps/api/src/wallet.ts +359 -0
- package/template/apps/api/src/worker.ts +113 -0
- package/template/apps/api/src/writer.ts +603 -0
- package/template/apps/api/test/bound-http.test.ts +496 -0
- package/template/apps/api/test/bound-profiles.test.ts +547 -0
- package/template/apps/api/test/config.test.ts +160 -0
- package/template/apps/api/test/custody-journal.test.ts +415 -0
- package/template/apps/api/test/custody-recovery-profile.test.ts +224 -0
- package/template/apps/api/test/custom-profile.test.ts +167 -0
- package/template/apps/api/test/env-file.test.ts +53 -0
- package/template/apps/api/test/epcis-fixtures.ts +270 -0
- package/template/apps/api/test/epcis-http.test.ts +1179 -0
- package/template/apps/api/test/epcis-mongo-storage.test.ts +313 -0
- package/template/apps/api/test/epcis-separation.test.ts +253 -0
- package/template/apps/api/test/epcis-web.test.ts +230 -0
- package/template/apps/api/test/exit-exercise.test.ts +1038 -0
- package/template/apps/api/test/external-index.test.ts +32 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/background.ttl +33 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/binding.json +141 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/context.jsonld +36 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/product.schema.json +44 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/shapes.ttl +112 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/conflicting-gtin.json +44 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/conflicting-serial.json +44 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/granularity-mismatch.json +44 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/item-gtin-13.json +43 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/item.json +42 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/missing-required-property.json +43 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/model-as-subject.json +44 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/no-passport-identifier.json +43 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/other-product.json +44 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/part-not-dishwasher-safe.json +45 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/registration/altered-artefact.json +19 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/registration/altered-background.ttl +33 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/registration/conflicting-binding.json +141 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/registration/conflicting-second-registration.json +19 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/registration/untrusted-binding.json +13 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/unlisted-context.json +47 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/wrong-binding-digest.json +44 -0
- package/template/apps/api/test/fixtures/custom-profile/example-notebook@1/binding.json +88 -0
- package/template/apps/api/test/fixtures/custom-profile/example-notebook@1/product.schema.json +25 -0
- package/template/apps/api/test/fixtures/custom-profile/example-notebook@1/vectors/item.json +26 -0
- package/template/apps/api/test/fixtures/custom-profile/example-notebook@1/vectors/missing-required-property.json +27 -0
- package/template/apps/api/test/fixtures/custom-profile/example-notebook@1/vectors/no-passport-identifier.json +27 -0
- package/template/apps/api/test/fixtures/custom-profile/example-notebook@1/vectors/other-product.json +28 -0
- package/template/apps/api/test/go-live.test.ts +179 -0
- package/template/apps/api/test/gs1-global-setup.ts +33 -0
- package/template/apps/api/test/gs1-test-env.ts +5 -0
- package/template/apps/api/test/identifier-host.test.ts +256 -0
- package/template/apps/api/test/index-projects.test.ts +81 -0
- package/template/apps/api/test/lifecycle-claims.test.ts +546 -0
- package/template/apps/api/test/lifecycle-fixtures.ts +167 -0
- package/template/apps/api/test/lifecycle.test.ts +147 -0
- package/template/apps/api/test/manifest-notice.test.ts +36 -0
- package/template/apps/api/test/network-guard.ts +113 -0
- package/template/apps/api/test/portability.test.ts +655 -0
- package/template/apps/api/test/profile-bundle-resolver.test.ts +198 -0
- package/template/apps/api/test/retired-profiles.test.ts +216 -0
- package/template/apps/api/test/sector-cutover.test.ts +95 -0
- package/template/apps/api/test/sector-forms.test.ts +420 -0
- package/template/apps/api/test/unjoined-index.test.ts +62 -0
- package/template/apps/api/test/validation-engine.test.ts +328 -0
- package/template/apps/api/test/wallet-monitor.test.ts +38 -0
- package/template/apps/api/test/writer-journal.test.ts +327 -0
- package/template/apps/api/tsconfig.json +9 -0
- package/template/apps/api/vitest.config.ts +12 -0
- package/template/apps/web/components.json +21 -0
- package/template/apps/web/index.html +12 -0
- package/template/apps/web/package.json +33 -0
- package/template/apps/web/src/app.tsx +55 -0
- package/template/apps/web/src/components/bits.tsx +188 -0
- package/template/apps/web/src/components/bound/bound-passport-form.tsx +368 -0
- package/template/apps/web/src/components/bound/field-view.tsx +237 -0
- package/template/apps/web/src/components/bound/pieces.tsx +169 -0
- package/template/apps/web/src/components/bound/readings.tsx +152 -0
- package/template/apps/web/src/components/bound/structured-value.tsx +114 -0
- package/template/apps/web/src/components/claim-dialog.tsx +344 -0
- package/template/apps/web/src/components/epcis-events.tsx +119 -0
- package/template/apps/web/src/components/layout.tsx +135 -0
- package/template/apps/web/src/components/lifecycle-claims.tsx +199 -0
- package/template/apps/web/src/components/passport-form.tsx +244 -0
- package/template/apps/web/src/components/read-passport.tsx +49 -0
- package/template/apps/web/src/components/reading.tsx +150 -0
- package/template/apps/web/src/components/ui/alert.tsx +65 -0
- package/template/apps/web/src/components/ui/badge.tsx +47 -0
- package/template/apps/web/src/components/ui/button.tsx +63 -0
- package/template/apps/web/src/components/ui/card.tsx +91 -0
- package/template/apps/web/src/components/ui/dialog.tsx +156 -0
- package/template/apps/web/src/components/ui/input.tsx +20 -0
- package/template/apps/web/src/components/ui/label.tsx +21 -0
- package/template/apps/web/src/components/ui/select.tsx +189 -0
- package/template/apps/web/src/components/ui/separator.tsx +25 -0
- package/template/apps/web/src/components/ui/table.tsx +115 -0
- package/template/apps/web/src/components/ui/tabs.tsx +90 -0
- package/template/apps/web/src/components/ui/textarea.tsx +17 -0
- package/template/apps/web/src/index.css +81 -0
- package/template/apps/web/src/lib/api.ts +396 -0
- package/template/apps/web/src/lib/auth.ts +10 -0
- package/template/apps/web/src/lib/bound/battery-form.ts +269 -0
- package/template/apps/web/src/lib/bound/display.ts +122 -0
- package/template/apps/web/src/lib/bound/fields.ts +128 -0
- package/template/apps/web/src/lib/bound/form-model.ts +521 -0
- package/template/apps/web/src/lib/bound/forms.ts +15 -0
- package/template/apps/web/src/lib/bound/identity.ts +48 -0
- package/template/apps/web/src/lib/bound/textile-form.ts +236 -0
- package/template/apps/web/src/lib/bound/units.ts +37 -0
- package/template/apps/web/src/lib/epcis.ts +345 -0
- package/template/apps/web/src/lib/format.ts +87 -0
- package/template/apps/web/src/lib/lifecycle.ts +350 -0
- package/template/apps/web/src/lib/session.tsx +92 -0
- package/template/apps/web/src/lib/use-load.ts +46 -0
- package/template/apps/web/src/main.tsx +18 -0
- package/template/apps/web/src/pages/accept.tsx +113 -0
- package/template/apps/web/src/pages/brand.tsx +94 -0
- package/template/apps/web/src/pages/brands.tsx +104 -0
- package/template/apps/web/src/pages/events.tsx +388 -0
- package/template/apps/web/src/pages/home.tsx +51 -0
- package/template/apps/web/src/pages/new-passport.tsx +137 -0
- package/template/apps/web/src/pages/operations.tsx +169 -0
- package/template/apps/web/src/pages/passport.tsx +632 -0
- package/template/apps/web/src/pages/public-passport.tsx +64 -0
- package/template/apps/web/src/pages/sign-in.tsx +93 -0
- package/template/apps/web/src/pages/verify.tsx +30 -0
- package/template/apps/web/src/pages/wallet.tsx +141 -0
- package/template/apps/web/tsconfig.json +29 -0
- package/template/apps/web/vite.config.ts +23 -0
- package/template/deploy/compose.yml +38 -0
- package/template/package.json +48 -0
- package/template/tsconfig.base.json +13 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { Link } from 'react-router'
|
|
3
|
+
import { Button } from '@/components/ui/button'
|
|
4
|
+
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'
|
|
5
|
+
import { CopyButton, ErrorNotice, Loading, Mono, PageTitle, Section, ToneBadge, statusTone } from '@/components/bits'
|
|
6
|
+
import { RequireAccount } from '@/components/layout'
|
|
7
|
+
import { api, passportRef } from '@/lib/api'
|
|
8
|
+
import { formatTime, identifierPathOf, shortTxid } from '@/lib/format'
|
|
9
|
+
import { useLoad } from '@/lib/use-load'
|
|
10
|
+
|
|
11
|
+
export function Operations() {
|
|
12
|
+
return (
|
|
13
|
+
<RequireAccount>
|
|
14
|
+
<OperationsPage />
|
|
15
|
+
</RequireAccount>
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function OperationsPage() {
|
|
20
|
+
const ops = useLoad(() => api.operations(), [])
|
|
21
|
+
const [running, setRunning] = useState(false)
|
|
22
|
+
const [done, setDone] = useState<string[]>()
|
|
23
|
+
const [runError, setRunError] = useState<unknown>()
|
|
24
|
+
|
|
25
|
+
async function run() {
|
|
26
|
+
setRunning(true)
|
|
27
|
+
setRunError(undefined)
|
|
28
|
+
try {
|
|
29
|
+
const answer = await api.runOperations()
|
|
30
|
+
setDone(answer.done)
|
|
31
|
+
ops.reload()
|
|
32
|
+
} catch (cause) {
|
|
33
|
+
setRunError(cause)
|
|
34
|
+
} finally {
|
|
35
|
+
setRunning(false)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<div className="space-y-10">
|
|
41
|
+
<PageTitle
|
|
42
|
+
title="Operations"
|
|
43
|
+
description="What the worker still owes: announcing a state again, fetching its proof once mined, and pushing that proof to the index. The worker runs on its own; Run now does one pass here."
|
|
44
|
+
action={
|
|
45
|
+
<Button onClick={run} disabled={running}>
|
|
46
|
+
{running ? 'Running' : 'Run now'}
|
|
47
|
+
</Button>
|
|
48
|
+
}
|
|
49
|
+
/>
|
|
50
|
+
{runError == null ? null : <ErrorNotice error={runError} title="The run failed" />}
|
|
51
|
+
{done == null ? null : (
|
|
52
|
+
<div className="rounded-lg border p-4">
|
|
53
|
+
<p className="mb-2 text-sm font-medium">Last run</p>
|
|
54
|
+
{done.length === 0 ? (
|
|
55
|
+
<p className="text-sm text-muted-foreground">Nothing was owed.</p>
|
|
56
|
+
) : (
|
|
57
|
+
<ul className="list-disc space-y-1 pl-5 font-mono text-xs">
|
|
58
|
+
{done.map((line, i) => (
|
|
59
|
+
<li key={i}>{line}</li>
|
|
60
|
+
))}
|
|
61
|
+
</ul>
|
|
62
|
+
)}
|
|
63
|
+
</div>
|
|
64
|
+
)}
|
|
65
|
+
{ops.loading ? (
|
|
66
|
+
<Loading what="Loading the duties" />
|
|
67
|
+
) : ops.error != null || ops.data == null ? (
|
|
68
|
+
<ErrorNotice error={ops.error ?? new Error('no answer')} title="Could not load the operations" />
|
|
69
|
+
) : (
|
|
70
|
+
<>
|
|
71
|
+
{ops.data.profiles == null || (ops.data.profiles.engine.available && ops.data.profiles.refused.length === 0) ? null : (
|
|
72
|
+
<Section title="Profiles">
|
|
73
|
+
{ops.data.profiles.engine.available ? null : <ErrorNotice error={new Error(ops.data.profiles.engine.problem ?? 'The validation engine cannot be used: its libraries did not load, or the validator service did not answer.')} title="The validation engine is not available" />}
|
|
74
|
+
{ops.data.profiles.refused.length === 0 ? null : (
|
|
75
|
+
<ul className="divide-y rounded-lg border text-sm">
|
|
76
|
+
{ops.data.profiles.refused.map((refusal) => (
|
|
77
|
+
<li key={refusal.source} className="space-y-1 p-3">
|
|
78
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
79
|
+
<ToneBadge tone="fail">Not registered</ToneBadge>
|
|
80
|
+
<Mono>{refusal.source}</Mono>
|
|
81
|
+
<Mono className="text-muted-foreground">{refusal.code}</Mono>
|
|
82
|
+
</div>
|
|
83
|
+
<p className="text-muted-foreground">{refusal.detail}</p>
|
|
84
|
+
</li>
|
|
85
|
+
))}
|
|
86
|
+
</ul>
|
|
87
|
+
)}
|
|
88
|
+
</Section>
|
|
89
|
+
)}
|
|
90
|
+
<Section title="Duties">
|
|
91
|
+
{ops.data.duties.length === 0 ? (
|
|
92
|
+
<p className="text-sm text-muted-foreground">Nothing is owed.</p>
|
|
93
|
+
) : (
|
|
94
|
+
<Table>
|
|
95
|
+
<TableHeader>
|
|
96
|
+
<TableRow>
|
|
97
|
+
<TableHead>Passport</TableHead>
|
|
98
|
+
<TableHead>Op</TableHead>
|
|
99
|
+
<TableHead>Duty</TableHead>
|
|
100
|
+
<TableHead>Since</TableHead>
|
|
101
|
+
<TableHead>Txid</TableHead>
|
|
102
|
+
</TableRow>
|
|
103
|
+
</TableHeader>
|
|
104
|
+
<TableBody>
|
|
105
|
+
{ops.data.duties.map((duty) => (
|
|
106
|
+
<TableRow key={`${duty.txid}-${duty.duty}`}>
|
|
107
|
+
<TableCell>
|
|
108
|
+
<Link to={`/passports/${passportRef(duty.passportId)}`} className="font-mono text-xs underline-offset-4 hover:underline">
|
|
109
|
+
{identifierPathOf(duty.passportId) ?? duty.passportId}
|
|
110
|
+
</Link>
|
|
111
|
+
</TableCell>
|
|
112
|
+
<TableCell>
|
|
113
|
+
<ToneBadge tone="neutral">{duty.op}</ToneBadge>
|
|
114
|
+
</TableCell>
|
|
115
|
+
<TableCell>{duty.duty}</TableCell>
|
|
116
|
+
<TableCell>{formatTime(duty.since)}</TableCell>
|
|
117
|
+
<TableCell>
|
|
118
|
+
<span className="flex items-center gap-1">
|
|
119
|
+
<Mono>{shortTxid(duty.txid)}</Mono>
|
|
120
|
+
<CopyButton text={duty.txid} label="Copy the txid" />
|
|
121
|
+
</span>
|
|
122
|
+
</TableCell>
|
|
123
|
+
</TableRow>
|
|
124
|
+
))}
|
|
125
|
+
</TableBody>
|
|
126
|
+
</Table>
|
|
127
|
+
)}
|
|
128
|
+
</Section>
|
|
129
|
+
<Section title="Passports">
|
|
130
|
+
{ops.data.passports.length === 0 ? (
|
|
131
|
+
<p className="text-sm text-muted-foreground">No passports in the journal.</p>
|
|
132
|
+
) : (
|
|
133
|
+
<Table>
|
|
134
|
+
<TableHeader>
|
|
135
|
+
<TableRow>
|
|
136
|
+
<TableHead>Passport</TableHead>
|
|
137
|
+
<TableHead>Brand</TableHead>
|
|
138
|
+
<TableHead>Status</TableHead>
|
|
139
|
+
<TableHead className="text-right">States</TableHead>
|
|
140
|
+
<TableHead className="text-right">Proven</TableHead>
|
|
141
|
+
<TableHead className="text-right">Pending</TableHead>
|
|
142
|
+
</TableRow>
|
|
143
|
+
</TableHeader>
|
|
144
|
+
<TableBody>
|
|
145
|
+
{ops.data.passports.map((p) => (
|
|
146
|
+
<TableRow key={p.passportId}>
|
|
147
|
+
<TableCell>
|
|
148
|
+
<Link to={`/passports/${passportRef(p.passportId)}`} className="font-mono text-xs underline-offset-4 hover:underline">
|
|
149
|
+
{identifierPathOf(p.passportId) ?? p.passportId}
|
|
150
|
+
</Link>
|
|
151
|
+
</TableCell>
|
|
152
|
+
<TableCell>{p.brandId}</TableCell>
|
|
153
|
+
<TableCell>
|
|
154
|
+
<ToneBadge tone={statusTone(p.status)}>{p.status}</ToneBadge>
|
|
155
|
+
</TableCell>
|
|
156
|
+
<TableCell className="text-right">{p.journal.states}</TableCell>
|
|
157
|
+
<TableCell className="text-right">{p.journal.proven}</TableCell>
|
|
158
|
+
<TableCell className="text-right">{p.journal.pending}</TableCell>
|
|
159
|
+
</TableRow>
|
|
160
|
+
))}
|
|
161
|
+
</TableBody>
|
|
162
|
+
</Table>
|
|
163
|
+
)}
|
|
164
|
+
</Section>
|
|
165
|
+
</>
|
|
166
|
+
)}
|
|
167
|
+
</div>
|
|
168
|
+
)
|
|
169
|
+
}
|