@substrat-run/contracts 0.159.0 → 0.161.0
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/attachments.d.ts +102 -0
- package/dist/attachments.d.ts.map +1 -1
- package/dist/attachments.js +100 -1
- package/dist/attachments.js.map +1 -1
- package/dist/control-plane.d.ts +379 -8
- package/dist/control-plane.d.ts.map +1 -1
- package/dist/control-plane.js +341 -9
- package/dist/control-plane.js.map +1 -1
- package/dist/file-source.d.ts +167 -0
- package/dist/file-source.d.ts.map +1 -0
- package/dist/file-source.js +144 -0
- package/dist/file-source.js.map +1 -0
- package/dist/ids.d.ts +7 -0
- package/dist/ids.d.ts.map +1 -1
- package/dist/ids.js +7 -0
- package/dist/ids.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/introspection.d.ts +1 -0
- package/dist/introspection.d.ts.map +1 -1
- package/dist/introspection.js +11 -0
- package/dist/introspection.js.map +1 -1
- package/dist/platform-request.d.ts +2 -2
- package/dist/platform-request.d.ts.map +1 -1
- package/dist/platform-request.js +8 -6
- package/dist/platform-request.js.map +1 -1
- package/dist/registry.d.ts +27 -0
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +28 -0
- package/dist/registry.js.map +1 -1
- package/dist/wire-headers.d.ts +15 -0
- package/dist/wire-headers.d.ts.map +1 -1
- package/dist/wire-headers.js +15 -0
- package/dist/wire-headers.js.map +1 -1
- package/dist/wire-signing.d.ts +443 -0
- package/dist/wire-signing.d.ts.map +1 -0
- package/dist/wire-signing.js +734 -0
- package/dist/wire-signing.js.map +1 -0
- package/package.json +5 -1
package/dist/attachments.d.ts
CHANGED
|
@@ -35,6 +35,61 @@ export declare const attachmentRecord: z.ZodObject<{
|
|
|
35
35
|
createdAt: z.core.$ZodBranded<z.ZodString, "Instant", "out">;
|
|
36
36
|
}, z.core.$strip>;
|
|
37
37
|
export type AttachmentRecord = z.infer<typeof attachmentRecord>;
|
|
38
|
+
/**
|
|
39
|
+
* A record without what only its bytes can say (#2498): an upload judges these fields before it
|
|
40
|
+
* writes a byte, and a streamed body's `size` and `sha256` are known only once it has been read.
|
|
41
|
+
*/
|
|
42
|
+
export declare const attachmentRecordFields: z.ZodObject<{
|
|
43
|
+
id: z.ZodString;
|
|
44
|
+
entity: z.ZodObject<{
|
|
45
|
+
entityType: z.ZodString;
|
|
46
|
+
entityId: z.ZodString;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
filename: z.ZodString;
|
|
49
|
+
contentType: z.ZodString;
|
|
50
|
+
visibility: z.ZodEnum<{
|
|
51
|
+
customer: "customer";
|
|
52
|
+
internal: "internal";
|
|
53
|
+
}>;
|
|
54
|
+
createdBy: z.ZodString;
|
|
55
|
+
createdAt: z.core.$ZodBranded<z.ZodString, "Instant", "out">;
|
|
56
|
+
}, z.core.$strip>;
|
|
57
|
+
/** The fields as a caller hands them over, before they are judged. */
|
|
58
|
+
export type AttachmentRecordFields = z.input<typeof attachmentRecordFields>;
|
|
59
|
+
/**
|
|
60
|
+
* The longest each caller-supplied string of a NEW attachment may be, in UTF-16 units (#2519). A
|
|
61
|
+
* connector reads a record back through a response header, where a non-ASCII unit costs up to 6
|
|
62
|
+
* bytes escaped, so the strings it carries are bounded where the record is made: at 512 + 255 +
|
|
63
|
+
* 128 + 255 + 128 units the record is under 8.2 KiB. 512 keeps a realistic 400-character path
|
|
64
|
+
* storable. {@link attachmentRecord} itself is NOT capped: it is also what a stored row is parsed
|
|
65
|
+
* against, and a row written before these bounds must stay readable.
|
|
66
|
+
*/
|
|
67
|
+
export declare const ATTACHMENT_FIELD_MAX: {
|
|
68
|
+
readonly filename: 512;
|
|
69
|
+
readonly contentType: 255;
|
|
70
|
+
readonly entityType: 128;
|
|
71
|
+
readonly entityId: 255;
|
|
72
|
+
readonly createdBy: 128;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* {@link attachmentRecordFields} as an upload judges it: the same fields, each bounded by
|
|
76
|
+
* {@link ATTACHMENT_FIELD_MAX}. One judge for every door that stores an attachment.
|
|
77
|
+
*/
|
|
78
|
+
export declare const attachmentUploadFields: z.ZodObject<{
|
|
79
|
+
id: z.ZodString;
|
|
80
|
+
visibility: z.ZodEnum<{
|
|
81
|
+
customer: "customer";
|
|
82
|
+
internal: "internal";
|
|
83
|
+
}>;
|
|
84
|
+
createdAt: z.core.$ZodBranded<z.ZodString, "Instant", "out">;
|
|
85
|
+
entity: z.ZodObject<{
|
|
86
|
+
entityType: z.ZodString;
|
|
87
|
+
entityId: z.ZodString;
|
|
88
|
+
}, z.core.$strip>;
|
|
89
|
+
filename: z.ZodString;
|
|
90
|
+
contentType: z.ZodString;
|
|
91
|
+
createdBy: z.ZodString;
|
|
92
|
+
}, z.core.$strip>;
|
|
38
93
|
/**
|
|
39
94
|
* The spine events attachment mutations emit (#473) — kernel-emitted, fat payload (the
|
|
40
95
|
* full `attachmentRecord`), so a consumer (a timeline projection, attachment GC) never
|
|
@@ -225,4 +280,51 @@ export declare const attachmentUploadLinkRevokedPayload: z.ZodObject<{
|
|
|
225
280
|
revokedBy: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
|
|
226
281
|
}, z.core.$strip>;
|
|
227
282
|
export type AttachmentUploadLinkRevokedPayload = z.infer<typeof attachmentUploadLinkRevokedPayload>;
|
|
283
|
+
/**
|
|
284
|
+
* How many bytes a connector upload's metadata takes on the wire: its JSON, URI-encoded, which is
|
|
285
|
+
* what the stream route's header carries. The multipart route carries the same JSON in a field and
|
|
286
|
+
* is held to the same count, taken WITHOUT the stream route's `size` member, so one filename is
|
|
287
|
+
* accepted or refused the same way on both (#2516).
|
|
288
|
+
*/
|
|
289
|
+
export declare function connectorAttachmentMetaBytes(metaJson: string): number;
|
|
290
|
+
/** The one sentence every end uses to refuse metadata over {@link CONNECTOR_ATTACHMENT_META_MAX_BYTES}. */
|
|
291
|
+
export declare function connectorAttachmentMetaRefusal(bytes: number): string;
|
|
292
|
+
/**
|
|
293
|
+
* The most bytes one streamed connector upload may carry (#2516). Streaming took the worker's
|
|
294
|
+
* memory out of the limit, which left nothing bounding a file; this is that bound, held where the
|
|
295
|
+
* bytes arrive (the stream route) and again by the platform before it sends, so a file too large
|
|
296
|
+
* is refused with an answer before anything is read or stored. The platform reaches the route
|
|
297
|
+
* through the dispatch namespace, not a zone's edge; the value is kept under 100 MB decimal (about
|
|
298
|
+
* 95.4 MiB), the lowest plan's Workers request-body limit, so that the same file is also one a
|
|
299
|
+
* deployment reached directly by a public request could take.
|
|
300
|
+
*/
|
|
301
|
+
export declare const CONNECTOR_ATTACHMENT_STREAM_MAX_BYTES: number;
|
|
302
|
+
/**
|
|
303
|
+
* The most bytes one BUFFERED connector upload may carry (#2538): the multipart route's file part,
|
|
304
|
+
* and the platform client's `Uint8Array` body. Lower than {@link CONNECTOR_ATTACHMENT_STREAM_MAX_BYTES}
|
|
305
|
+
* because that one is a request-size limit and this one is a memory limit: a stream is never held, but
|
|
306
|
+
* a buffered file is resident several times over at once (the raw body, the parsed form's copy, then
|
|
307
|
+
* the bytes handed on; on the platform side the caller's buffer, the form's copy, the encoded request
|
|
308
|
+
* and the copy read to bind its digest) against a 128 MB isolate. The platform side is the tighter, at
|
|
309
|
+
* about four times the file (an estimate, not a measurement), so 16 MiB (about 64 MiB resident) keeps
|
|
310
|
+
* twice that in hand; it is below the buffered upload-link cap ({@link UPLOAD_LINK_MAX_BYTES_CEILING}).
|
|
311
|
+
* Above it a caller sends a streamed upload, which is the route for a large file.
|
|
312
|
+
*/
|
|
313
|
+
export declare const CONNECTOR_ATTACHMENT_BUFFERED_MAX_BYTES: number;
|
|
314
|
+
/**
|
|
315
|
+
* What the multipart route's body may carry beyond the file (#2538): the `meta` field (at most
|
|
316
|
+
* {@link CONNECTOR_ATTACHMENT_META_MAX_BYTES} once encoded, never more raw), the part headers and
|
|
317
|
+
* the boundaries, with room to spare. A body over the buffered bound plus this is refused unread.
|
|
318
|
+
*/
|
|
319
|
+
export declare const CONNECTOR_ATTACHMENT_MULTIPART_ENVELOPE_BYTES: number;
|
|
320
|
+
/** The one sentence every end uses to refuse a declared size over {@link CONNECTOR_ATTACHMENT_STREAM_MAX_BYTES}. */
|
|
321
|
+
export declare function connectorAttachmentSizeRefusal(declared: number): string;
|
|
322
|
+
/** The sentence for a buffered file over {@link CONNECTOR_ATTACHMENT_BUFFERED_MAX_BYTES}: its own bytes, once known. */
|
|
323
|
+
export declare function connectorAttachmentBufferedRefusal(bytes: number): string;
|
|
324
|
+
/**
|
|
325
|
+
* The sentence for a multipart BODY refused before its file part could be told apart: a
|
|
326
|
+
* `Content-Length` over the bound plus the envelope (`bytes` is that header), or a body cut off while
|
|
327
|
+
* it was read (`bytes` omitted: nobody declared a size). Names the body, not the attachment.
|
|
328
|
+
*/
|
|
329
|
+
export declare function connectorAttachmentBodyRefusal(bytes?: number): string;
|
|
228
330
|
//# sourceMappingURL=attachments.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachments.d.ts","sourceRoot":"","sources":["../src/attachments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"attachments.d.ts","sourceRoot":"","sources":["../src/attachments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB,eAAO,MAAM,UAAU;;;EAAmC,CAAC;AAC3D,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEpD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;iBAe3B,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,sBAAsB;;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AM,CAMrE"}
|
package/dist/attachments.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { entityRef } from './events.js';
|
|
3
3
|
import { instant, principalId } from './ids.js';
|
|
4
|
+
import { CONNECTOR_ATTACHMENT_META_MAX_BYTES } from './wire-headers.js';
|
|
4
5
|
// Visibility classification for attachment items — documents, comments,
|
|
5
6
|
// custom-field values (K-13). Mandatory wherever data can reach the customer
|
|
6
7
|
// portal: like piiClass on events, a classification is only total if it was
|
|
@@ -36,6 +37,39 @@ export const attachmentRecord = z.object({
|
|
|
36
37
|
createdBy: z.string().min(1),
|
|
37
38
|
createdAt: instant,
|
|
38
39
|
});
|
|
40
|
+
/**
|
|
41
|
+
* A record without what only its bytes can say (#2498): an upload judges these fields before it
|
|
42
|
+
* writes a byte, and a streamed body's `size` and `sha256` are known only once it has been read.
|
|
43
|
+
*/
|
|
44
|
+
export const attachmentRecordFields = attachmentRecord.omit({ size: true, sha256: true });
|
|
45
|
+
/**
|
|
46
|
+
* The longest each caller-supplied string of a NEW attachment may be, in UTF-16 units (#2519). A
|
|
47
|
+
* connector reads a record back through a response header, where a non-ASCII unit costs up to 6
|
|
48
|
+
* bytes escaped, so the strings it carries are bounded where the record is made: at 512 + 255 +
|
|
49
|
+
* 128 + 255 + 128 units the record is under 8.2 KiB. 512 keeps a realistic 400-character path
|
|
50
|
+
* storable. {@link attachmentRecord} itself is NOT capped: it is also what a stored row is parsed
|
|
51
|
+
* against, and a row written before these bounds must stay readable.
|
|
52
|
+
*/
|
|
53
|
+
export const ATTACHMENT_FIELD_MAX = {
|
|
54
|
+
filename: 512,
|
|
55
|
+
contentType: 255,
|
|
56
|
+
entityType: 128,
|
|
57
|
+
entityId: 255,
|
|
58
|
+
createdBy: 128,
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* {@link attachmentRecordFields} as an upload judges it: the same fields, each bounded by
|
|
62
|
+
* {@link ATTACHMENT_FIELD_MAX}. One judge for every door that stores an attachment.
|
|
63
|
+
*/
|
|
64
|
+
export const attachmentUploadFields = attachmentRecordFields.extend({
|
|
65
|
+
entity: z.object({
|
|
66
|
+
entityType: z.string().min(1).max(ATTACHMENT_FIELD_MAX.entityType),
|
|
67
|
+
entityId: z.string().min(1).max(ATTACHMENT_FIELD_MAX.entityId),
|
|
68
|
+
}),
|
|
69
|
+
filename: z.string().min(1).max(ATTACHMENT_FIELD_MAX.filename),
|
|
70
|
+
contentType: z.string().min(1).max(ATTACHMENT_FIELD_MAX.contentType),
|
|
71
|
+
createdBy: z.string().min(1).max(ATTACHMENT_FIELD_MAX.createdBy),
|
|
72
|
+
});
|
|
39
73
|
/**
|
|
40
74
|
* The spine events attachment mutations emit (#473) — kernel-emitted, fat payload (the
|
|
41
75
|
* full `attachmentRecord`), so a consumer (a timeline projection, attachment GC) never
|
|
@@ -124,7 +158,9 @@ export const uploadLinkFilename = z
|
|
|
124
158
|
/** `ctx.attachments.mintUploadUrl`'s input. */
|
|
125
159
|
export const uploadLinkMintInput = z
|
|
126
160
|
.object({
|
|
127
|
-
|
|
161
|
+
// Bounded like an upload (#2519): a link for an entity no redemption could store is refused
|
|
162
|
+
// at the mint, to the minter, not at the redemption, to the uploader.
|
|
163
|
+
entity: attachmentUploadFields.shape.entity,
|
|
128
164
|
/** Fixes the stored name. Absent: the uploader names the file (`?filename=` or `Content-Disposition`). */
|
|
129
165
|
filename: uploadLinkFilename.optional(),
|
|
130
166
|
/** Narrows the target's `maxBytes`; a larger value is refused, not clamped. */
|
|
@@ -187,4 +223,67 @@ export const attachmentUploadLinkRevokedPayload = z.object({
|
|
|
187
223
|
entity: entityRef,
|
|
188
224
|
revokedBy: principalId,
|
|
189
225
|
});
|
|
226
|
+
// -- connector upload bounds (#2516) --------------------------------------------
|
|
227
|
+
/**
|
|
228
|
+
* How many bytes a connector upload's metadata takes on the wire: its JSON, URI-encoded, which is
|
|
229
|
+
* what the stream route's header carries. The multipart route carries the same JSON in a field and
|
|
230
|
+
* is held to the same count, taken WITHOUT the stream route's `size` member, so one filename is
|
|
231
|
+
* accepted or refused the same way on both (#2516).
|
|
232
|
+
*/
|
|
233
|
+
export function connectorAttachmentMetaBytes(metaJson) {
|
|
234
|
+
return encodeURIComponent(metaJson).length;
|
|
235
|
+
}
|
|
236
|
+
/** The one sentence every end uses to refuse metadata over {@link CONNECTOR_ATTACHMENT_META_MAX_BYTES}. */
|
|
237
|
+
export function connectorAttachmentMetaRefusal(bytes) {
|
|
238
|
+
return (`the attachment's metadata is ${bytes} bytes once encoded, over the ` +
|
|
239
|
+
`${CONNECTOR_ATTACHMENT_META_MAX_BYTES}-byte bound a connector upload carries it in — shorten the filename`);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* The most bytes one streamed connector upload may carry (#2516). Streaming took the worker's
|
|
243
|
+
* memory out of the limit, which left nothing bounding a file; this is that bound, held where the
|
|
244
|
+
* bytes arrive (the stream route) and again by the platform before it sends, so a file too large
|
|
245
|
+
* is refused with an answer before anything is read or stored. The platform reaches the route
|
|
246
|
+
* through the dispatch namespace, not a zone's edge; the value is kept under 100 MB decimal (about
|
|
247
|
+
* 95.4 MiB), the lowest plan's Workers request-body limit, so that the same file is also one a
|
|
248
|
+
* deployment reached directly by a public request could take.
|
|
249
|
+
*/
|
|
250
|
+
export const CONNECTOR_ATTACHMENT_STREAM_MAX_BYTES = 95 * 1024 * 1024;
|
|
251
|
+
/**
|
|
252
|
+
* The most bytes one BUFFERED connector upload may carry (#2538): the multipart route's file part,
|
|
253
|
+
* and the platform client's `Uint8Array` body. Lower than {@link CONNECTOR_ATTACHMENT_STREAM_MAX_BYTES}
|
|
254
|
+
* because that one is a request-size limit and this one is a memory limit: a stream is never held, but
|
|
255
|
+
* a buffered file is resident several times over at once (the raw body, the parsed form's copy, then
|
|
256
|
+
* the bytes handed on; on the platform side the caller's buffer, the form's copy, the encoded request
|
|
257
|
+
* and the copy read to bind its digest) against a 128 MB isolate. The platform side is the tighter, at
|
|
258
|
+
* about four times the file (an estimate, not a measurement), so 16 MiB (about 64 MiB resident) keeps
|
|
259
|
+
* twice that in hand; it is below the buffered upload-link cap ({@link UPLOAD_LINK_MAX_BYTES_CEILING}).
|
|
260
|
+
* Above it a caller sends a streamed upload, which is the route for a large file.
|
|
261
|
+
*/
|
|
262
|
+
export const CONNECTOR_ATTACHMENT_BUFFERED_MAX_BYTES = 16 * 1024 * 1024;
|
|
263
|
+
/**
|
|
264
|
+
* What the multipart route's body may carry beyond the file (#2538): the `meta` field (at most
|
|
265
|
+
* {@link CONNECTOR_ATTACHMENT_META_MAX_BYTES} once encoded, never more raw), the part headers and
|
|
266
|
+
* the boundaries, with room to spare. A body over the buffered bound plus this is refused unread.
|
|
267
|
+
*/
|
|
268
|
+
export const CONNECTOR_ATTACHMENT_MULTIPART_ENVELOPE_BYTES = 16 * 1024;
|
|
269
|
+
/** The one sentence every end uses to refuse a declared size over {@link CONNECTOR_ATTACHMENT_STREAM_MAX_BYTES}. */
|
|
270
|
+
export function connectorAttachmentSizeRefusal(declared) {
|
|
271
|
+
return (`the attachment declares ${declared} bytes, over the ${CONNECTOR_ATTACHMENT_STREAM_MAX_BYTES}-byte ` +
|
|
272
|
+
`bound on a streamed connector upload`);
|
|
273
|
+
}
|
|
274
|
+
/** The sentence for a buffered file over {@link CONNECTOR_ATTACHMENT_BUFFERED_MAX_BYTES}: its own bytes, once known. */
|
|
275
|
+
export function connectorAttachmentBufferedRefusal(bytes) {
|
|
276
|
+
return (`the attachment is ${bytes} bytes, over the ${CONNECTOR_ATTACHMENT_BUFFERED_MAX_BYTES}-byte bound ` +
|
|
277
|
+
`on a buffered connector upload — use the streaming upload above ${CONNECTOR_ATTACHMENT_BUFFERED_MAX_BYTES / (1024 * 1024)} MiB`);
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* The sentence for a multipart BODY refused before its file part could be told apart: a
|
|
281
|
+
* `Content-Length` over the bound plus the envelope (`bytes` is that header), or a body cut off while
|
|
282
|
+
* it was read (`bytes` omitted: nobody declared a size). Names the body, not the attachment.
|
|
283
|
+
*/
|
|
284
|
+
export function connectorAttachmentBodyRefusal(bytes) {
|
|
285
|
+
const bound = CONNECTOR_ATTACHMENT_BUFFERED_MAX_BYTES + CONNECTOR_ATTACHMENT_MULTIPART_ENVELOPE_BYTES;
|
|
286
|
+
return ((bytes === undefined ? `the request body ran past the ${bound}-byte bound` : `the request body is ${bytes} bytes, over the ${bound}-byte bound`) +
|
|
287
|
+
` on a buffered connector upload (the file plus its multipart envelope) — use the streaming upload above ${CONNECTOR_ATTACHMENT_BUFFERED_MAX_BYTES / (1024 * 1024)} MiB`);
|
|
288
|
+
}
|
|
190
289
|
//# sourceMappingURL=attachments.js.map
|
package/dist/attachments.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachments.js","sourceRoot":"","sources":["../src/attachments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"attachments.js","sourceRoot":"","sources":["../src/attachments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,mCAAmC,EAAE,MAAM,mBAAmB,CAAC;AAExE,wEAAwE;AACxE,6EAA6E;AAC7E,4EAA4E;AAC5E,0EAA0E;AAC1E,6BAA6B;AAE7B,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;AAG3D;;;;;;;;;;;;GAYG;AACH,MAAM,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