Add dataset and identity contract foundations
This commit is contained in:
@@ -0,0 +1,246 @@
|
||||
import type {
|
||||
ConsentBinding,
|
||||
DatasetJob,
|
||||
DatasetSyncState,
|
||||
EntityResolution,
|
||||
InventoryCursor,
|
||||
InventoryCursorState,
|
||||
InventoryQuery,
|
||||
InventoryRow,
|
||||
InventoryQueryResult,
|
||||
ResourceAuthorization,
|
||||
SignedMoneyNormalizationPolicy,
|
||||
WalletBalanceResult,
|
||||
} from '../../src/lib/domain/model';
|
||||
|
||||
/** Synthetic, offline-only values used to exercise contract shape and pinning. */
|
||||
export const syntheticPrincipal = { kind: 'character', id: '90000000000000001', ownerUserId: 'fixture-user-a' } as const;
|
||||
export const syntheticResource = {
|
||||
principal: syntheticPrincipal,
|
||||
requiredScopes: ['esi-assets.read_assets.v1'],
|
||||
authorizationRevision: 7,
|
||||
authorizationEpoch: 1,
|
||||
} as const;
|
||||
|
||||
export const datasetState: DatasetSyncState = {
|
||||
principal: syntheticPrincipal,
|
||||
dataset: 'assets',
|
||||
status: 'ready',
|
||||
authorizationStatus: 'active',
|
||||
authorizationEpoch: 1,
|
||||
grantRevision: 7,
|
||||
credentialVersion: 3,
|
||||
coverage: { kind: 'snapshot', generation: 'assets-g7', complete: true },
|
||||
fetchedAt: 1_700_000_100_000,
|
||||
upstreamEffectiveAt: null,
|
||||
};
|
||||
|
||||
export const appendDatasetState: DatasetSyncState = {
|
||||
principal: { kind: 'character', id: '90000000000000001', ownerUserId: 'fixture-user-a' },
|
||||
dataset: 'wallet_journal',
|
||||
status: 'partial',
|
||||
authorizationStatus: 'active',
|
||||
authorizationEpoch: 1,
|
||||
grantRevision: 4,
|
||||
credentialVersion: 2,
|
||||
coverage: {
|
||||
kind: 'append',
|
||||
checkpoint: 'journal-from-90000000000000001',
|
||||
sourceIdentity: 'esi:character-wallet-journal',
|
||||
windowStart: 1_699_900_000_000,
|
||||
windowEnd: 1_700_000_100_000,
|
||||
gaps: [{ from: null, to: 'journal-from-90000000000000001', reason: 'older history unavailable upstream' }],
|
||||
complete: false,
|
||||
},
|
||||
fetchedAt: 1_700_000_100_000,
|
||||
upstreamEffectiveAt: null,
|
||||
};
|
||||
|
||||
export const singletonRows: readonly Pick<InventoryRow, 'isSingleton'>[] = [
|
||||
{ isSingleton: true },
|
||||
{ isSingleton: false },
|
||||
{ isSingleton: null },
|
||||
];
|
||||
|
||||
export const ambiguousType: EntityResolution<{ id: number; name: string }> = {
|
||||
status: 'ambiguous',
|
||||
candidates: [{ id: 34, name: 'Tritanium' }, { id: 35, name: 'Pyerite' }],
|
||||
};
|
||||
|
||||
export const authorization: ResourceAuthorization = {
|
||||
principal: syntheticPrincipal,
|
||||
userId: 'fixture-user-a',
|
||||
status: 'active',
|
||||
grantRevision: 7,
|
||||
credentialVersion: 3,
|
||||
grantedScopes: ['esi-assets.read_assets.v1'],
|
||||
observedAt: 1_700_000_100_000,
|
||||
staleAuthority: { state: 'current', observedAt: 1_700_000_100_000, maximumWindowMs: null },
|
||||
authorizationEpoch: 1,
|
||||
};
|
||||
|
||||
export const consent: ConsentBinding = {
|
||||
bindingId: 'consent-fixture-1',
|
||||
sessionId: 'session-fixture-1',
|
||||
userId: 'fixture-user-a',
|
||||
intent: 'upgrade_dataset',
|
||||
capability: 'inventory_query',
|
||||
resourceRequests: [{
|
||||
resource: syntheticResource,
|
||||
requestedScopes: ['esi-assets.read_assets.v1'],
|
||||
approvedExistingScopes: [],
|
||||
}],
|
||||
createdAt: 1_700_000_000_000,
|
||||
expiresAt: 1_700_000_300_000,
|
||||
state: 'pending',
|
||||
};
|
||||
|
||||
export const systemJob: DatasetJob = {
|
||||
id: 'job-reference-fixture-1',
|
||||
owner: { kind: 'system', service: 'reference' },
|
||||
authority: 'system',
|
||||
dataset: 'reference_data',
|
||||
status: 'queued',
|
||||
attempts: 0,
|
||||
dueAt: 1_700_000_200_000,
|
||||
leaseExpiresAt: null,
|
||||
publicationFence: {
|
||||
jobId: 'job-reference-fixture-1',
|
||||
principal: { kind: 'system', id: 'reference-public' },
|
||||
dataset: 'reference_data',
|
||||
resources: [],
|
||||
coverageKind: 'snapshot',
|
||||
generation: 'reference-g1',
|
||||
checkpoint: null,
|
||||
},
|
||||
};
|
||||
|
||||
export const inventoryCursor: InventoryCursor = { token: 'cursor-fixture-opaque' };
|
||||
export const inventoryCursorState: InventoryCursorState = {
|
||||
token: inventoryCursor.token,
|
||||
status: 'active',
|
||||
position: { offset: 0, lastItemId: null },
|
||||
pin: {
|
||||
callerUserId: 'fixture-user-a',
|
||||
queryFingerprint: 'sha256:fixture-query',
|
||||
selectedResources: [syntheticResource],
|
||||
authorizationRevisions: { 'character:90000000000000001': 7 },
|
||||
authorizationEpochs: { 'character:90000000000000001': 1 },
|
||||
snapshotGenerations: { assets: 'assets-g7' },
|
||||
referenceVersion: 'reference-g1',
|
||||
priceVersion: 'prices-g1',
|
||||
expiresAt: 1_700_000_300_000,
|
||||
},
|
||||
};
|
||||
|
||||
export const inventoryQuery: InventoryQuery = {
|
||||
callerUserId: 'fixture-user-a',
|
||||
selectedResources: [syntheticResource],
|
||||
authorizationRevisions: { 'character:90000000000000001': 7 },
|
||||
authorizationEpochs: { 'character:90000000000000001': 1 },
|
||||
filters: { typeIds: [34], minQuantity: '2', blueprintState: 'all' },
|
||||
sort: { field: 'name', direction: 'ascending', tieBreaker: 'item_id' },
|
||||
pageSize: 50,
|
||||
cursor: inventoryCursor,
|
||||
};
|
||||
|
||||
export const inventoryResult: InventoryQueryResult = {
|
||||
status: 'ready',
|
||||
rows: [],
|
||||
summary: { matchingRows: 0, matchingQuantity: '0', estimatedValue: '0', scope: 'all_matching_rows' },
|
||||
nextCursor: null,
|
||||
pageState: 'initial',
|
||||
provenance: {
|
||||
reportId: 'report-fixture-1',
|
||||
generatedAt: 1_700_000_200_000,
|
||||
fetchedAt: { assets: 1_700_000_100_000 },
|
||||
upstreamEffectiveAt: { assets: null },
|
||||
input: {
|
||||
selectedResources: [syntheticResource],
|
||||
requiredDatasetKinds: ['assets'],
|
||||
pinSet: 'exact_selected_resource_dataset_set',
|
||||
datasetPins: [{
|
||||
selectedResource: syntheticResource,
|
||||
principal: syntheticPrincipal,
|
||||
dataset: 'assets',
|
||||
coverage: { kind: 'snapshot', generation: 'assets-g7', complete: true },
|
||||
authorizationRevision: 7,
|
||||
authorizationEpoch: 1,
|
||||
fetchedAt: 1_700_000_100_000,
|
||||
upstreamEffectiveAt: null,
|
||||
}],
|
||||
authorizationRevisions: { 'character:90000000000000001': 7 },
|
||||
authorizationEpochs: { 'character:90000000000000001': 1 },
|
||||
snapshotGenerations: { assets: 'assets-g7' },
|
||||
appendCheckpoints: {},
|
||||
referenceVersion: 'reference-g1',
|
||||
priceVersion: 'prices-g1',
|
||||
},
|
||||
sourceSkew: false,
|
||||
assumptions: [],
|
||||
},
|
||||
};
|
||||
|
||||
export const afterEndInventoryCursorState: InventoryCursorState = {
|
||||
...inventoryCursorState,
|
||||
status: 'exhausted',
|
||||
position: { offset: 2, lastItemId: '90000000000000042' },
|
||||
};
|
||||
|
||||
export const afterEndInventoryResult: InventoryQueryResult = {
|
||||
status: 'ready',
|
||||
rows: [],
|
||||
summary: { matchingRows: 2, matchingQuantity: '3', estimatedValue: '100', scope: 'all_matching_rows' },
|
||||
nextCursor: null,
|
||||
pageState: 'after_end',
|
||||
provenance: inventoryResult.provenance,
|
||||
};
|
||||
|
||||
export const walletResult: WalletBalanceResult = {
|
||||
status: 'ready',
|
||||
components: [{
|
||||
component: 'wallet_balance',
|
||||
principal: syntheticPrincipal,
|
||||
amount: '-125',
|
||||
fetchedAt: 1_700_000_100_000,
|
||||
upstreamEffectiveAt: null,
|
||||
coverage: { kind: 'snapshot', generation: 'wallet-g2', complete: true },
|
||||
authorizationRevision: 4,
|
||||
credentialVersion: 2,
|
||||
}],
|
||||
provenance: {
|
||||
...inventoryResult.provenance,
|
||||
input: {
|
||||
...inventoryResult.provenance.input,
|
||||
requiredDatasetKinds: ['wallet_balance'],
|
||||
pinSet: 'exact_selected_resource_dataset_set',
|
||||
datasetPins: [{
|
||||
selectedResource: syntheticResource,
|
||||
principal: syntheticPrincipal,
|
||||
dataset: 'wallet_balance',
|
||||
coverage: { kind: 'snapshot', generation: 'wallet-g2', complete: true },
|
||||
authorizationRevision: 4,
|
||||
authorizationEpoch: 1,
|
||||
fetchedAt: 1_700_000_100_000,
|
||||
upstreamEffectiveAt: null,
|
||||
}],
|
||||
authorizationRevisions: { 'character:90000000000000001': 4 },
|
||||
authorizationEpochs: { 'character:90000000000000001': 1 },
|
||||
snapshotGenerations: { wallet_balance: 'wallet-g2' },
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
/** Synthetic fixture for the approved, fixed signed-decimal policy. */
|
||||
export const approvedMoneyPolicy: SignedMoneyNormalizationPolicy = {
|
||||
input: 'decimal_text',
|
||||
scale: 2,
|
||||
rounding: 'half_away_from_zero',
|
||||
grammar: 'json_number_ascii_decimal',
|
||||
maxRawInputCharacters: 8192,
|
||||
maxCoefficientDigits: 4096,
|
||||
exponentRange: [-1000, 1000],
|
||||
centsShiftRange: [-1000, 1000],
|
||||
rejectWhitespace: true,
|
||||
canonicalizeNegativeZero: true,
|
||||
};
|
||||
Reference in New Issue
Block a user