@pacspace-io/sdk 0.9.0 → 0.15.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.
Files changed (152) hide show
  1. package/README.md +53 -132
  2. package/dist/blinding-file.d.ts +13 -0
  3. package/dist/blinding-file.d.ts.map +1 -0
  4. package/dist/blinding-guard.d.ts +7 -0
  5. package/dist/blinding-guard.d.ts.map +1 -0
  6. package/dist/blinding.d.ts +32 -0
  7. package/dist/blinding.d.ts.map +1 -0
  8. package/dist/client.d.ts +28 -4
  9. package/dist/client.d.ts.map +1 -1
  10. package/dist/fingerprint.d.ts +26 -5
  11. package/dist/fingerprint.d.ts.map +1 -1
  12. package/dist/index.d.ts +35 -35
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +7366 -186
  15. package/dist/index.js.map +7 -1
  16. package/dist/inputs.txt +132 -0
  17. package/dist/records-crypto-libraries.json +42 -0
  18. package/dist/records-crypto-types/proof/hiding-commitment-v1.d.ts +19 -0
  19. package/dist/records-crypto-types/proof/jcs.d.ts +4 -0
  20. package/dist/records-crypto-types/proof/layout-document-v1.d.ts +72 -0
  21. package/dist/records-crypto-types/proof/ledger-head-v1.d.ts +22 -0
  22. package/dist/records-crypto-types/proof/merkle-v2.d.ts +5 -0
  23. package/dist/records-crypto-types/proof/payload-ref-v1.d.ts +17 -0
  24. package/dist/records-crypto-types/proof/seal-input.d.ts +2 -0
  25. package/dist/records-crypto-types/proof/semantic-receipt-v2.d.ts +89 -0
  26. package/dist/records-crypto-types/proof/semantic-receipt-v3.d.ts +20 -0
  27. package/dist/records-crypto-types/proof/slot-encoding-v1.d.ts +169 -0
  28. package/dist/records-crypto-types/records/flag-threads-v1.d.ts +53 -0
  29. package/dist/records-crypto-types/records/labels.d.ts +37 -0
  30. package/dist/records-crypto-types/records/reader-crypto-v1.d.ts +198 -0
  31. package/dist/records-crypto-types/records/reader-link-v1.d.ts +164 -0
  32. package/dist/records-crypto-types/records/shared-record-ack-v2.d.ts +72 -0
  33. package/dist/records-crypto-types/records/signed-acknowledgment-v1.d.ts +38 -0
  34. package/dist/records-crypto-types/records/signed-acknowledgment-v2.d.ts +12 -0
  35. package/dist/records-crypto-types/records/trail-index-v1.d.ts +89 -0
  36. package/dist/records-crypto-types/records/trail-rule.d.ts +54 -0
  37. package/dist/records-crypto-types/records-crypto/asymmetric/ack-flag-notes-v1.d.ts +57 -0
  38. package/dist/records-crypto-types/records-crypto/asymmetric/flag-notes-v1.d.ts +55 -0
  39. package/dist/records-crypto-types/records-crypto/asymmetric/index.d.ts +4 -0
  40. package/dist/records-crypto-types/records-crypto/asymmetric/reader-wraps-v1.d.ts +83 -0
  41. package/dist/records-crypto-types/records-crypto/asymmetric/records-asymmetric-v1.d.ts +201 -0
  42. package/dist/records-crypto-types/records-crypto/base64url.d.ts +3 -0
  43. package/dist/records-crypto-types/records-crypto/blinding-file.d.ts +16 -0
  44. package/dist/records-crypto-types/records-crypto/blinding-value.d.ts +10 -0
  45. package/dist/records-crypto-types/records-crypto/bundle-entry.d.ts +2 -0
  46. package/dist/records-crypto-types/records-crypto/disclosure-envelope-v1.d.ts +42 -0
  47. package/dist/records-crypto-types/records-crypto/held-file.d.ts +17 -0
  48. package/dist/records-crypto-types/records-crypto/hmac-node.d.ts +8 -0
  49. package/dist/records-crypto-types/records-crypto/hmac-web.d.ts +8 -0
  50. package/dist/records-crypto-types/records-crypto/index.d.ts +13 -0
  51. package/dist/records-crypto-types/records-crypto/platform-crypto.d.ts +9 -0
  52. package/dist/records-crypto-types/records-crypto/record-disclosure-v1.d.ts +171 -0
  53. package/dist/records-crypto-types/records-crypto/record-hash-v2.d.ts +49 -0
  54. package/dist/records-crypto-types/records-crypto/record-hash-v3.d.ts +36 -0
  55. package/dist/records-crypto-types/records-crypto/records-encryption-v1.d.ts +185 -0
  56. package/dist/records-crypto-types/records-crypto/wrap-shapes-v1.d.ts +23 -0
  57. package/dist/records-crypto.d.ts +1 -0
  58. package/dist/records-crypto.js +16105 -0
  59. package/dist/records-crypto.js.map +7 -0
  60. package/dist/records-encryption/base64url.d.ts +5 -0
  61. package/dist/records-encryption/base64url.d.ts.map +1 -0
  62. package/dist/records-encryption/encrypted-records.d.ts +338 -0
  63. package/dist/records-encryption/encrypted-records.d.ts.map +1 -0
  64. package/dist/records-encryption/index.d.ts +14 -0
  65. package/dist/records-encryption/index.d.ts.map +1 -0
  66. package/dist/records-encryption/keys.d.ts +40 -0
  67. package/dist/records-encryption/keys.d.ts.map +1 -0
  68. package/dist/records-encryption/loader.d.ts +15 -0
  69. package/dist/records-encryption/loader.d.ts.map +1 -0
  70. package/dist/records-encryption/pin-store-file.d.ts +8 -0
  71. package/dist/records-encryption/pin-store-file.d.ts.map +1 -0
  72. package/dist/records-encryption/pin-store.d.ts +17 -0
  73. package/dist/records-encryption/pin-store.d.ts.map +1 -0
  74. package/dist/records-encryption/transport.d.ts +23 -0
  75. package/dist/records-encryption/transport.d.ts.map +1 -0
  76. package/dist/records-encryption/words.d.ts +40 -0
  77. package/dist/records-encryption/words.d.ts.map +1 -0
  78. package/dist/records-encryption/workspace-secret.d.ts +9 -0
  79. package/dist/records-encryption/workspace-secret.d.ts.map +1 -0
  80. package/dist/resources/records.d.ts +112 -2
  81. package/dist/resources/records.d.ts.map +1 -1
  82. package/dist/types/common.d.ts +0 -8
  83. package/dist/types/common.d.ts.map +1 -1
  84. package/dist/types/config.d.ts +7 -5
  85. package/dist/types/config.d.ts.map +1 -1
  86. package/dist/types/records-encryption.d.ts +136 -0
  87. package/dist/types/records-encryption.d.ts.map +1 -0
  88. package/dist/types/records.d.ts +171 -20
  89. package/dist/types/records.d.ts.map +1 -1
  90. package/dist/types/verify.d.ts +84 -0
  91. package/dist/types/verify.d.ts.map +1 -0
  92. package/dist/webhooks/index.d.ts +1 -1
  93. package/dist/webhooks/index.d.ts.map +1 -1
  94. package/dist/webhooks/index.js +229 -5
  95. package/dist/webhooks/index.js.map +7 -1
  96. package/dist/webhooks/types.d.ts +15 -7
  97. package/dist/webhooks/types.d.ts.map +1 -1
  98. package/dist/workspace-secret-file.d.ts +18 -0
  99. package/dist/workspace-secret-file.d.ts.map +1 -0
  100. package/package.json +16 -13
  101. package/dist/client.js +0 -553
  102. package/dist/client.js.map +0 -1
  103. package/dist/errors/index.js +0 -223
  104. package/dist/errors/index.js.map +0 -1
  105. package/dist/fingerprint.js +0 -132
  106. package/dist/fingerprint.js.map +0 -1
  107. package/dist/resources/balance.d.ts +0 -384
  108. package/dist/resources/balance.d.ts.map +0 -1
  109. package/dist/resources/balance.js +0 -1120
  110. package/dist/resources/balance.js.map +0 -1
  111. package/dist/resources/customers.d.ts +0 -33
  112. package/dist/resources/customers.d.ts.map +0 -1
  113. package/dist/resources/customers.js +0 -26
  114. package/dist/resources/customers.js.map +0 -1
  115. package/dist/resources/internal/batch-transport.d.ts +0 -65
  116. package/dist/resources/internal/batch-transport.d.ts.map +0 -1
  117. package/dist/resources/internal/batch-transport.js +0 -42
  118. package/dist/resources/internal/batch-transport.js.map +0 -1
  119. package/dist/resources/receipts.d.ts +0 -46
  120. package/dist/resources/receipts.d.ts.map +0 -1
  121. package/dist/resources/receipts.js +0 -133
  122. package/dist/resources/receipts.js.map +0 -1
  123. package/dist/resources/records.js +0 -232
  124. package/dist/resources/records.js.map +0 -1
  125. package/dist/resources/submission.d.ts +0 -79
  126. package/dist/resources/submission.d.ts.map +0 -1
  127. package/dist/resources/submission.js +0 -398
  128. package/dist/resources/submission.js.map +0 -1
  129. package/dist/types/balance.d.ts +0 -966
  130. package/dist/types/balance.d.ts.map +0 -1
  131. package/dist/types/balance.js +0 -3
  132. package/dist/types/balance.js.map +0 -1
  133. package/dist/types/common.js +0 -3
  134. package/dist/types/common.js.map +0 -1
  135. package/dist/types/config.js +0 -3
  136. package/dist/types/config.js.map +0 -1
  137. package/dist/types/records.js +0 -5
  138. package/dist/types/records.js.map +0 -1
  139. package/dist/types/submission.d.ts +0 -125
  140. package/dist/types/submission.d.ts.map +0 -1
  141. package/dist/types/submission.js +0 -3
  142. package/dist/types/submission.js.map +0 -1
  143. package/dist/utils/polling.d.ts +0 -32
  144. package/dist/utils/polling.d.ts.map +0 -1
  145. package/dist/utils/polling.js +0 -52
  146. package/dist/utils/polling.js.map +0 -1
  147. package/dist/utils/retry.js +0 -21
  148. package/dist/utils/retry.js.map +0 -1
  149. package/dist/webhooks/types.js +0 -3
  150. package/dist/webhooks/types.js.map +0 -1
  151. package/dist/webhooks/verify.js +0 -191
  152. package/dist/webhooks/verify.js.map +0 -1
