Keep-going: tree shares, health flags, CI, compose, timestamp Zapier action
Directory-tree encrypted share mock; /health reports mockVerae/nats; middleware OpenAPI extended; zappier receipt by jobId; activate Create Timestamp (local mock or hosted); GitHub Actions test:offline; compose builds zappier image; seed-demo.mjs. No Zapier login or live Verae required.
This commit is contained in:
parent
645a24909a
commit
5925e76c72
39 changed files with 514 additions and 33 deletions
12
packages/zappier/Dockerfile
Normal file
12
packages/zappier/Dockerfile
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
FROM node:20-bookworm-slim
|
||||
WORKDIR /app
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci
|
||||
COPY tsconfig.json ./
|
||||
COPY src ./src
|
||||
COPY admin ./admin
|
||||
COPY portal ./portal
|
||||
COPY openapi.yaml ./
|
||||
ENV PORT=3000
|
||||
EXPOSE 3000
|
||||
CMD ["npx", "ts-node", "src/index.ts"]
|
||||
|
|
@ -93,6 +93,21 @@ paths:
|
|||
description: OK
|
||||
'404':
|
||||
description: Missing
|
||||
/v1/receipts/{jobId}:
|
||||
get:
|
||||
operationId: receipt
|
||||
summary: Retrieval receipt JSON (mock job ids from /v1/timestamp)
|
||||
parameters:
|
||||
- name: jobId
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: OK
|
||||
'404':
|
||||
description: Missing
|
||||
/v1/add:
|
||||
post:
|
||||
operationId: add
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@ export function buildApp(deps: AppDeps = {}): {
|
|||
string,
|
||||
{ jobId: string; sha256: string; data?: string; timestamp: string }
|
||||
>();
|
||||
const jobIndex = new Map<string, { jobId: string; sha256: string; data?: string; timestamp: string }>();
|
||||
|
||||
const app = express();
|
||||
app.use(express.json());
|
||||
|
|
@ -177,10 +178,29 @@ export function buildApp(deps: AppDeps = {}): {
|
|||
}
|
||||
const jobId = randomUUID();
|
||||
const timestamp = new Date().toISOString();
|
||||
hashIndex.set(sha256, { jobId, sha256, data, timestamp });
|
||||
const rec = { jobId, sha256, data, timestamp };
|
||||
hashIndex.set(sha256, rec);
|
||||
jobIndex.set(jobId, rec);
|
||||
res.status(202).json({ jobId, sha256, existing: false, timestamp });
|
||||
});
|
||||
|
||||
app.get('/v1/receipts/:jobId', meter('receipt', usage, pricing), (req, res) => {
|
||||
const rec = jobIndex.get(String(req.params.jobId));
|
||||
if (!rec) {
|
||||
res.status(404).json({ error: 'Job not found' });
|
||||
return;
|
||||
}
|
||||
res.json({
|
||||
type: 'verae.retrieval-receipt',
|
||||
format: 'json',
|
||||
jobId: rec.jobId,
|
||||
sha256: rec.sha256,
|
||||
timestamp: rec.timestamp,
|
||||
extraSeal: { event: 'document.retrieved', retrievedAt: new Date().toISOString() },
|
||||
quote: res.locals.quote,
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/v1/hashes/:sha256', meter('hash-lookup', usage, pricing), (req, res) => {
|
||||
const sha256 = String(req.params.sha256 || '').toLowerCase();
|
||||
const rec = hashIndex.get(sha256);
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ export const DEFAULT_RATE_CARD: RateCard = {
|
|||
add: { kind: 'free' },
|
||||
timestamp: { kind: 'fixed', fixedCents: 4 },
|
||||
'hash-lookup': { kind: 'free' },
|
||||
receipt: { kind: 'free' },
|
||||
storage: { kind: 'variable', baseCents: 10, perKbCents: 1, perMbCents: 50 },
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -36,6 +36,11 @@ describe('Zappier API', () => {
|
|||
.set('x-api-key', KEY);
|
||||
expect(look.status).toBe(200);
|
||||
expect(look.body.jobId).toBe(a.body.jobId);
|
||||
const receipt = await request(app)
|
||||
.get(`/v1/receipts/${a.body.jobId}`)
|
||||
.set('x-api-key', KEY);
|
||||
expect(receipt.status).toBe(200);
|
||||
expect(receipt.body.type).toBe('verae.retrieval-receipt');
|
||||
});
|
||||
|
||||
it('POST /v1/add returns the sum and is free', async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue