@zveltio/sdk 3.0.0-beta.77 → 3.0.0-beta.79
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/ddl/index.d.ts +3 -0
- package/dist/ddl/index.d.ts.map +1 -1
- package/dist/extension/capabilities.d.ts +70 -0
- package/dist/extension/capabilities.d.ts.map +1 -0
- package/dist/extension/capabilities.js +78 -0
- package/dist/extension/index.d.ts +104 -10
- package/dist/extension/index.d.ts.map +1 -1
- package/dist/extension/index.js +4 -0
- package/dist/offline/index.d.ts +20 -51
- package/dist/offline/index.d.ts.map +1 -1
- package/dist/offline/index.js +114 -140
- package/dist/schema-codegen.d.ts +22 -0
- package/dist/schema-codegen.d.ts.map +1 -1
- package/dist/schema-codegen.js +100 -0
- package/dist/testing/with-test-db.d.ts +1 -1
- package/dist/testing/with-test-db.d.ts.map +1 -1
- package/dist/testing/with-test-db.js +1 -1
- package/dist/tests/migration-parse.test.d.ts +2 -0
- package/dist/tests/migration-parse.test.d.ts.map +1 -0
- package/dist/tests/migration-parse.test.js +17 -0
- package/dist/tests/validate-manifest-dependencies.test.d.ts +2 -0
- package/dist/tests/validate-manifest-dependencies.test.d.ts.map +1 -0
- package/dist/tests/validate-manifest-dependencies.test.js +27 -0
- package/dist/tests/validate-manifest-forward-credentials.test.d.ts +2 -0
- package/dist/tests/validate-manifest-forward-credentials.test.d.ts.map +1 -0
- package/dist/tests/validate-manifest-forward-credentials.test.js +22 -0
- package/dist/validate/index.d.ts.map +1 -1
- package/dist/validate/index.js +51 -0
- package/dist/validate/migration-parse.d.ts +10 -5
- package/dist/validate/migration-parse.d.ts.map +1 -1
- package/dist/validate/migration-parse.js +1 -1
- package/package.json +2 -2
package/dist/validate/index.js
CHANGED
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
*/
|
|
26
26
|
import { parseMigrationSql } from './migration-parse.js';
|
|
27
27
|
export { SHARED_MESSAGE_KEYS } from './shared-message-keys.js';
|
|
28
|
+
/** Headers the engine keeps from a worker-isolated extension unless `forwardCredentials` names them. */
|
|
29
|
+
const CREDENTIAL_HEADERS = ['authorization', 'cookie', 'proxy-authorization', 'x-api-key'];
|
|
28
30
|
// ─── Helpers ───────────────────────────────────────────────────────────────
|
|
29
31
|
const SEMVER_RE = /^\d+\.\d+\.\d+(?:-[A-Za-z0-9.-]+)?$/;
|
|
30
32
|
const KNOWN_CATEGORIES = new Set([
|
|
@@ -93,6 +95,34 @@ export function validateManifest(input) {
|
|
|
93
95
|
if (typeof obj.zveltioMaxVersion === 'string' && !SEMVER_RE.test(obj.zveltioMaxVersion)) {
|
|
94
96
|
out.push(err('MANIFEST_BAD_MAX_VERSION', `zveltioMaxVersion "${obj.zveltioMaxVersion}" is not valid semver`));
|
|
95
97
|
}
|
|
98
|
+
// Required and optional extension dependencies share one shape; the broker
|
|
99
|
+
// lets an extension call services only of the extensions named in either.
|
|
100
|
+
const depNames = new Map();
|
|
101
|
+
for (const field of ['dependencies', 'optionalDependencies']) {
|
|
102
|
+
const list = obj[field];
|
|
103
|
+
if (list === undefined)
|
|
104
|
+
continue;
|
|
105
|
+
if (!Array.isArray(list)) {
|
|
106
|
+
out.push(err('MANIFEST_BAD_DEPENDENCY', `"${field}" must be an array of { name, minVersion? }`));
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
for (const d of list) {
|
|
110
|
+
const depName = d && typeof d === 'object' ? d.name : undefined;
|
|
111
|
+
const min = d && typeof d === 'object' ? d.minVersion : undefined;
|
|
112
|
+
if (typeof depName !== 'string' || depName.trim() === '') {
|
|
113
|
+
out.push(err('MANIFEST_BAD_DEPENDENCY', `"${field}" entry ${JSON.stringify(d)} has no name`));
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if (min !== undefined && (typeof min !== 'string' || !SEMVER_RE.test(min))) {
|
|
117
|
+
out.push(err('MANIFEST_BAD_DEPENDENCY', `"${field}" ${depName}: minVersion ${JSON.stringify(min)} is not semver`));
|
|
118
|
+
}
|
|
119
|
+
const seen = depNames.get(depName);
|
|
120
|
+
if (seen) {
|
|
121
|
+
out.push(err('MANIFEST_BAD_DEPENDENCY', `"${depName}" is listed in "${seen}" and "${field}"`));
|
|
122
|
+
}
|
|
123
|
+
depNames.set(depName, field);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
96
126
|
// The engine's manifest schema refuses the whole extension (422) on a bad entry.
|
|
97
127
|
if (obj.apiKeyRoutes !== undefined) {
|
|
98
128
|
const routes = Array.isArray(obj.apiKeyRoutes) ? obj.apiKeyRoutes : [obj.apiKeyRoutes];
|
|
@@ -102,6 +132,27 @@ export function validateManifest(input) {
|
|
|
102
132
|
}
|
|
103
133
|
}
|
|
104
134
|
}
|
|
135
|
+
// The host strips these from a worker's request; a public route may ask for some back.
|
|
136
|
+
if (obj.forwardCredentials !== undefined) {
|
|
137
|
+
const fwd = obj.forwardCredentials;
|
|
138
|
+
const publicRoutes = Array.isArray(obj.publicRoutes) ? obj.publicRoutes : [];
|
|
139
|
+
if (!fwd || typeof fwd !== 'object' || Array.isArray(fwd)) {
|
|
140
|
+
out.push(err('MANIFEST_BAD_FORWARD_CREDENTIALS', '"forwardCredentials" must map a route to headers'));
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
for (const [route, names] of Object.entries(fwd)) {
|
|
144
|
+
if (!publicRoutes.includes(route)) {
|
|
145
|
+
out.push(err('MANIFEST_BAD_FORWARD_CREDENTIALS', `forwardCredentials names "${route}", which is not a publicRoutes entry`));
|
|
146
|
+
}
|
|
147
|
+
const list = Array.isArray(names) ? names : [names];
|
|
148
|
+
for (const n of list) {
|
|
149
|
+
if (typeof n !== 'string' || !CREDENTIAL_HEADERS.includes(n)) {
|
|
150
|
+
out.push(err('MANIFEST_BAD_FORWARD_CREDENTIALS', `forwardCredentials "${route}": ${JSON.stringify(n)} is not one of ${CREDENTIAL_HEADERS.join(', ')}`));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
105
156
|
if (typeof obj.category === 'string' && !KNOWN_CATEGORIES.has(obj.category)) {
|
|
106
157
|
// A true warning — categories are open-ended in practice (e.g. the RO
|
|
107
158
|
// compliance set uses "compliance/ro"). Surfaced so authors notice typos
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Parse a single SQL migration file into its UP and DOWN sections.
|
|
3
3
|
*
|
|
4
|
-
* The DOWN section starts at the first line
|
|
5
|
-
* insensitive). Everything before that marker is
|
|
6
|
-
* marker line is DOWN. If the marker is absent, the
|
|
4
|
+
* The DOWN section starts at the first line that is exactly `-- DOWN` (case
|
|
5
|
+
* insensitive, surrounding spaces allowed). Everything before that marker is
|
|
6
|
+
* UP; everything after the marker line is DOWN. If the marker is absent, the
|
|
7
|
+
* whole file is UP.
|
|
7
8
|
*
|
|
8
|
-
* Mirror of `packages/engine/src/lib/extension-
|
|
9
|
+
* Mirror of `packages/engine/src/lib/extensions/extension-utils.ts:parseMigrationSql`
|
|
9
10
|
* — kept in the SDK so validators and tooling can call it without depending
|
|
10
|
-
* on engine internals.
|
|
11
|
+
* on engine internals. The two must agree on the marker: the engine was moved
|
|
12
|
+
* to the anchored `\s*$` form and this copy kept `\b`, so a comment such as
|
|
13
|
+
* `-- DOWN: manual rollback required` ended UP here and not there —
|
|
14
|
+
* `withTestDb` applied half an extension's schema while the engine applied all
|
|
15
|
+
* of it, and the validator saw a DOWN section the engine did not.
|
|
11
16
|
*/
|
|
12
17
|
export interface ParsedMigration {
|
|
13
18
|
up: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-parse.d.ts","sourceRoot":"","sources":["../../src/validate/migration-parse.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"migration-parse.d.ts","sourceRoot":"","sources":["../../src/validate/migration-parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAU9D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zveltio/sdk",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.79",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"fake-indexeddb": "^6.2.5",
|
|
70
70
|
"hono": "^4.13.8",
|
|
71
71
|
"kysely": "^0.29.6",
|
|
72
|
-
"pg": "^8.23.
|
|
72
|
+
"pg": "^8.23.1",
|
|
73
73
|
"typescript": "^5.4.0"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|