@@ -1,232 +0,0 @@
1
- "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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.RecordsResource = void 0;
37
- const records_1 = require("../types/records");
38
- function recordPath(recordType, record, suffix) {
39
- const type = encodeURIComponent(recordType || records_1.DEFAULT_RECORD_TYPE);
40
- const id = encodeURIComponent(record);
41
- return `/api/v1/records/${type}/${id}${suffix}`;
42
- }
43
- function payloadsOf(receipt) {
44
- const content = receipt.recordContent ??
45
- (receipt.sealedRecord?.content);
46
- const payloads = content?.payloads;
47
- return Array.isArray(payloads) ? payloads : [];
48
- }
49
- function fingerprintKey(ref) {
50
- return `${ref.alg ?? ''}:${String(ref.digest ?? '').toLowerCase()}:${ref.byteLength ?? ''}`;
51
- }
52
- function historyEntries(history) {
53
- if (Array.isArray(history.entries) && history.entries.length > 0) {
54
- return history.entries;
55
- }
56
- const committed = (history.receipts ?? []).map((receipt) => ({
57
- seq: typeof receipt.seq === 'number' ? receipt.seq : null,
58
- status: receipt.status || 'committed',
59
- receiptId: typeof receipt.receiptId === 'string' ? receipt.receiptId : undefined,
60
- }));
61
- return [...committed, ...(history.pendingEntries ?? [])].sort((a, b) => (a.seq ?? 0) - (b.seq ?? 0));
62
- }
63
- class RecordsResource {
64
- constructor(client) {
65
- this.client = client;
66
- }
67
- async emit(input, options) {
68
- const content = {
69
- title: input.title,
70
- occurredAt: input.occurredAt,
71
- actorId: input.actorId,
72
- payloads: input.payloads,
73
- };
74
- if (input.kind !== undefined)
75
- content.kind = input.kind;
76
- if (input.instructedBy !== undefined)
77
- content.instructedBy = input.instructedBy;
78
- if (input.description !== undefined)
79
- content.description = input.description;
80
- if (input.note !== undefined)
81
- content.note = input.note;
82
- if (input.references) {
83
- content.references = input.references.map((ref) => ({
84
- recordKey: ref.recordKey,
85
- seq: ref.entry,
86
- }));
87
- }
88
- if (input.amends) {
89
- content.amends = { recordKey: input.amends.recordKey, seq: input.amends.entry };
90
- }
91
- const body = {
92
- lifecycle: input.lifecycle ?? 'recorded',
93
- content,
94
- };
95
- if (input.idempotencyKey)
96
- body.referenceId = input.idempotencyKey;
97
- const response = await this.client.post(recordPath(input.recordType, input.record, '/transitions'), body, options);
98
- if (response.code === 'IDEMPOTENCY_PENDING') {
99
- return {
100
- receiptId: '',
101
- recordType: input.recordType || records_1.DEFAULT_RECORD_TYPE,
102
- entityId: input.record,
103
- recordKey: '',
104
- status: 'QUEUED',
105
- code: 'IDEMPOTENCY_PENDING',
106
- retryAfterSeconds: typeof response.retryAfterSeconds === 'number'
107
- ? response.retryAfterSeconds
108
- : undefined,
109
- message: typeof response.message === 'string' ? response.message : undefined,
110
- };
111
- }
112
- return {
113
- intakeId: typeof response.intakeId === 'string' ? response.intakeId : undefined,
114
- receiptId: String(response.receiptId ?? ''),
115
- recordType: String(response.recordType ?? input.recordType ?? records_1.DEFAULT_RECORD_TYPE),
116
- entityId: String(response.entityId ?? input.record),
117
- recordKey: String(response.recordKey ?? ''),
118
- layoutId: typeof response.layoutId === 'number' ? response.layoutId : undefined,
119
- layoutVersion: typeof response.layoutVersion === 'number' ? response.layoutVersion : undefined,
120
- lifecycle: typeof response.lifecycle === 'string' ? response.lifecycle : undefined,
121
- status: String(response.status ?? 'QUEUED'),
122
- referenceId: typeof response.referenceId === 'string' ? response.referenceId : undefined,
123
- receivedAt: typeof response.receivedAt === 'string' ? response.receivedAt : undefined,
124
- queuedViaOverflow: response.queuedViaOverflow === true,
125
- message: typeof response.message === 'string' ? response.message : undefined,
126
- };
127
- }
128
- async receipt(input, options) {
129
- return this.client.get(recordPath(input.recordType, input.record, `/receipts/${encodeURIComponent(String(input.entry))}`), options);
130
- }
131
- async history(input, options) {
132
- const query = new URLSearchParams();
133
- if (input.fromEntry !== undefined)
134
- query.set('fromSeq', String(input.fromEntry));
135
- if (input.toEntry !== undefined)
136
- query.set('toSeq', String(input.toEntry));
137
- const suffix = query.toString() ? `/history?${query.toString()}` : '/history';
138
- const raw = await this.client.getRaw(recordPath(input.recordType, input.record, suffix), options);
139
- const next = raw.headers.get('x-next-from-seq');
140
- return {
141
- ...raw.body,
142
- nextFromSeq: next !== null ? Number(next) : raw.body.nextFromSeq ?? null,
143
- };
144
- }
145
- async check(input) {
146
- const entries = historyEntries(input.history);
147
- const expectByEntry = new Map((input.expect ?? []).map((row) => [row.entry, row.payloads]));
148
- const receiptsBySeq = new Map();
149
- for (const receipt of input.history.receipts ?? []) {
150
- if (typeof receipt.seq === 'number')
151
- receiptsBySeq.set(receipt.seq, receipt);
152
- }
153
- const entryResults = entries.map((entry) => {
154
- const result = {
155
- entry: entry.seq,
156
- status: entry.status,
157
- code: entry.code,
158
- sentence: entry.sentence,
159
- };
160
- if (entry.seq !== null && expectByEntry.has(entry.seq)) {
161
- const wanted = expectByEntry.get(entry.seq) ?? [];
162
- const committed = payloadsOf(receiptsBySeq.get(entry.seq) ?? {});
163
- const committedKeys = new Set(committed.map(fingerprintKey));
164
- result.expected = wanted.every((ref) => committedKeys.has(fingerprintKey(ref)));
165
- }
166
- return result;
167
- });
168
- let failedCheck = null;
169
- let reason;
170
- let bundleOk = entries.some((entry) => entry.status === 'committed');
171
- let sourceChecked = false;
172
- let chainWord;
173
- if (input.source) {
174
- try {
175
- const shared = await Promise.resolve().then(() => __importStar(require('@pacspace/shared')));
176
- const chain = input.history.chain;
177
- const contractAddress = input.source.address || chain?.contractAddress;
178
- if (contractAddress) {
179
- const reader = input.source.kind === 'direct' && input.source.url
180
- ? shared.createRpcRecordChainReader({
181
- rpcUrl: input.source.url,
182
- contractAddress,
183
- chainId: chain?.chainId,
184
- })
185
- : shared.createMirrorNodeRecordChainReader({
186
- mirrorBaseUrl: input.source.url,
187
- contractAddress,
188
- chainId: chain?.chainId,
189
- });
190
- chainWord = await reader.getRecord(input.history.recordKey);
191
- sourceChecked = true;
192
- }
193
- }
194
- catch {
195
- sourceChecked = false;
196
- }
197
- }
198
- try {
199
- const shared = await Promise.resolve().then(() => __importStar(require('@pacspace/shared')));
200
- const verification = shared.verifyRecordHistoryBundleV1(input.history, chainWord !== undefined ? { chainWord } : {});
201
- bundleOk = verification.verified;
202
- if (!verification.verified) {
203
- failedCheck = verification.history?.perReceipt.find((row) => !row.result.verified)?.result.failedCheck
204
- ?? (verification.schemaOk ? (verification.digestOk ? 'semantic' : 'schema') : 'schema');
205
- reason = verification.reason;
206
- }
207
- }
208
- catch {
209
- if (!bundleOk) {
210
- failedCheck = 'schema';
211
- reason = 'No committed entries.';
212
- }
213
- }
214
- const expectFailed = entryResults.some((row) => row.expected === false);
215
- if (expectFailed && !failedCheck)
216
- failedCheck = 'semantic';
217
- const failedEntries = entries.filter((entry) => entry.status === 'failed');
218
- if (failedEntries.length > 0 && !failedCheck) {
219
- failedCheck = 'schema';
220
- reason = failedEntries[0]?.sentence ?? 'A queued write did not commit.';
221
- }
222
- return {
223
- ok: bundleOk && !expectFailed && failedEntries.length === 0 && failedCheck === null,
224
- entries: entryResults,
225
- failedCheck,
226
- sourceChecked,
227
- reason,
228
- };
229
- }
230
- }
231
- exports.RecordsResource = RecordsResource;
232
- //# sourceMappingURL=records.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"records.js","sourceRoot":"","sources":["../../src/resources/records.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,8CAAuD;AAEvD,SAAS,UAAU,CAAC,UAA8B,EAAE,MAAc,EAAE,MAAc;IAChF,MAAM,IAAI,GAAG,kBAAkB,CAAC,UAAU,IAAI,6BAAmB,CAAC,CAAC;IACnE,MAAM,EAAE,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACtC,OAAO,mBAAmB,IAAI,IAAI,EAAE,GAAG,MAAM,EAAE,CAAC;AAClD,CAAC;AAED,SAAS,UAAU,CAAC,OAAgC;IAClD,MAAM,OAAO,GACV,OAAO,CAAC,aAAqD;QAC9D,CAAE,OAAO,CAAC,YAAkE,EAAE,OAAO,CAAC,CAAC;IACzF,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,CAAC;IACnC,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;AACjD,CAAC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ACJ,CAAC;CACF;AAvLD,0CAuLC"}
@@ -1,79 +0,0 @@
1
- import type { InternalBatchDelta, InternalBatchResponse } from './internal/batch-transport';
2
- import type { CustomerUsageSummary, FlushSummariesOptions, QueuedUsageSummary, SubmissionAutomationOptions, SubmissionQueueState, SummaryFlushResult } from '../types/submission';
3
- type SubmitBatchFn = (deltas: InternalBatchDelta[]) => Promise<InternalBatchResponse>;
4
- interface SubmissionCoordinatorConfig {
5
- submitBatch: SubmitBatchFn;
6
- options?: SubmissionAutomationOptions;
7
- }
8
- /**
9
- * Tenant-owned metering submission automation.
10
- *
11
- * This coordinator only submits tenant-produced summaries. It does not infer
12
- * or meter raw product usage events.
13
- */
14
- export declare class SubmissionCoordinator {
15
- private static readonly trackedCoordinators;
16
- private static shutdownHooksRegistered;
17
- private static readonly shutdownHandlers;
18
- private readonly submitBatch;
19
- private readonly profile;
20
- private readonly cadenceMs;
21
- private readonly enterprise;
22
- private readonly autoStart;
23
- private readonly autoFlushOnShutdown;
24
- private readonly maxDeltasPerRequest;
25
- private readonly maxRequestsPerMinute;
26
- private readonly defaultReason;
27
- private readonly queue;
28
- private shutdownTracked;
29
- private timer;
30
- private running;
31
- private nextFlushAt;
32
- private activeFlush;
33
- private lastRequestAt;
34
- constructor(config: SubmissionCoordinatorConfig);
35
- /**
36
- * Enqueue one tenant-produced customer summary.
37
- */
38
- queueSummary(summary: CustomerUsageSummary): QueuedUsageSummary;
39
- /**
40
- * Enqueue multiple tenant-produced summaries.
41
- */
42
- queueSummaries(summaries: CustomerUsageSummary[]): QueuedUsageSummary[];
43
- /**
44
- * Returns queue and scheduler state.
45
- */
46
- getQueueState(): SubmissionQueueState;
47
- /**
48
- * Start scheduled flushes for non-immediate profiles.
49
- */
50
- start(): void;
51
- /**
52
- * Stop scheduled flushes.
53
- */
54
- stop(): void;
55
- /**
56
- * Flush queued summaries immediately.
57
- */
58
- flushSummaries(options?: FlushSummariesOptions): Promise<SummaryFlushResult>;
59
- /**
60
- * Stop scheduler, flush pending work, and unregister shutdown hooks.
61
- */
62
- shutdown(): Promise<void>;
63
- private assertProfileCompatibility;
64
- private normalizeSummary;
65
- private normalizeIso;
66
- private buildReferenceId;
67
- private performFlush;
68
- private paceRequests;
69
- private chunk;
70
- private scheduleNextFlush;
71
- private onScheduledFlush;
72
- private ensureShutdownHooks;
73
- private static flushTrackedCoordinators;
74
- private trackShutdownHooks;
75
- private untrackShutdownHooks;
76
- private sleep;
77
- }
78
- export {};
79
- //# sourceMappingURL=submission.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"submission.d.ts","sourceRoot":"","sources":["../../src/resources/submission.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,2BAA2B,EAE3B,oBAAoB,EAEpB,kBAAkB,EACnB,MAAM,qBAAqB,CAAC;AAE7B,KAAK,aAAa,GAAG,CACnB,MAAM,EAAE,kBAAkB,EAAE,KACzB,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAEpC,UAAU,2BAA2B;IACnC,WAAW,EAAE,aAAa,CAAC;IAC3B,OAAO,CAAC,EAAE,2BAA2B,CAAC;CACvC;AAUD;;;;;GAKG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAoC;IAC/E,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAAS;IAC/C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAatC;IAEF,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAgB;IAC5C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;IAC5C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAU;IACrC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAU;IAC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