@learncard/lca-api-service 1.5.3 → 1.6.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/.env.example +10 -0
- package/CHANGELOG.md +26 -0
- package/bundle.mjs +1 -1
- package/dist/app.d.ts +4 -1
- package/dist/config/cacheEnvironment.d.ts +4 -4
- package/dist/config/environment.d.ts +145 -114
- package/dist/config/oidcEnvironment.d.ts +22 -22
- package/dist/didkit_wasm_bg.wasm +0 -0
- package/dist/helpers/bedrockGeneration.d.ts +17 -0
- package/dist/helpers/bedrockGeneration.test.d.ts +1 -0
- package/dist/helpers/bedrockSchema.d.ts +10 -0
- package/dist/helpers/imageGeneration.d.ts +42 -0
- package/dist/helpers/imageGeneration.test.d.ts +1 -0
- package/dist/index.js +2 -2
- package/dist/models/Notification.d.ts +3 -1
- package/dist/publish-metafile.json +1 -1
- package/dist/routes/ai.skill-icons.test.d.ts +1 -0
- package/dist/routes/keys.d.ts +1 -0
- package/dist/routes/notifications.d.ts +3 -1
- package/dist/types/notifications.d.ts +3 -1
- package/docs/bedrock-generation.md +119 -0
- package/docs/image-generation.md +120 -0
- package/package.json +20 -15
- package/scripts/node24-runtime.cjs +9 -0
- package/scripts/verify-node24-layer.cjs +49 -0
- package/serverless-local.yml +3 -1
- package/serverless.function-env.cjs +2 -4
- package/serverless.yml +76 -3
- package/src/config/environment.ts +14 -0
- package/src/helpers/bedrockGeneration.test.ts +222 -0
- package/src/helpers/bedrockGeneration.ts +110 -0
- package/src/helpers/bedrockSchema.ts +352 -0
- package/src/helpers/imageGeneration.test.ts +456 -0
- package/src/helpers/imageGeneration.ts +432 -0
- package/src/routes/ai.skill-icons.test.ts +92 -0
- package/src/routes/ai.test.ts +68 -91
- package/src/routes/ai.ts +31 -143
- package/src/routes/keys.ts +18 -0
- package/src/services/escrow-enclave/enclaveTrustAnchors.ts +19 -0
- package/src/services/escrow-enclave/logFailure.test.ts +8 -0
- package/src/services/escrow-enclave/logFailure.ts +17 -0
- package/src/services/escrow-enclave/remoteEnclave.tls.test.ts +10 -0
- package/test/keys-auth-share-escrow.spec.ts +103 -0
- package/test/oidc.spec.ts +41 -2
- package/tsconfig.bedrock.json +10 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import OpenAI from 'openai';
|
|
2
|
+
import { getTokenProvider } from '@aws/bedrock-token-generator';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export declare const BEDROCK_BASE_URL = "https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1";
|
|
5
|
+
export declare const GENERATION_MODELS: {
|
|
6
|
+
readonly reasoning: "us.openai.gpt-6.1-sol";
|
|
7
|
+
readonly formatting: "us.openai.gpt-6-luna";
|
|
8
|
+
};
|
|
9
|
+
type GenerationTask = keyof typeof GENERATION_MODELS;
|
|
10
|
+
export declare const createBedrockClient: (baseURL?: string, tokenFactory?: typeof getTokenProvider, fetch?: typeof globalThis.fetch) => OpenAI;
|
|
11
|
+
export declare const generateStructuredOutput: <Schema extends z.ZodType>(client: OpenAI, params: {
|
|
12
|
+
task: GenerationTask;
|
|
13
|
+
instructions: string;
|
|
14
|
+
input: string;
|
|
15
|
+
schema: Schema;
|
|
16
|
+
}) => Promise<z.output<Schema>>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare class BedrockSchemaError extends Error {
|
|
3
|
+
readonly path: string;
|
|
4
|
+
readonly reason: string;
|
|
5
|
+
readonly code = "unsupported_bedrock_schema";
|
|
6
|
+
constructor(path: string, reason: string);
|
|
7
|
+
}
|
|
8
|
+
export declare function validateBedrockJsonSchema(schema: unknown): void;
|
|
9
|
+
export declare function compileProjectedSchema(schema: z.ZodType): Record<string, unknown>;
|
|
10
|
+
export declare function parseBedrockOutput(value: unknown, schema: z.ZodType): Promise<unknown>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type OpenAI from 'openai';
|
|
2
|
+
export interface ImageGenerationConfig {
|
|
3
|
+
IMAGE_PROVIDER: 'openai' | 'bedrock';
|
|
4
|
+
BEDROCK_IMAGE_REGION: string;
|
|
5
|
+
BEDROCK_IMAGE_MODEL_ID: string;
|
|
6
|
+
IMAGE_TIMEOUT_MS: number;
|
|
7
|
+
}
|
|
8
|
+
interface ImageStorage {
|
|
9
|
+
storeURL: (url: string) => Promise<{
|
|
10
|
+
url?: string;
|
|
11
|
+
}>;
|
|
12
|
+
upload: (bytes: Buffer, options: {
|
|
13
|
+
timeout: number;
|
|
14
|
+
}, storeOptions: {
|
|
15
|
+
filename: string;
|
|
16
|
+
}) => Promise<{
|
|
17
|
+
url?: string;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
export interface ImageDiagnostics {
|
|
21
|
+
stage?: 'invoke' | 'decode' | 'storage' | 'timeout' | 'config';
|
|
22
|
+
category?: ProviderErrorCategory;
|
|
23
|
+
decodeReason?: string;
|
|
24
|
+
finishReason?: string | null;
|
|
25
|
+
errorName?: string;
|
|
26
|
+
errorCode?: string;
|
|
27
|
+
httpStatus?: number;
|
|
28
|
+
awsRequestId?: string;
|
|
29
|
+
sdkRetryable?: boolean;
|
|
30
|
+
attempts?: number;
|
|
31
|
+
}
|
|
32
|
+
type ProviderErrorCategory = 'throttled' | 'unavailable' | 'timeout' | 'filtered' | 'rejected';
|
|
33
|
+
export declare const providerErrorInfo: (error: unknown) => Partial<ImageDiagnostics>;
|
|
34
|
+
export declare const classifyProviderError: (error: unknown) => {
|
|
35
|
+
category: ProviderErrorCategory;
|
|
36
|
+
retryable: boolean;
|
|
37
|
+
};
|
|
38
|
+
export declare const decodeBedrockImage: (body: Uint8Array, diagnostics?: ImageDiagnostics) => Buffer;
|
|
39
|
+
export declare const generateStoredImage: (prompt: string, did: string, config: ImageGenerationConfig, openai: OpenAI | undefined, storage: ImageStorage) => Promise<{
|
|
40
|
+
url: string;
|
|
41
|
+
}>;
|
|
42
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/dist/index.js
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 166355147 bytes
|
|
4
|
+
sha256: 0b23e44f11e205fe9e6dd5502e0a80c343603806b4356fdeda1937f70cc49de7
|
|
@@ -56,6 +56,7 @@ export declare const MongoNotificationValidator: z.ZodObject<{
|
|
|
56
56
|
email: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
57
57
|
image: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
58
58
|
heroImage: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
59
|
+
linkedInOrganizationId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
59
60
|
websiteLink: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
60
61
|
isServiceProfile: z.ZodOptional<z.ZodOptional<z.ZodDefault<z.ZodBoolean>>>;
|
|
61
62
|
type: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
@@ -102,6 +103,7 @@ export declare const MongoNotificationValidator: z.ZodObject<{
|
|
|
102
103
|
email: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
103
104
|
image: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
104
105
|
heroImage: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
106
|
+
linkedInOrganizationId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
105
107
|
websiteLink: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
106
108
|
isServiceProfile: z.ZodOptional<z.ZodOptional<z.ZodDefault<z.ZodBoolean>>>;
|
|
107
109
|
type: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
@@ -174,9 +176,9 @@ export declare const MongoNotificationValidator: z.ZodObject<{
|
|
|
174
176
|
}, z.core.$strip>>;
|
|
175
177
|
id: z.ZodString;
|
|
176
178
|
action: z.ZodEnum<{
|
|
179
|
+
update: "update";
|
|
177
180
|
write: "write";
|
|
178
181
|
consent: "consent";
|
|
179
|
-
update: "update";
|
|
180
182
|
sync: "sync";
|
|
181
183
|
withdraw: "withdraw";
|
|
182
184
|
}>;
|