@dakkitor/api-contracts 1.6.0 → 1.7.1
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/dist/curated-worker-leads/candidate-edit-session.contract.d.ts +12 -12
- package/dist/curated-worker-leads/consent-queue.contract.d.ts +28 -28
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/outreach/__tests__/outreach-requests.contract.spec.js +37 -0
- package/dist/outreach/lab-outreach.contract.d.ts +1110 -0
- package/dist/outreach/lab-outreach.contract.d.ts.map +1 -0
- package/dist/outreach/lab-outreach.contract.js +174 -0
- package/dist/outreach/lab-outreach.contract.spec.d.ts +2 -0
- package/dist/outreach/lab-outreach.contract.spec.d.ts.map +1 -0
- package/dist/outreach/lab-outreach.contract.spec.js +90 -0
- package/dist/outreach/outreach-requests.contract.d.ts +84 -0
- package/dist/outreach/outreach-requests.contract.d.ts.map +1 -1
- package/dist/outreach/outreach-requests.schemas.d.ts +9 -0
- package/dist/outreach/outreach-requests.schemas.d.ts.map +1 -1
- package/dist/outreach/outreach-requests.schemas.js +3 -0
- package/dist/outreach/outreach.contract.spec.js +3 -0
- package/dist/relay-pods/relay-lab-fleet.contract.d.ts +858 -0
- package/dist/relay-pods/relay-lab-fleet.contract.d.ts.map +1 -0
- package/dist/relay-pods/relay-lab-fleet.contract.js +79 -0
- package/dist/relay-pods/relay-lab-fleet.contract.spec.d.ts +2 -0
- package/dist/relay-pods/relay-lab-fleet.contract.spec.d.ts.map +1 -0
- package/dist/relay-pods/relay-lab-fleet.contract.spec.js +162 -0
- package/dist/relay-pods/relay-lab-fleet.schemas.d.ts +472 -0
- package/dist/relay-pods/relay-lab-fleet.schemas.d.ts.map +1 -0
- package/dist/relay-pods/relay-lab-fleet.schemas.js +155 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relay-lab-fleet.contract.d.ts","sourceRoot":"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
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.relayLabFleetContract = void 0;
|
|
18
|
+
const core_1 = require("@ts-rest/core");
|
|
19
|
+
const zod_1 = require("zod");
|
|
20
|
+
const error_schemas_1 = require("../common/error-schemas");
|
|
21
|
+
const relay_lab_fleet_schemas_1 = require("./relay-lab-fleet.schemas");
|
|
22
|
+
__exportStar(require("./relay-lab-fleet.schemas"), exports);
|
|
23
|
+
const c = (0, core_1.initContract)();
|
|
24
|
+
const enrollmentPathParams = zod_1.z
|
|
25
|
+
.object({
|
|
26
|
+
localDeviceKey: zod_1.z.string().min(1),
|
|
27
|
+
})
|
|
28
|
+
.strict();
|
|
29
|
+
exports.relayLabFleetContract = c.router({
|
|
30
|
+
publishSnapshot: {
|
|
31
|
+
method: 'PUT',
|
|
32
|
+
path: '/relay-pods/me/lab-devices/snapshot',
|
|
33
|
+
body: relay_lab_fleet_schemas_1.PublishRelayLabSnapshotBodySchema,
|
|
34
|
+
responses: {
|
|
35
|
+
200: relay_lab_fleet_schemas_1.PublishRelayLabSnapshotResponseSchema,
|
|
36
|
+
},
|
|
37
|
+
summary: 'Publish a Relay pod Lab-device snapshot',
|
|
38
|
+
metadata: { tags: ['Relay Lab Fleet'] },
|
|
39
|
+
},
|
|
40
|
+
readFleet: {
|
|
41
|
+
method: 'GET',
|
|
42
|
+
path: '/relay-pods/lab-fleet',
|
|
43
|
+
responses: {
|
|
44
|
+
200: relay_lab_fleet_schemas_1.RelayLabFleetSnapshotSchema,
|
|
45
|
+
},
|
|
46
|
+
summary: 'Read the current multi-pod Relay Lab fleet',
|
|
47
|
+
metadata: { tags: ['Relay Lab Fleet'] },
|
|
48
|
+
},
|
|
49
|
+
reportReadiness: {
|
|
50
|
+
method: 'PUT',
|
|
51
|
+
path: '/relay-pods/me/lab-readiness',
|
|
52
|
+
body: relay_lab_fleet_schemas_1.ReportRelayLabReadinessBodySchema,
|
|
53
|
+
responses: {
|
|
54
|
+
200: relay_lab_fleet_schemas_1.RelayLabReadinessSchema,
|
|
55
|
+
},
|
|
56
|
+
summary: 'Report pod-local Relay Lab readiness',
|
|
57
|
+
metadata: { tags: ['Relay Lab Fleet'] },
|
|
58
|
+
},
|
|
59
|
+
updateEnrollment: {
|
|
60
|
+
method: 'PATCH',
|
|
61
|
+
path: '/relay-pods/me/lab-devices/:localDeviceKey/enrollment',
|
|
62
|
+
pathParams: enrollmentPathParams,
|
|
63
|
+
body: relay_lab_fleet_schemas_1.UpdateRelayLabEnrollmentBodySchema,
|
|
64
|
+
responses: {
|
|
65
|
+
200: relay_lab_fleet_schemas_1.UpdateRelayLabEnrollmentResponseSchema,
|
|
66
|
+
404: error_schemas_1.ErrorResponseSchema,
|
|
67
|
+
},
|
|
68
|
+
summary: 'Update a local Relay Lab device enrollment state',
|
|
69
|
+
metadata: { tags: ['Relay Lab Fleet'] },
|
|
70
|
+
},
|
|
71
|
+
}, {
|
|
72
|
+
pathPrefix: '/v2',
|
|
73
|
+
commonResponses: {
|
|
74
|
+
400: error_schemas_1.ErrorResponseSchema,
|
|
75
|
+
401: error_schemas_1.ErrorResponseSchema,
|
|
76
|
+
403: error_schemas_1.ErrorResponseSchema,
|
|
77
|
+
500: error_schemas_1.ErrorResponseSchema,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relay-lab-fleet.contract.spec.d.ts","sourceRoot":"","sources":["../../contracts/relay-pods/relay-lab-fleet.contract.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const bun_test_1 = require("bun:test");
|
|
4
|
+
const relay_lab_fleet_schemas_1 = require("./relay-lab-fleet.schemas");
|
|
5
|
+
const relay_lab_fleet_contract_1 = require("./relay-lab-fleet.contract");
|
|
6
|
+
const index_1 = require("../index");
|
|
7
|
+
const podId = '11111111-1111-4111-8111-111111111111';
|
|
8
|
+
const labDeviceId = '22222222-2222-4222-8222-222222222222';
|
|
9
|
+
const now = '2026-08-02T09:00:00.000Z';
|
|
10
|
+
const device = {
|
|
11
|
+
id: labDeviceId,
|
|
12
|
+
podId,
|
|
13
|
+
podSlug: 'pod-01',
|
|
14
|
+
podDisplayName: 'Pod 01',
|
|
15
|
+
localDeviceKey: 'phone-01',
|
|
16
|
+
label: 'Primary phone',
|
|
17
|
+
phoneE164: '+447700900123',
|
|
18
|
+
identityVersion: 1,
|
|
19
|
+
lifecycleStatus: 'ACTIVE',
|
|
20
|
+
enrollmentStatus: 'ENROLLED',
|
|
21
|
+
connectionStatus: 'ONLINE',
|
|
22
|
+
restrictionStatus: 'NONE',
|
|
23
|
+
identityStatus: 'VALID',
|
|
24
|
+
lastSeenAt: now,
|
|
25
|
+
};
|
|
26
|
+
(0, bun_test_1.describe)('relay Lab fleet schemas', () => {
|
|
27
|
+
(0, bun_test_1.it)('keeps the canonical fleet device strict', () => {
|
|
28
|
+
(0, bun_test_1.expect)(relay_lab_fleet_schemas_1.RelayLabDeviceSchema.parse(device)).toMatchObject({
|
|
29
|
+
id: labDeviceId,
|
|
30
|
+
podId,
|
|
31
|
+
phoneE164: '+447700900123',
|
|
32
|
+
});
|
|
33
|
+
(0, bun_test_1.expect)(relay_lab_fleet_schemas_1.RelayLabDeviceSchema.safeParse({ ...device, workerId: podId }).success).toBe(false);
|
|
34
|
+
});
|
|
35
|
+
(0, bun_test_1.it)('accepts pod-local snapshot rows without caller-supplied pod scope', () => {
|
|
36
|
+
const body = {
|
|
37
|
+
generation: 7,
|
|
38
|
+
observedAt: now,
|
|
39
|
+
devices: [
|
|
40
|
+
{
|
|
41
|
+
localDeviceKey: 'phone-01',
|
|
42
|
+
label: 'Primary phone',
|
|
43
|
+
phoneE164: '+447700900123',
|
|
44
|
+
lifecycleStatus: 'ACTIVE',
|
|
45
|
+
connectionStatus: 'ONLINE',
|
|
46
|
+
restrictionStatus: 'NONE',
|
|
47
|
+
lastSeenAt: now,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
};
|
|
51
|
+
(0, bun_test_1.expect)(relay_lab_fleet_schemas_1.PublishRelayLabSnapshotBodySchema.parse(body)).toEqual(body);
|
|
52
|
+
(0, bun_test_1.expect)(relay_lab_fleet_schemas_1.PublishRelayLabSnapshotBodySchema.safeParse({ ...body, podId }).success).toBe(false);
|
|
53
|
+
(0, bun_test_1.expect)(relay_lab_fleet_schemas_1.PublishRelayLabSnapshotBodySchema.safeParse({
|
|
54
|
+
...body,
|
|
55
|
+
devices: [{ ...body.devices[0], enrollmentStatus: 'ENROLLED' }],
|
|
56
|
+
}).success).toBe(false);
|
|
57
|
+
});
|
|
58
|
+
(0, bun_test_1.it)('accepts only server-scoped readiness facts', () => {
|
|
59
|
+
(0, bun_test_1.expect)(relay_lab_fleet_schemas_1.ReportRelayLabReadinessBodySchema.safeParse({
|
|
60
|
+
revision: 43,
|
|
61
|
+
requiredPairCount: 2,
|
|
62
|
+
savedPairCount: 2,
|
|
63
|
+
failedPairCount: 0,
|
|
64
|
+
missingPairs: [],
|
|
65
|
+
}).success).toBe(true);
|
|
66
|
+
(0, bun_test_1.expect)(relay_lab_fleet_schemas_1.ReportRelayLabReadinessBodySchema.safeParse({
|
|
67
|
+
podId,
|
|
68
|
+
revision: 43,
|
|
69
|
+
requiredPairCount: 2,
|
|
70
|
+
savedPairCount: 2,
|
|
71
|
+
failedPairCount: 0,
|
|
72
|
+
missingPairs: [],
|
|
73
|
+
}).success).toBe(false);
|
|
74
|
+
});
|
|
75
|
+
(0, bun_test_1.it)('accepts only the exported contact-reconciliation readiness error codes', () => {
|
|
76
|
+
const readiness = {
|
|
77
|
+
revision: 43,
|
|
78
|
+
requiredPairCount: 1,
|
|
79
|
+
savedPairCount: 0,
|
|
80
|
+
failedPairCount: 1,
|
|
81
|
+
missingPairs: [
|
|
82
|
+
{
|
|
83
|
+
ownerLocalDeviceKey: 'phone-01',
|
|
84
|
+
contactLabDeviceId: labDeviceId,
|
|
85
|
+
errorCode: 'CONTACT_WRITE_FAILED',
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
};
|
|
89
|
+
for (const errorCode of relay_lab_fleet_schemas_1.RELAY_LAB_READINESS_ERROR_CODES) {
|
|
90
|
+
(0, bun_test_1.expect)(relay_lab_fleet_schemas_1.ReportRelayLabReadinessBodySchema.safeParse({
|
|
91
|
+
...readiness,
|
|
92
|
+
missingPairs: [{ ...readiness.missingPairs[0], errorCode }],
|
|
93
|
+
}).success).toBe(true);
|
|
94
|
+
}
|
|
95
|
+
for (const errorCode of [
|
|
96
|
+
'failed for +447700900123',
|
|
97
|
+
'contact_write_failed',
|
|
98
|
+
`X_${'A'.repeat(64)}`,
|
|
99
|
+
'PHONE_447700900123',
|
|
100
|
+
'CONTACT_447700900123',
|
|
101
|
+
]) {
|
|
102
|
+
(0, bun_test_1.expect)(relay_lab_fleet_schemas_1.ReportRelayLabReadinessBodySchema.safeParse({
|
|
103
|
+
...readiness,
|
|
104
|
+
missingPairs: [{ ...readiness.missingPairs[0], errorCode }],
|
|
105
|
+
}).success).toBe(false);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
(0, bun_test_1.it)('emits compact SSE payloads without phone numbers', () => {
|
|
109
|
+
(0, bun_test_1.expect)(relay_lab_fleet_schemas_1.LabFleetSsePayloadSchema.parse({
|
|
110
|
+
revision: 43,
|
|
111
|
+
changeType: 'IDENTITY_CHANGED',
|
|
112
|
+
sourcePodId: podId,
|
|
113
|
+
affectedDeviceIds: [labDeviceId],
|
|
114
|
+
})).not.toHaveProperty('phoneNumber');
|
|
115
|
+
(0, bun_test_1.expect)(relay_lab_fleet_schemas_1.LabFleetSsePayloadSchema.safeParse({
|
|
116
|
+
revision: 43,
|
|
117
|
+
changeType: 'IDENTITY_CHANGED',
|
|
118
|
+
sourcePodId: podId,
|
|
119
|
+
affectedDeviceIds: [labDeviceId],
|
|
120
|
+
phoneNumber: '+447700900123',
|
|
121
|
+
}).success).toBe(false);
|
|
122
|
+
});
|
|
123
|
+
(0, bun_test_1.it)('accepts only enroll and revoke as human enrollment commands', () => {
|
|
124
|
+
(0, bun_test_1.expect)(relay_lab_fleet_schemas_1.UpdateRelayLabEnrollmentBodySchema.safeParse({
|
|
125
|
+
enrollmentStatus: 'ENROLLED',
|
|
126
|
+
expectedIdentity: {
|
|
127
|
+
identityVersion: 3,
|
|
128
|
+
label: 'Alice Lab',
|
|
129
|
+
phoneE164: '+447700900123',
|
|
130
|
+
},
|
|
131
|
+
}).success).toBe(true);
|
|
132
|
+
(0, bun_test_1.expect)(relay_lab_fleet_schemas_1.UpdateRelayLabEnrollmentBodySchema.safeParse({
|
|
133
|
+
enrollmentStatus: 'ENROLLED',
|
|
134
|
+
}).success).toBe(false);
|
|
135
|
+
(0, bun_test_1.expect)(relay_lab_fleet_schemas_1.UpdateRelayLabEnrollmentBodySchema.safeParse({
|
|
136
|
+
enrollmentStatus: 'REVOKED',
|
|
137
|
+
}).success).toBe(true);
|
|
138
|
+
(0, bun_test_1.expect)(relay_lab_fleet_schemas_1.UpdateRelayLabEnrollmentBodySchema.safeParse({
|
|
139
|
+
enrollmentStatus: 'UNENROLLED',
|
|
140
|
+
}).success).toBe(false);
|
|
141
|
+
(0, bun_test_1.expect)(relay_lab_fleet_schemas_1.UpdateRelayLabEnrollmentBodySchema.safeParse({
|
|
142
|
+
enrollmentStatus: 'REVOKED',
|
|
143
|
+
expectedIdentity: {
|
|
144
|
+
identityVersion: 3,
|
|
145
|
+
label: 'Alice Lab',
|
|
146
|
+
phoneE164: '+447700900123',
|
|
147
|
+
},
|
|
148
|
+
}).success).toBe(false);
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
(0, bun_test_1.describe)('relayLabFleetContract routes', () => {
|
|
152
|
+
(0, bun_test_1.it)('publishes the pod and fleet lifecycle endpoints under /v2', () => {
|
|
153
|
+
(0, bun_test_1.expect)(relay_lab_fleet_contract_1.relayLabFleetContract.publishSnapshot.path).toBe('/v2/relay-pods/me/lab-devices/snapshot');
|
|
154
|
+
(0, bun_test_1.expect)(relay_lab_fleet_contract_1.relayLabFleetContract.readFleet.path).toBe('/v2/relay-pods/lab-fleet');
|
|
155
|
+
(0, bun_test_1.expect)(relay_lab_fleet_contract_1.relayLabFleetContract.reportReadiness.path).toBe('/v2/relay-pods/me/lab-readiness');
|
|
156
|
+
(0, bun_test_1.expect)(relay_lab_fleet_contract_1.relayLabFleetContract.updateEnrollment).toMatchObject({
|
|
157
|
+
method: 'PATCH',
|
|
158
|
+
path: '/v2/relay-pods/me/lab-devices/:localDeviceKey/enrollment',
|
|
159
|
+
});
|
|
160
|
+
(0, bun_test_1.expect)(index_1.apiContractRouter.RelayLabFleet.readFleet.path).toBe('/v2/relay-pods/lab-fleet');
|
|
161
|
+
});
|
|
162
|
+
});
|