@ericminassian/platform-engine 0.2.0 → 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/dist/clients.d.ts +8 -0
- package/dist/clients.js +22 -1
- package/dist/clients.js.map +1 -1
- package/dist/compat.d.ts +21 -9
- package/dist/compat.js +27 -7
- package/dist/compat.js.map +1 -1
- package/dist/drivers/appsync.d.ts +49 -0
- package/dist/drivers/appsync.js +155 -0
- package/dist/drivers/appsync.js.map +1 -0
- package/dist/drivers/ecr.d.ts +109 -0
- package/dist/drivers/ecr.js +303 -0
- package/dist/drivers/ecr.js.map +1 -0
- package/dist/drivers/ecs.d.ts +163 -0
- package/dist/drivers/ecs.js +447 -0
- package/dist/drivers/ecs.js.map +1 -0
- package/dist/drivers/events.d.ts +10 -0
- package/dist/drivers/events.js +13 -1
- package/dist/drivers/events.js.map +1 -1
- package/dist/drivers/index.d.ts +5 -0
- package/dist/drivers/index.js +5 -0
- package/dist/drivers/index.js.map +1 -1
- package/dist/drivers/kvs.d.ts +3 -0
- package/dist/drivers/kvs.js +14 -7
- package/dist/drivers/kvs.js.map +1 -1
- package/dist/drivers/lambda.d.ts +22 -0
- package/dist/drivers/lambda.js +74 -3
- package/dist/drivers/lambda.js.map +1 -1
- package/dist/drivers/request-function.d.ts +60 -0
- package/dist/drivers/request-function.js +167 -0
- package/dist/drivers/request-function.js.map +1 -0
- package/dist/drivers/s3.d.ts +7 -0
- package/dist/drivers/s3.js +31 -0
- package/dist/drivers/s3.js.map +1 -1
- package/dist/drivers/scheduler.d.ts +24 -0
- package/dist/drivers/scheduler.js +60 -5
- package/dist/drivers/scheduler.js.map +1 -1
- package/dist/drivers/ses.d.ts +77 -0
- package/dist/drivers/ses.js +181 -0
- package/dist/drivers/ses.js.map +1 -0
- package/dist/drivers/sqs.d.ts +11 -0
- package/dist/drivers/sqs.js +67 -1
- package/dist/drivers/sqs.js.map +1 -1
- package/dist/drivers/ssm.d.ts +1 -0
- package/dist/drivers/ssm.js +23 -3
- package/dist/drivers/ssm.js.map +1 -1
- package/dist/drivers/web-function.d.ts +41 -11
- package/dist/drivers/web-function.js +62 -8
- package/dist/drivers/web-function.js.map +1 -1
- package/dist/emulator.js.map +1 -1
- package/dist/images.d.ts +104 -0
- package/dist/images.js +182 -0
- package/dist/images.js.map +1 -0
- package/dist/index.d.ts +132 -7
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/local.js +222 -7
- package/dist/local.js.map +1 -1
- package/dist/policy.d.ts +47 -4
- package/dist/policy.js +369 -15
- package/dist/policy.js.map +1 -1
- package/dist/services.d.ts +155 -0
- package/dist/services.js +464 -0
- package/dist/services.js.map +1 -0
- package/dist/stage.d.ts +44 -4
- package/dist/stage.js +681 -138
- package/dist/stage.js.map +1 -1
- package/dist/static.d.ts +1 -1
- package/dist/static.js +2 -36
- package/dist/static.js.map +1 -1
- package/dist/util.d.ts +22 -0
- package/dist/util.js +18 -2
- package/dist/util.js.map +1 -1
- package/package.json +20 -14
- package/src/clients.ts +25 -1
- package/src/compat.ts +34 -11
- package/src/drivers/appsync.ts +220 -0
- package/src/drivers/ecr.ts +457 -0
- package/src/drivers/ecs.ts +661 -0
- package/src/drivers/events.ts +29 -2
- package/src/drivers/index.ts +5 -0
- package/src/drivers/kvs.ts +21 -12
- package/src/drivers/lambda.ts +103 -2
- package/src/drivers/request-function.ts +295 -0
- package/src/drivers/s3.ts +46 -0
- package/src/drivers/scheduler.ts +88 -5
- package/src/drivers/ses.ts +267 -0
- package/src/drivers/sqs.ts +95 -0
- package/src/drivers/ssm.ts +23 -2
- package/src/drivers/web-function.ts +108 -17
- package/src/emulator.ts +3 -3
- package/src/images.ts +254 -0
- package/src/index.ts +131 -8
- package/src/local.ts +251 -7
- package/src/policy.ts +450 -26
- package/src/services.ts +663 -0
- package/src/stage.ts +839 -153
- package/src/static.ts +2 -37
- package/src/util.ts +38 -4
package/src/static.ts
CHANGED
|
@@ -1,40 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
html: 'text/html; charset=utf-8',
|
|
4
|
-
htm: 'text/html; charset=utf-8',
|
|
5
|
-
css: 'text/css; charset=utf-8',
|
|
6
|
-
js: 'text/javascript; charset=utf-8',
|
|
7
|
-
mjs: 'text/javascript; charset=utf-8',
|
|
8
|
-
cjs: 'text/javascript; charset=utf-8',
|
|
9
|
-
map: 'application/json; charset=utf-8',
|
|
10
|
-
json: 'application/json; charset=utf-8',
|
|
11
|
-
webmanifest: 'application/manifest+json',
|
|
12
|
-
txt: 'text/plain; charset=utf-8',
|
|
13
|
-
xml: 'application/xml; charset=utf-8',
|
|
14
|
-
svg: 'image/svg+xml',
|
|
15
|
-
png: 'image/png',
|
|
16
|
-
jpg: 'image/jpeg',
|
|
17
|
-
jpeg: 'image/jpeg',
|
|
18
|
-
gif: 'image/gif',
|
|
19
|
-
webp: 'image/webp',
|
|
20
|
-
avif: 'image/avif',
|
|
21
|
-
ico: 'image/x-icon',
|
|
22
|
-
woff: 'font/woff',
|
|
23
|
-
woff2: 'font/woff2',
|
|
24
|
-
ttf: 'font/ttf',
|
|
25
|
-
otf: 'font/otf',
|
|
26
|
-
wasm: 'application/wasm',
|
|
27
|
-
pdf: 'application/pdf',
|
|
28
|
-
mp4: 'video/mp4',
|
|
29
|
-
webm: 'video/webm',
|
|
30
|
-
mp3: 'audio/mpeg',
|
|
31
|
-
wav: 'audio/wav',
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export function contentTypeFor(path: string): string {
|
|
35
|
-
const ext = path.slice(path.lastIndexOf('.') + 1).toLowerCase();
|
|
36
|
-
return TYPES[ext] ?? 'application/octet-stream';
|
|
37
|
-
}
|
|
1
|
+
// Shared with store files put without a content type.
|
|
2
|
+
export { contentTypeFor } from '@ericminassian/platform-core';
|
|
38
3
|
|
|
39
4
|
export const IMMUTABLE = 'public, max-age=31536000, immutable';
|
|
40
5
|
export const REVALIDATE = 'public, max-age=0, must-revalidate';
|
package/src/util.ts
CHANGED
|
@@ -41,6 +41,10 @@ const NOT_FOUND = new Set([
|
|
|
41
41
|
'NoSuchCachePolicy',
|
|
42
42
|
'NoSuchDistribution',
|
|
43
43
|
'EntityNotFound',
|
|
44
|
+
'ServiceNotFoundException',
|
|
45
|
+
'ClusterNotFoundException',
|
|
46
|
+
'RepositoryNotFoundException',
|
|
47
|
+
'ImageNotFoundException',
|
|
44
48
|
]);
|
|
45
49
|
|
|
46
50
|
export function isNotFound(e: unknown): boolean {
|
|
@@ -105,7 +109,7 @@ export async function mapLimit<T, R>(
|
|
|
105
109
|
limit: number,
|
|
106
110
|
fn: (item: T) => Promise<R>,
|
|
107
111
|
): Promise<R[]> {
|
|
108
|
-
const out
|
|
112
|
+
const out = Array.from<R>({ length: items.length });
|
|
109
113
|
let next = 0;
|
|
110
114
|
const workers = Array.from({ length: Math.min(limit, items.length) }, async () => {
|
|
111
115
|
while (next < items.length) {
|
|
@@ -117,6 +121,36 @@ export async function mapLimit<T, R>(
|
|
|
117
121
|
return out;
|
|
118
122
|
}
|
|
119
123
|
|
|
124
|
+
export interface RawRequest {
|
|
125
|
+
method: string;
|
|
126
|
+
protocol: string;
|
|
127
|
+
hostname: string;
|
|
128
|
+
port?: number;
|
|
129
|
+
path: string;
|
|
130
|
+
query?: Record<string, string>;
|
|
131
|
+
headers: Record<string, string>;
|
|
132
|
+
body?: string;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Send a request outside the SDK's operations through a client's own HTTP
|
|
137
|
+
* handler, so it gets the same TLS setup (the emulator's CA) as the client.
|
|
138
|
+
*/
|
|
139
|
+
export async function sendRaw(
|
|
140
|
+
client: { config: { requestHandler: unknown } },
|
|
141
|
+
request: RawRequest,
|
|
142
|
+
): Promise<{ statusCode: number; body: Uint8Array }> {
|
|
143
|
+
const handler = client.config.requestHandler as {
|
|
144
|
+
handle(
|
|
145
|
+
request: RawRequest,
|
|
146
|
+
): Promise<{ response: { statusCode: number; body: AsyncIterable<Uint8Array> } }>;
|
|
147
|
+
};
|
|
148
|
+
const { response } = await handler.handle(request);
|
|
149
|
+
const chunks: Uint8Array[] = [];
|
|
150
|
+
for await (const c of response.body) chunks.push(c);
|
|
151
|
+
return { statusCode: response.statusCode, body: new Uint8Array(Buffer.concat(chunks)) };
|
|
152
|
+
}
|
|
153
|
+
|
|
120
154
|
// ------------------------------------------------------------------ tags
|
|
121
155
|
|
|
122
156
|
export function stageTags(app: string, stage: string): Record<string, string> {
|
|
@@ -159,15 +193,15 @@ export function policy(...statements: PolicyStatement[]): PolicyDocument {
|
|
|
159
193
|
/** Deep-equal for policy documents that may come back URL-encoded from IAM. */
|
|
160
194
|
export function samePolicy(a: string | PolicyDocument | undefined, b: PolicyDocument): boolean {
|
|
161
195
|
if (!a) return false;
|
|
162
|
-
const parsed = typeof a === 'string' ? JSON.parse(decodeURIComponent(a)) : a;
|
|
196
|
+
const parsed = typeof a === 'string' ? (JSON.parse(decodeURIComponent(a)) as unknown) : a;
|
|
163
197
|
return canonical(parsed) === canonical(b);
|
|
164
198
|
}
|
|
165
199
|
|
|
166
200
|
function canonical(v: unknown): string {
|
|
167
201
|
if (Array.isArray(v)) return `[${v.map(canonical).join(',')}]`;
|
|
168
202
|
if (v && typeof v === 'object') {
|
|
169
|
-
return `{${Object.keys(v
|
|
170
|
-
.
|
|
203
|
+
return `{${Object.keys(v)
|
|
204
|
+
.toSorted()
|
|
171
205
|
.map((k) => `${JSON.stringify(k)}:${canonical((v as Record<string, unknown>)[k])}`)
|
|
172
206
|
.join(',')}}`;
|
|
173
207
|
}
|