@strands-agents/sdk 0.2.2 → 0.4.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/README.md +43 -0
- package/dist/src/__fixtures__/mock-hook-provider.d.ts +3 -7
- package/dist/src/__fixtures__/mock-hook-provider.d.ts.map +1 -1
- package/dist/src/__fixtures__/mock-hook-provider.js +3 -9
- package/dist/src/__fixtures__/mock-hook-provider.js.map +1 -1
- package/dist/src/__fixtures__/mock-message-model.d.ts +8 -2
- package/dist/src/__fixtures__/mock-message-model.d.ts.map +1 -1
- package/dist/src/__fixtures__/mock-message-model.js +1 -0
- package/dist/src/__fixtures__/mock-message-model.js.map +1 -1
- package/dist/src/__fixtures__/mock-storage-provider.d.ts +37 -0
- package/dist/src/__fixtures__/mock-storage-provider.d.ts.map +1 -0
- package/dist/src/__fixtures__/mock-storage-provider.js +105 -0
- package/dist/src/__fixtures__/mock-storage-provider.js.map +1 -0
- package/dist/src/__fixtures__/slim-types.d.ts +50 -0
- package/dist/src/__fixtures__/slim-types.d.ts.map +1 -0
- package/dist/src/__fixtures__/slim-types.js +6 -0
- package/dist/src/__fixtures__/slim-types.js.map +1 -0
- package/dist/src/__fixtures__/tool-helpers.d.ts +8 -3
- package/dist/src/__fixtures__/tool-helpers.d.ts.map +1 -1
- package/dist/src/__fixtures__/tool-helpers.js +1 -1
- package/dist/src/__fixtures__/tool-helpers.js.map +1 -1
- package/dist/src/agent/__tests__/agent.hook.test.js +18 -18
- package/dist/src/agent/__tests__/agent.hook.test.js.map +1 -1
- package/dist/src/agent/__tests__/agent.test.js +124 -8
- package/dist/src/agent/__tests__/agent.test.js.map +1 -1
- package/dist/src/agent/__tests__/printer.test.js +5 -9
- package/dist/src/agent/__tests__/printer.test.js.map +1 -1
- package/dist/src/agent/__tests__/snapshot.test.d.ts +2 -0
- package/dist/src/agent/__tests__/snapshot.test.d.ts.map +1 -0
- package/dist/src/agent/__tests__/snapshot.test.js +249 -0
- package/dist/src/agent/__tests__/snapshot.test.js.map +1 -0
- package/dist/src/agent/__tests__/state.test.js +19 -0
- package/dist/src/agent/__tests__/state.test.js.map +1 -1
- package/dist/src/agent/agent.d.ts +19 -4
- package/dist/src/agent/agent.d.ts.map +1 -1
- package/dist/src/agent/agent.js +104 -34
- package/dist/src/agent/agent.js.map +1 -1
- package/dist/src/agent/printer.d.ts +4 -0
- package/dist/src/agent/printer.d.ts.map +1 -1
- package/dist/src/agent/printer.js +18 -6
- package/dist/src/agent/printer.js.map +1 -1
- package/dist/src/agent/snapshot.d.ts +132 -0
- package/dist/src/agent/snapshot.d.ts.map +1 -0
- package/dist/src/agent/snapshot.js +151 -0
- package/dist/src/agent/snapshot.js.map +1 -0
- package/dist/src/agent/state.d.ts +14 -1
- package/dist/src/agent/state.d.ts.map +1 -1
- package/dist/src/agent/state.js +21 -0
- package/dist/src/agent/state.js.map +1 -1
- package/dist/src/errors.d.ts +15 -0
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +18 -0
- package/dist/src/errors.js.map +1 -1
- package/dist/src/hooks/__tests__/events.test.js +102 -21
- package/dist/src/hooks/__tests__/events.test.js.map +1 -1
- package/dist/src/hooks/events.d.ts +156 -22
- package/dist/src/hooks/events.d.ts.map +1 -1
- package/dist/src/hooks/events.js +158 -18
- package/dist/src/hooks/events.js.map +1 -1
- package/dist/src/hooks/index.d.ts +12 -4
- package/dist/src/hooks/index.d.ts.map +1 -1
- package/dist/src/hooks/index.js +11 -3
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/registry.d.ts +5 -5
- package/dist/src/hooks/registry.d.ts.map +1 -1
- package/dist/src/hooks/registry.js.map +1 -1
- package/dist/src/hooks/types.d.ts +5 -5
- package/dist/src/hooks/types.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/models/__tests__/anthropic.test.js +31 -42
- package/dist/src/models/__tests__/anthropic.test.js.map +1 -1
- package/dist/src/models/__tests__/bedrock.test.js +70 -107
- package/dist/src/models/__tests__/bedrock.test.js.map +1 -1
- package/dist/src/models/__tests__/gemini.test.js +438 -141
- package/dist/src/models/__tests__/gemini.test.js.map +1 -1
- package/dist/src/models/__tests__/model.test.js +14 -13
- package/dist/src/models/__tests__/model.test.js.map +1 -1
- package/dist/src/models/__tests__/openai.test.js +73 -83
- package/dist/src/models/__tests__/openai.test.js.map +1 -1
- package/dist/src/models/gemini/adapters.d.ts +2 -1
- package/dist/src/models/gemini/adapters.d.ts.map +1 -1
- package/dist/src/models/gemini/adapters.js +97 -10
- package/dist/src/models/gemini/adapters.js.map +1 -1
- package/dist/src/models/gemini/model.d.ts.map +1 -1
- package/dist/src/models/gemini/model.js +37 -1
- package/dist/src/models/gemini/model.js.map +1 -1
- package/dist/src/models/gemini/types.d.ts +9 -1
- package/dist/src/models/gemini/types.d.ts.map +1 -1
- package/dist/src/models/model.d.ts.map +1 -1
- package/dist/src/models/model.js +4 -0
- package/dist/src/models/model.js.map +1 -1
- package/dist/src/models/streaming.d.ts +13 -0
- package/dist/src/models/streaming.d.ts.map +1 -1
- package/dist/src/models/streaming.js +17 -0
- package/dist/src/models/streaming.js.map +1 -1
- package/dist/src/multiagent/__tests__/nodes.test.d.ts +2 -0
- package/dist/src/multiagent/__tests__/nodes.test.d.ts.map +1 -0
- package/dist/src/multiagent/__tests__/nodes.test.js +98 -0
- package/dist/src/multiagent/__tests__/nodes.test.js.map +1 -0
- package/dist/src/multiagent/events.d.ts +24 -0
- package/dist/src/multiagent/events.d.ts.map +1 -0
- package/dist/src/multiagent/events.js +19 -0
- package/dist/src/multiagent/events.js.map +1 -0
- package/dist/src/multiagent/index.d.ts +11 -0
- package/dist/src/multiagent/index.d.ts.map +1 -0
- package/dist/src/multiagent/index.js +7 -0
- package/dist/src/multiagent/index.js.map +1 -0
- package/dist/src/multiagent/nodes.d.ts +75 -0
- package/dist/src/multiagent/nodes.d.ts.map +1 -0
- package/dist/src/multiagent/nodes.js +101 -0
- package/dist/src/multiagent/nodes.js.map +1 -0
- package/dist/src/multiagent/state.d.ts +55 -0
- package/dist/src/multiagent/state.d.ts.map +1 -0
- package/dist/src/multiagent/state.js +43 -0
- package/dist/src/multiagent/state.js.map +1 -0
- package/dist/src/multiagent/types.d.ts +5 -0
- package/dist/src/multiagent/types.d.ts.map +1 -0
- package/dist/src/multiagent/types.js +2 -0
- package/dist/src/multiagent/types.js.map +1 -0
- package/dist/src/registry/tool-registry.d.ts +2 -1
- package/dist/src/registry/tool-registry.d.ts.map +1 -1
- package/dist/src/registry/tool-registry.js +4 -2
- package/dist/src/registry/tool-registry.js.map +1 -1
- package/dist/src/session/__tests__/file-storage.test.node.d.ts +2 -0
- package/dist/src/session/__tests__/file-storage.test.node.d.ts.map +1 -0
- package/dist/src/session/__tests__/file-storage.test.node.js +218 -0
- package/dist/src/session/__tests__/file-storage.test.node.js.map +1 -0
- package/dist/src/session/__tests__/s3-storage.test.node.d.ts +2 -0
- package/dist/src/session/__tests__/s3-storage.test.node.d.ts.map +1 -0
- package/dist/src/session/__tests__/s3-storage.test.node.js +375 -0
- package/dist/src/session/__tests__/s3-storage.test.node.js.map +1 -0
- package/dist/src/session/__tests__/validation.test.d.ts +2 -0
- package/dist/src/session/__tests__/validation.test.d.ts.map +1 -0
- package/dist/src/session/__tests__/validation.test.js +20 -0
- package/dist/src/session/__tests__/validation.test.js.map +1 -0
- package/dist/src/session/file-storage.d.ts +79 -0
- package/dist/src/session/file-storage.d.ts.map +1 -0
- package/dist/src/session/file-storage.js +144 -0
- package/dist/src/session/file-storage.js.map +1 -0
- package/dist/src/session/index.d.ts +19 -0
- package/dist/src/session/index.d.ts.map +1 -0
- package/dist/src/session/index.js +18 -0
- package/dist/src/session/index.js.map +1 -0
- package/dist/src/session/s3-storage.d.ts +93 -0
- package/dist/src/session/s3-storage.d.ts.map +1 -0
- package/dist/src/session/s3-storage.js +150 -0
- package/dist/src/session/s3-storage.js.map +1 -0
- package/dist/src/session/storage.d.ts +91 -0
- package/dist/src/session/storage.d.ts.map +1 -0
- package/dist/src/session/storage.js +2 -0
- package/dist/src/session/storage.js.map +1 -0
- package/dist/src/session/types.d.ts +49 -0
- package/dist/src/session/types.d.ts.map +1 -0
- package/dist/src/session/types.js +2 -0
- package/dist/src/session/types.js.map +1 -0
- package/dist/src/session/validation.d.ts +10 -0
- package/dist/src/session/validation.d.ts.map +1 -0
- package/dist/src/session/validation.js +16 -0
- package/dist/src/session/validation.js.map +1 -0
- package/dist/src/structured-output/__tests__/context.test.d.ts +2 -0
- package/dist/src/structured-output/__tests__/context.test.d.ts.map +1 -0
- package/dist/src/structured-output/__tests__/context.test.js +201 -0
- package/dist/src/structured-output/__tests__/context.test.js.map +1 -0
- package/dist/src/structured-output/__tests__/exceptions.test.d.ts +2 -0
- package/dist/src/structured-output/__tests__/exceptions.test.d.ts.map +1 -0
- package/dist/src/structured-output/__tests__/exceptions.test.js +103 -0
- package/dist/src/structured-output/__tests__/exceptions.test.js.map +1 -0
- package/dist/src/structured-output/__tests__/tool.test.d.ts +2 -0
- package/dist/src/structured-output/__tests__/tool.test.d.ts.map +1 -0
- package/dist/src/structured-output/__tests__/tool.test.js +256 -0
- package/dist/src/structured-output/__tests__/tool.test.js.map +1 -0
- package/dist/src/structured-output/__tests__/utils.test.d.ts +2 -0
- package/dist/src/structured-output/__tests__/utils.test.d.ts.map +1 -0
- package/dist/src/structured-output/__tests__/utils.test.js +183 -0
- package/dist/src/structured-output/__tests__/utils.test.js.map +1 -0
- package/dist/src/structured-output/context.d.ts +91 -0
- package/dist/src/structured-output/context.d.ts.map +1 -0
- package/dist/src/structured-output/context.js +112 -0
- package/dist/src/structured-output/context.js.map +1 -0
- package/dist/src/structured-output/exceptions.d.ts +18 -0
- package/dist/src/structured-output/exceptions.d.ts.map +1 -0
- package/dist/src/structured-output/exceptions.js +28 -0
- package/dist/src/structured-output/exceptions.js.map +1 -0
- package/dist/src/structured-output/tool.d.ts +33 -0
- package/dist/src/structured-output/tool.d.ts.map +1 -0
- package/dist/src/structured-output/tool.js +73 -0
- package/dist/src/structured-output/tool.js.map +1 -0
- package/dist/src/structured-output/utils.d.ts +23 -0
- package/dist/src/structured-output/utils.d.ts.map +1 -0
- package/dist/src/structured-output/utils.js +104 -0
- package/dist/src/structured-output/utils.js.map +1 -0
- package/dist/src/tools/zod-tool.d.ts.map +1 -1
- package/dist/src/tools/zod-tool.js +2 -5
- package/dist/src/tools/zod-tool.js.map +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/src/types/__tests__/media.test.js +216 -1
- package/dist/src/types/__tests__/media.test.js.map +1 -1
- package/dist/src/types/__tests__/messages.test.js +193 -4
- package/dist/src/types/__tests__/messages.test.js.map +1 -1
- package/dist/src/types/agent.d.ts +13 -7
- package/dist/src/types/agent.d.ts.map +1 -1
- package/dist/src/types/agent.js +8 -1
- package/dist/src/types/agent.js.map +1 -1
- package/dist/src/types/json.d.ts +61 -0
- package/dist/src/types/json.d.ts.map +1 -1
- package/dist/src/types/json.js +24 -0
- package/dist/src/types/json.js.map +1 -1
- package/dist/src/types/media.d.ts +84 -4
- package/dist/src/types/media.d.ts.map +1 -1
- package/dist/src/types/media.js +194 -0
- package/dist/src/types/media.js.map +1 -1
- package/dist/src/types/messages.d.ts +158 -9
- package/dist/src/types/messages.d.ts.map +1 -1
- package/dist/src/types/messages.js +242 -7
- package/dist/src/types/messages.js.map +1 -1
- package/dist/src/types/serializable.d.ts +31 -0
- package/dist/src/types/serializable.d.ts.map +1 -0
- package/dist/src/types/serializable.js +19 -0
- package/dist/src/types/serializable.js.map +1 -0
- package/dist/src/utils/zod.d.ts +11 -0
- package/dist/src/utils/zod.d.ts.map +1 -0
- package/dist/src/utils/zod.js +14 -0
- package/dist/src/utils/zod.js.map +1 -0
- package/dist/src/vended-tools/bash/__tests__/bash.test.node.d.ts +2 -0
- package/dist/src/vended-tools/bash/__tests__/bash.test.node.d.ts.map +1 -0
- package/dist/src/vended-tools/bash/__tests__/{bash.test.js → bash.test.node.js} +3 -4
- package/dist/src/vended-tools/bash/__tests__/bash.test.node.js.map +1 -0
- package/dist/src/vended-tools/file_editor/__tests__/file-editor.test.node.d.ts +2 -0
- package/dist/src/vended-tools/file_editor/__tests__/file-editor.test.node.d.ts.map +1 -0
- package/dist/src/vended-tools/file_editor/__tests__/{file-editor.test.js → file-editor.test.node.js} +1 -1
- package/dist/src/vended-tools/file_editor/__tests__/file-editor.test.node.js.map +1 -0
- package/package.json +7 -2
- package/dist/src/vended-tools/bash/__tests__/bash.test.d.ts +0 -2
- package/dist/src/vended-tools/bash/__tests__/bash.test.d.ts.map +0 -1
- package/dist/src/vended-tools/bash/__tests__/bash.test.js.map +0 -1
- package/dist/src/vended-tools/file_editor/__tests__/file-editor.test.d.ts +0 -2
- package/dist/src/vended-tools/file_editor/__tests__/file-editor.test.d.ts.map +0 -1
- package/dist/src/vended-tools/file_editor/__tests__/file-editor.test.js.map +0 -1
package/dist/src/types/agent.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ToolStreamEvent } from '../tools/tool.js';
|
|
2
1
|
/**
|
|
3
2
|
* Result returned by the agent loop.
|
|
4
3
|
*/
|
|
@@ -12,9 +11,17 @@ export class AgentResult {
|
|
|
12
11
|
* The last message added to the messages array.
|
|
13
12
|
*/
|
|
14
13
|
lastMessage;
|
|
14
|
+
/**
|
|
15
|
+
* The validated structured output from the LLM, if a schema was provided.
|
|
16
|
+
* Type represents any validated Zod schema output.
|
|
17
|
+
*/
|
|
18
|
+
structuredOutput;
|
|
15
19
|
constructor(data) {
|
|
16
20
|
this.stopReason = data.stopReason;
|
|
17
21
|
this.lastMessage = data.lastMessage;
|
|
22
|
+
if (data.structuredOutput !== undefined) {
|
|
23
|
+
this.structuredOutput = data.structuredOutput;
|
|
24
|
+
}
|
|
18
25
|
}
|
|
19
26
|
/**
|
|
20
27
|
* Extracts and concatenates all text content from the last message.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../../src/types/agent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../../src/types/agent.ts"],"names":[],"mappings":"AAqCA;;GAEG;AACH,MAAM,OAAO,WAAW;IACb,IAAI,GAAG,aAAsB,CAAA;IAEtC;;OAEG;IACM,UAAU,CAAY;IAE/B;;OAEG;IACM,WAAW,CAAS;IAE7B;;;OAGG;IACM,gBAAgB,CAAsB;IAE/C,YAAY,IAA8F;QACxG,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAA;QACjC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAA;QACnC,IAAI,IAAI,CAAC,gBAAgB,KAAK,SAAS,EAAE,CAAC;YACxC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAA;QAC/C,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACI,QAAQ;QACb,MAAM,SAAS,GAAa,EAAE,CAAA;QAE9B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YAC7C,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;gBACnB,KAAK,WAAW;oBACd,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;oBAC1B,MAAK;gBACP,KAAK,gBAAgB;oBACnB,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;wBACf,uCAAuC;wBACvC,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;wBACvD,SAAS,CAAC,IAAI,CAAC,qBAAqB,YAAY,EAAE,CAAC,CAAA;oBACrD,CAAC;oBACD,MAAK;gBACP;oBACE,OAAO,CAAC,KAAK,CAAC,gCAAgC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;oBAC3D,MAAK;YACT,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC7B,CAAC;CACF"}
|
package/dist/src/types/json.d.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import type { JSONSchema7 } from 'json-schema';
|
|
2
|
+
/**
|
|
3
|
+
* Interface for objects that can be serialized to JSON via `toJSON()`.
|
|
4
|
+
*
|
|
5
|
+
* @typeParam T - The type returned by `toJSON()`.
|
|
6
|
+
*/
|
|
7
|
+
export interface JSONSerializable<T = unknown> {
|
|
8
|
+
toJSON(): T;
|
|
9
|
+
}
|
|
2
10
|
/**
|
|
3
11
|
* Represents any valid JSON value.
|
|
4
12
|
* This type ensures type safety for JSON-serializable data.
|
|
@@ -52,4 +60,57 @@ export declare function deepCopy(value: unknown): JSONValue;
|
|
|
52
60
|
* @throws JsonValidationError if value contains functions, symbols, or undefined values
|
|
53
61
|
*/
|
|
54
62
|
export declare function deepCopyWithValidation(value: unknown, contextPath?: string): JSONValue;
|
|
63
|
+
/**
|
|
64
|
+
* Removes undefined values from an object.
|
|
65
|
+
* Useful for JSON serialization to avoid including undefined fields in output.
|
|
66
|
+
*
|
|
67
|
+
* @param obj - Object with potentially undefined values
|
|
68
|
+
* @returns New object with undefined values removed
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const data = { name: 'test', value: undefined, count: 0 }
|
|
73
|
+
* const clean = omitUndefined(data)
|
|
74
|
+
* // Result: { name: 'test', count: 0 }
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare function omitUndefined<T extends object>(obj: T): {
|
|
78
|
+
[K in keyof T]: Exclude<T[K], undefined>;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Recursively transforms a type by converting all Uint8Array properties to strings.
|
|
82
|
+
* Used for JSON serialization where binary data is encoded as base64 strings.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* interface Data {
|
|
87
|
+
* name: string
|
|
88
|
+
* bytes: Uint8Array
|
|
89
|
+
* nested: { content: Uint8Array }
|
|
90
|
+
* }
|
|
91
|
+
*
|
|
92
|
+
* type SerializedData = Serialized<Data>
|
|
93
|
+
* // Result: { name: string; bytes: string; nested: { content: string } }
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export type Serialized<T> = T extends Uint8Array ? string : T extends (infer U)[] ? Serialized<U>[] : T extends object ? {
|
|
97
|
+
[K in keyof T]: Serialized<T[K]>;
|
|
98
|
+
} : T;
|
|
99
|
+
/**
|
|
100
|
+
* Represents data that may contain either Uint8Array (runtime) or string (serialized) for binary fields.
|
|
101
|
+
* Used for deserialization where input may come from JSON (strings) or direct construction (Uint8Array).
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* interface Data {
|
|
106
|
+
* bytes: Uint8Array
|
|
107
|
+
* }
|
|
108
|
+
*
|
|
109
|
+
* type InputData = MaybeSerializedInput<Data>
|
|
110
|
+
* // Result: { bytes: Uint8Array | string }
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
export type MaybeSerializedInput<T> = T extends Uint8Array ? Uint8Array | string : T extends (infer U)[] ? MaybeSerializedInput<U>[] : T extends object ? {
|
|
114
|
+
[K in keyof T]: MaybeSerializedInput<T[K]>;
|
|
115
|
+
} : T;
|
|
55
116
|
//# sourceMappingURL=json.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../src/types/json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../src/types/json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C;;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AC,CAAC,CAAC,EAAE,GACzB,CAAC,SAAS,MAAM,GACd;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAC9C,CAAC,CAAA"}
|
package/dist/src/types/json.js
CHANGED
|
@@ -69,4 +69,28 @@ export function deepCopyWithValidation(value, contextPath = 'value') {
|
|
|
69
69
|
throw new Error(`Unable to serialize value: ${errorMessage}`);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Removes undefined values from an object.
|
|
74
|
+
* Useful for JSON serialization to avoid including undefined fields in output.
|
|
75
|
+
*
|
|
76
|
+
* @param obj - Object with potentially undefined values
|
|
77
|
+
* @returns New object with undefined values removed
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* const data = { name: 'test', value: undefined, count: 0 }
|
|
82
|
+
* const clean = omitUndefined(data)
|
|
83
|
+
* // Result: { name: 'test', count: 0 }
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export function omitUndefined(obj) {
|
|
87
|
+
const result = {};
|
|
88
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
89
|
+
if (value !== undefined) {
|
|
90
|
+
;
|
|
91
|
+
result[key] = value;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
72
96
|
//# sourceMappingURL=json.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../../src/types/json.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../../src/types/json.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAqClD;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,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AC,MAAkC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;QACnD,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This module provides types for handling images, videos, and documents
|
|
5
5
|
* with support for multiple sources (bytes, S3, URLs, files).
|
|
6
6
|
*/
|
|
7
|
+
import type { Serialized, MaybeSerializedInput, JSONSerializable } from './json.js';
|
|
7
8
|
import { TextBlock, type TextBlockData } from './messages.js';
|
|
8
9
|
export type MediaFormats = DocumentFormat | ImageFormat | VideoFormat;
|
|
9
10
|
/**
|
|
@@ -17,6 +18,13 @@ export declare function getMimeType(format: string): string | undefined;
|
|
|
17
18
|
* Cross-platform base64 encoding function that works in both browser and Node.js environments.
|
|
18
19
|
*/
|
|
19
20
|
export declare function encodeBase64(input: string | Uint8Array): string;
|
|
21
|
+
/**
|
|
22
|
+
* Cross-platform base64 decoding function that works in both browser and Node.js environments.
|
|
23
|
+
*
|
|
24
|
+
* @param input - Base64 encoded string to decode
|
|
25
|
+
* @returns Decoded bytes as Uint8Array
|
|
26
|
+
*/
|
|
27
|
+
export declare function decodeBase64(input: string): Uint8Array;
|
|
20
28
|
/**
|
|
21
29
|
* Data for an S3 location.
|
|
22
30
|
* Used by Bedrock for referencing media and documents stored in S3.
|
|
@@ -35,10 +43,22 @@ export interface S3LocationData {
|
|
|
35
43
|
/**
|
|
36
44
|
* S3 location for Bedrock media and document sources.
|
|
37
45
|
*/
|
|
38
|
-
export declare class S3Location implements S3LocationData {
|
|
46
|
+
export declare class S3Location implements S3LocationData, JSONSerializable<S3LocationData> {
|
|
39
47
|
readonly uri: string;
|
|
40
48
|
readonly bucketOwner?: string;
|
|
41
49
|
constructor(data: S3LocationData);
|
|
50
|
+
/**
|
|
51
|
+
* Serializes the S3Location to a JSON-compatible S3LocationData object.
|
|
52
|
+
* Called automatically by JSON.stringify().
|
|
53
|
+
*/
|
|
54
|
+
toJSON(): S3LocationData;
|
|
55
|
+
/**
|
|
56
|
+
* Creates an S3Location instance from S3LocationData.
|
|
57
|
+
*
|
|
58
|
+
* @param data - S3LocationData to deserialize
|
|
59
|
+
* @returns S3Location instance
|
|
60
|
+
*/
|
|
61
|
+
static fromJSON(data: S3LocationData): S3Location;
|
|
42
62
|
}
|
|
43
63
|
/**
|
|
44
64
|
* Image format type.
|
|
@@ -84,7 +104,9 @@ export interface ImageBlockData {
|
|
|
84
104
|
/**
|
|
85
105
|
* Image content block.
|
|
86
106
|
*/
|
|
87
|
-
export declare class ImageBlock implements ImageBlockData {
|
|
107
|
+
export declare class ImageBlock implements ImageBlockData, JSONSerializable<{
|
|
108
|
+
image: Serialized<ImageBlockData>;
|
|
109
|
+
}> {
|
|
88
110
|
/**
|
|
89
111
|
* Discriminator for image content.
|
|
90
112
|
*/
|
|
@@ -99,6 +121,24 @@ export declare class ImageBlock implements ImageBlockData {
|
|
|
99
121
|
readonly source: ImageSource;
|
|
100
122
|
constructor(data: ImageBlockData);
|
|
101
123
|
private _convertSource;
|
|
124
|
+
/**
|
|
125
|
+
* Serializes the ImageBlock to a JSON-compatible ContentBlockData object.
|
|
126
|
+
* Called automatically by JSON.stringify().
|
|
127
|
+
* Uint8Array bytes are encoded as base64 string.
|
|
128
|
+
*/
|
|
129
|
+
toJSON(): {
|
|
130
|
+
image: Serialized<ImageBlockData>;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Creates an ImageBlock instance from its wrapped data format.
|
|
134
|
+
* Base64-encoded bytes are decoded back to Uint8Array.
|
|
135
|
+
*
|
|
136
|
+
* @param data - Wrapped ImageBlockData to deserialize (accepts both string and Uint8Array for bytes)
|
|
137
|
+
* @returns ImageBlock instance
|
|
138
|
+
*/
|
|
139
|
+
static fromJSON(data: {
|
|
140
|
+
image: MaybeSerializedInput<ImageBlockData>;
|
|
141
|
+
}): ImageBlock;
|
|
102
142
|
}
|
|
103
143
|
/**
|
|
104
144
|
* Video format type.
|
|
@@ -138,7 +178,9 @@ export interface VideoBlockData {
|
|
|
138
178
|
/**
|
|
139
179
|
* Video content block.
|
|
140
180
|
*/
|
|
141
|
-
export declare class VideoBlock implements VideoBlockData {
|
|
181
|
+
export declare class VideoBlock implements VideoBlockData, JSONSerializable<{
|
|
182
|
+
video: Serialized<VideoBlockData>;
|
|
183
|
+
}> {
|
|
142
184
|
/**
|
|
143
185
|
* Discriminator for video content.
|
|
144
186
|
*/
|
|
@@ -153,6 +195,24 @@ export declare class VideoBlock implements VideoBlockData {
|
|
|
153
195
|
readonly source: VideoSource;
|
|
154
196
|
constructor(data: VideoBlockData);
|
|
155
197
|
private _convertSource;
|
|
198
|
+
/**
|
|
199
|
+
* Serializes the VideoBlock to a JSON-compatible ContentBlockData object.
|
|
200
|
+
* Called automatically by JSON.stringify().
|
|
201
|
+
* Uint8Array bytes are encoded as base64 string.
|
|
202
|
+
*/
|
|
203
|
+
toJSON(): {
|
|
204
|
+
video: Serialized<VideoBlockData>;
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* Creates a VideoBlock instance from its wrapped data format.
|
|
208
|
+
* Base64-encoded bytes are decoded back to Uint8Array.
|
|
209
|
+
*
|
|
210
|
+
* @param data - Wrapped VideoBlockData to deserialize (accepts both string and Uint8Array for bytes)
|
|
211
|
+
* @returns VideoBlock instance
|
|
212
|
+
*/
|
|
213
|
+
static fromJSON(data: {
|
|
214
|
+
video: MaybeSerializedInput<VideoBlockData>;
|
|
215
|
+
}): VideoBlock;
|
|
156
216
|
}
|
|
157
217
|
/**
|
|
158
218
|
* Document format type.
|
|
@@ -223,7 +283,9 @@ export interface DocumentBlockData {
|
|
|
223
283
|
/**
|
|
224
284
|
* Document content block.
|
|
225
285
|
*/
|
|
226
|
-
export declare class DocumentBlock implements DocumentBlockData {
|
|
286
|
+
export declare class DocumentBlock implements DocumentBlockData, JSONSerializable<{
|
|
287
|
+
document: Serialized<DocumentBlockData>;
|
|
288
|
+
}> {
|
|
227
289
|
/**
|
|
228
290
|
* Discriminator for document content.
|
|
229
291
|
*/
|
|
@@ -252,5 +314,23 @@ export declare class DocumentBlock implements DocumentBlockData {
|
|
|
252
314
|
readonly context?: string;
|
|
253
315
|
constructor(data: DocumentBlockData);
|
|
254
316
|
private _convertSource;
|
|
317
|
+
/**
|
|
318
|
+
* Serializes the DocumentBlock to a JSON-compatible ContentBlockData object.
|
|
319
|
+
* Called automatically by JSON.stringify().
|
|
320
|
+
* Uint8Array bytes are encoded as base64 string.
|
|
321
|
+
*/
|
|
322
|
+
toJSON(): {
|
|
323
|
+
document: Serialized<DocumentBlockData>;
|
|
324
|
+
};
|
|
325
|
+
/**
|
|
326
|
+
* Creates a DocumentBlock instance from its wrapped data format.
|
|
327
|
+
* Base64-encoded bytes are decoded back to Uint8Array.
|
|
328
|
+
*
|
|
329
|
+
* @param data - Wrapped DocumentBlockData to deserialize (accepts both string and Uint8Array for bytes)
|
|
330
|
+
* @returns DocumentBlock instance
|
|
331
|
+
*/
|
|
332
|
+
static fromJSON(data: {
|
|
333
|
+
document: MaybeSerializedInput<DocumentBlockData>;
|
|
334
|
+
}): DocumentBlock;
|
|
255
335
|
}
|
|
256
336
|
//# sourceMappingURL=media.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../../src/types/media.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAA;AAE7D,MAAM,MAAM,YAAY,GAAG,cAAc,GAAG,WAAW,GAAG,WAAW,CAAA;AAqCrE;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE9D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CA2B/D;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,GAAG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AE,MAAM,CAAA;IAErB;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAA;IAE/B;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAA;IAE/B;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAA;IAEzC;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;gBAEb,IAAI,EAAE,iBAAiB;IAYnC,OAAO,CAAC,cAAc;IA4BtB;;;;OAIG;IACH,MAAM,IAAI;QAAE,QAAQ,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAA;KAAE;IAsBrD;;;;;;OAMG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE;QAAE,QAAQ,EAAE,oBAAoB,CAAC,iBAAiB,CAAC,CAAA;KAAE,GAAG,aAAa;CA0B5F"}
|
package/dist/src/types/media.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This module provides types for handling images, videos, and documents
|
|
5
5
|
* with support for multiple sources (bytes, S3, URLs, files).
|
|
6
6
|
*/
|
|
7
|
+
import { omitUndefined } from './json.js';
|
|
7
8
|
import { TextBlock } from './messages.js';
|
|
8
9
|
/**
|
|
9
10
|
* MIME type mappings for supported media formats.
|
|
@@ -72,6 +73,25 @@ export function encodeBase64(input) {
|
|
|
72
73
|
}
|
|
73
74
|
return globalThis.Buffer.from(input, 'binary').toString('base64');
|
|
74
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Cross-platform base64 decoding function that works in both browser and Node.js environments.
|
|
78
|
+
*
|
|
79
|
+
* @param input - Base64 encoded string to decode
|
|
80
|
+
* @returns Decoded bytes as Uint8Array
|
|
81
|
+
*/
|
|
82
|
+
export function decodeBase64(input) {
|
|
83
|
+
// Node.js: Fast path using Buffer
|
|
84
|
+
if (typeof globalThis.Buffer === 'function') {
|
|
85
|
+
return new Uint8Array(globalThis.Buffer.from(input, 'base64'));
|
|
86
|
+
}
|
|
87
|
+
// Browser: Use atob to decode base64 to binary string, then convert to bytes
|
|
88
|
+
const binary = globalThis.atob(input);
|
|
89
|
+
const bytes = new Uint8Array(binary.length);
|
|
90
|
+
for (let i = 0; i < binary.length; i++) {
|
|
91
|
+
bytes[i] = binary.charCodeAt(i);
|
|
92
|
+
}
|
|
93
|
+
return bytes;
|
|
94
|
+
}
|
|
75
95
|
/**
|
|
76
96
|
* S3 location for Bedrock media and document sources.
|
|
77
97
|
*/
|
|
@@ -84,6 +104,25 @@ export class S3Location {
|
|
|
84
104
|
this.bucketOwner = data.bucketOwner;
|
|
85
105
|
}
|
|
86
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Serializes the S3Location to a JSON-compatible S3LocationData object.
|
|
109
|
+
* Called automatically by JSON.stringify().
|
|
110
|
+
*/
|
|
111
|
+
toJSON() {
|
|
112
|
+
return omitUndefined({
|
|
113
|
+
uri: this.uri,
|
|
114
|
+
bucketOwner: this.bucketOwner,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Creates an S3Location instance from S3LocationData.
|
|
119
|
+
*
|
|
120
|
+
* @param data - S3LocationData to deserialize
|
|
121
|
+
* @returns S3Location instance
|
|
122
|
+
*/
|
|
123
|
+
static fromJSON(data) {
|
|
124
|
+
return new S3Location(data);
|
|
125
|
+
}
|
|
87
126
|
}
|
|
88
127
|
/**
|
|
89
128
|
* Image content block.
|
|
@@ -126,6 +165,54 @@ export class ImageBlock {
|
|
|
126
165
|
}
|
|
127
166
|
throw new Error('Invalid image source');
|
|
128
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Serializes the ImageBlock to a JSON-compatible ContentBlockData object.
|
|
170
|
+
* Called automatically by JSON.stringify().
|
|
171
|
+
* Uint8Array bytes are encoded as base64 string.
|
|
172
|
+
*/
|
|
173
|
+
toJSON() {
|
|
174
|
+
let source;
|
|
175
|
+
if (this.source.type === 'imageSourceBytes') {
|
|
176
|
+
source = { bytes: encodeBase64(this.source.bytes) };
|
|
177
|
+
}
|
|
178
|
+
else if (this.source.type === 'imageSourceUrl') {
|
|
179
|
+
source = { url: this.source.url };
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
source = { s3Location: this.source.s3Location.toJSON() };
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
image: {
|
|
186
|
+
format: this.format,
|
|
187
|
+
source,
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Creates an ImageBlock instance from its wrapped data format.
|
|
193
|
+
* Base64-encoded bytes are decoded back to Uint8Array.
|
|
194
|
+
*
|
|
195
|
+
* @param data - Wrapped ImageBlockData to deserialize (accepts both string and Uint8Array for bytes)
|
|
196
|
+
* @returns ImageBlock instance
|
|
197
|
+
*/
|
|
198
|
+
static fromJSON(data) {
|
|
199
|
+
const image = data.image;
|
|
200
|
+
let source;
|
|
201
|
+
if ('bytes' in image.source) {
|
|
202
|
+
const bytes = image.source.bytes;
|
|
203
|
+
source = { bytes: typeof bytes === 'string' ? decodeBase64(bytes) : bytes };
|
|
204
|
+
}
|
|
205
|
+
else if ('url' in image.source) {
|
|
206
|
+
source = { url: image.source.url };
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
source = { s3Location: image.source.s3Location };
|
|
210
|
+
}
|
|
211
|
+
return new ImageBlock({
|
|
212
|
+
format: image.format,
|
|
213
|
+
source,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
129
216
|
}
|
|
130
217
|
/**
|
|
131
218
|
* Video content block.
|
|
@@ -159,6 +246,48 @@ export class VideoBlock {
|
|
|
159
246
|
}
|
|
160
247
|
throw new Error('Invalid video source');
|
|
161
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* Serializes the VideoBlock to a JSON-compatible ContentBlockData object.
|
|
251
|
+
* Called automatically by JSON.stringify().
|
|
252
|
+
* Uint8Array bytes are encoded as base64 string.
|
|
253
|
+
*/
|
|
254
|
+
toJSON() {
|
|
255
|
+
let source;
|
|
256
|
+
if (this.source.type === 'videoSourceBytes') {
|
|
257
|
+
source = { bytes: encodeBase64(this.source.bytes) };
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
source = { s3Location: this.source.s3Location.toJSON() };
|
|
261
|
+
}
|
|
262
|
+
return {
|
|
263
|
+
video: {
|
|
264
|
+
format: this.format,
|
|
265
|
+
source,
|
|
266
|
+
},
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Creates a VideoBlock instance from its wrapped data format.
|
|
271
|
+
* Base64-encoded bytes are decoded back to Uint8Array.
|
|
272
|
+
*
|
|
273
|
+
* @param data - Wrapped VideoBlockData to deserialize (accepts both string and Uint8Array for bytes)
|
|
274
|
+
* @returns VideoBlock instance
|
|
275
|
+
*/
|
|
276
|
+
static fromJSON(data) {
|
|
277
|
+
const video = data.video;
|
|
278
|
+
let source;
|
|
279
|
+
if ('bytes' in video.source) {
|
|
280
|
+
const bytes = video.source.bytes;
|
|
281
|
+
source = { bytes: typeof bytes === 'string' ? decodeBase64(bytes) : bytes };
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
source = { s3Location: video.source.s3Location };
|
|
285
|
+
}
|
|
286
|
+
return new VideoBlock({
|
|
287
|
+
format: video.format,
|
|
288
|
+
source,
|
|
289
|
+
});
|
|
290
|
+
}
|
|
162
291
|
}
|
|
163
292
|
/**
|
|
164
293
|
* Document content block.
|
|
@@ -226,5 +355,70 @@ export class DocumentBlock {
|
|
|
226
355
|
}
|
|
227
356
|
throw new Error('Invalid document source');
|
|
228
357
|
}
|
|
358
|
+
/**
|
|
359
|
+
* Serializes the DocumentBlock to a JSON-compatible ContentBlockData object.
|
|
360
|
+
* Called automatically by JSON.stringify().
|
|
361
|
+
* Uint8Array bytes are encoded as base64 string.
|
|
362
|
+
*/
|
|
363
|
+
toJSON() {
|
|
364
|
+
let source;
|
|
365
|
+
if (this.source.type === 'documentSourceBytes') {
|
|
366
|
+
source = { bytes: encodeBase64(this.source.bytes) };
|
|
367
|
+
}
|
|
368
|
+
else if (this.source.type === 'documentSourceText') {
|
|
369
|
+
source = { text: this.source.text };
|
|
370
|
+
}
|
|
371
|
+
else if (this.source.type === 'documentSourceContentBlock') {
|
|
372
|
+
source = { content: this.source.content.map((block) => block.toJSON()) };
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
source = { s3Location: this.source.s3Location.toJSON() };
|
|
376
|
+
}
|
|
377
|
+
return {
|
|
378
|
+
document: omitUndefined({
|
|
379
|
+
name: this.name,
|
|
380
|
+
format: this.format,
|
|
381
|
+
source,
|
|
382
|
+
citations: this.citations,
|
|
383
|
+
context: this.context,
|
|
384
|
+
}),
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Creates a DocumentBlock instance from its wrapped data format.
|
|
389
|
+
* Base64-encoded bytes are decoded back to Uint8Array.
|
|
390
|
+
*
|
|
391
|
+
* @param data - Wrapped DocumentBlockData to deserialize (accepts both string and Uint8Array for bytes)
|
|
392
|
+
* @returns DocumentBlock instance
|
|
393
|
+
*/
|
|
394
|
+
static fromJSON(data) {
|
|
395
|
+
const doc = data.document;
|
|
396
|
+
let source;
|
|
397
|
+
if ('bytes' in doc.source) {
|
|
398
|
+
const bytes = doc.source.bytes;
|
|
399
|
+
source = { bytes: typeof bytes === 'string' ? decodeBase64(bytes) : bytes };
|
|
400
|
+
}
|
|
401
|
+
else if ('text' in doc.source) {
|
|
402
|
+
source = { text: doc.source.text };
|
|
403
|
+
}
|
|
404
|
+
else if ('content' in doc.source) {
|
|
405
|
+
source = { content: doc.source.content };
|
|
406
|
+
}
|
|
407
|
+
else {
|
|
408
|
+
source = { s3Location: doc.source.s3Location };
|
|
409
|
+
}
|
|
410
|
+
const result = {
|
|
411
|
+
name: doc.name,
|
|
412
|
+
format: doc.format,
|
|
413
|
+
source,
|
|
414
|
+
};
|
|
415
|
+
if (doc.citations !== undefined) {
|
|
416
|
+
result.citations = doc.citations;
|
|
417
|
+
}
|
|
418
|
+
if (doc.context !== undefined) {
|
|
419
|
+
result.context = doc.context;
|
|
420
|
+
}
|
|
421
|
+
return new DocumentBlock(result);
|
|
422
|
+
}
|
|
229
423
|
}
|
|
230
424
|
//# sourceMappingURL=media.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media.js","sourceRoot":"","sources":["../../../src/types/media.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"media.js","sourceRoot":"","sources":["../../../src/types/media.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,SAAS,EAAsB,MAAM,eAAe,CAAA;AAI7D;;;GAGG;AACH,MAAM,UAAU,GAAiC;IAC/C,SAAS;IACT,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,YAAY;IACjB,IAAI,EAAE,YAAY;IAClB,GAAG,EAAE,WAAW;IAChB,IAAI,EAAE,YAAY;IAClB,SAAS;IACT,GAAG,EAAE,kBAAkB;IACvB,GAAG,EAAE,iBAAiB;IACtB,GAAG,EAAE,WAAW;IAChB,IAAI,EAAE,YAAY;IAClB,GAAG,EAAE,aAAa;IAClB,IAAI,EAAE,YAAY;IAClB,GAAG,EAAE,YAAY;IACjB,GAAG,EAAE,gBAAgB;IACrB,KAAK,EAAE,YAAY;IACnB,YAAY;IACZ,GAAG,EAAE,iBAAiB;IACtB,GAAG,EAAE,UAAU;IACf,GAAG,EAAE,oBAAoB;IACzB,IAAI,EAAE,yEAAyE;IAC/E,GAAG,EAAE,0BAA0B;IAC/B,IAAI,EAAE,mEAAmE;IACzE,IAAI,EAAE,WAAW;IACjB,GAAG,EAAE,YAAY;IACjB,EAAE,EAAE,eAAe;IACnB,IAAI,EAAE,kBAAkB;IACxB,GAAG,EAAE,iBAAiB;CACvB,C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