@zveltio/sdk 2.0.8 → 3.0.0-beta.1
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/build/index.d.ts +77 -0
- package/dist/build/index.d.ts.map +1 -0
- package/dist/build/index.js +157 -0
- package/dist/client/QueryBuilder.d.ts.map +1 -1
- package/dist/client/QueryBuilder.js +12 -3
- package/dist/client/RealtimeClient.d.ts.map +1 -1
- package/dist/client/RealtimeClient.js +3 -1
- package/dist/client/ZveltioClient.d.ts.map +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +16 -5
- package/dist/core.d.ts.map +1 -1
- package/dist/ddl/index.d.ts +153 -0
- package/dist/ddl/index.d.ts.map +1 -0
- package/dist/ddl/index.js +33 -0
- package/dist/extension/index.d.ts +522 -10
- package/dist/extension/index.d.ts.map +1 -1
- package/dist/extension/index.js +1 -1
- package/dist/extension/permission-gate.d.ts +37 -0
- package/dist/extension/permission-gate.d.ts.map +1 -0
- package/dist/extension/permission-gate.js +93 -0
- package/dist/generate-types.d.ts +37 -0
- package/dist/generate-types.d.ts.map +1 -0
- package/dist/generate-types.js +157 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/local-store.d.ts.map +1 -1
- package/dist/local-store.js +1 -3
- package/dist/offline/index.d.ts +105 -0
- package/dist/offline/index.d.ts.map +1 -0
- package/dist/offline/index.js +235 -0
- package/dist/publish/index.d.ts +94 -0
- package/dist/publish/index.d.ts.map +1 -0
- package/dist/publish/index.js +148 -0
- package/dist/realtime.d.ts.map +1 -1
- package/dist/realtime.js +6 -2
- package/dist/rpc/index.d.ts +68 -0
- package/dist/rpc/index.d.ts.map +1 -0
- package/dist/rpc/index.js +61 -0
- package/dist/schema-codegen.d.ts +60 -0
- package/dist/schema-codegen.d.ts.map +1 -0
- package/dist/schema-codegen.js +369 -0
- package/dist/schema-watcher.d.ts.map +1 -1
- package/dist/schema-watcher.js +1 -3
- package/dist/studio/index.d.ts +84 -0
- package/dist/studio/index.d.ts.map +1 -0
- package/dist/studio/index.js +180 -0
- package/dist/svelte.d.ts.map +1 -1
- package/dist/sync-manager.d.ts.map +1 -1
- package/dist/sync-manager.js +4 -11
- package/dist/testing/index.d.ts +121 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +283 -0
- package/dist/testing/with-test-db.d.ts +119 -0
- package/dist/testing/with-test-db.d.ts.map +1 -0
- package/dist/testing/with-test-db.js +313 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +3 -1
- package/dist/validate/index.d.ts +95 -0
- package/dist/validate/index.d.ts.map +1 -0
- package/dist/validate/index.js +201 -0
- package/dist/validate/migration-parse.d.ts +17 -0
- package/dist/validate/migration-parse.d.ts.map +1 -0
- package/dist/validate/migration-parse.js +11 -0
- package/package.json +53 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @zveltio/sdk/build
|
|
3
|
+
*
|
|
4
|
+
* Public API for authors who want to compile their extension bundle
|
|
5
|
+
* from a custom build script (not via `zveltio extension pack`).
|
|
6
|
+
*
|
|
7
|
+
* The canonical pipeline is still `zveltio extension pack` — it
|
|
8
|
+
* understands the manifest, computes the hash, and patches the
|
|
9
|
+
* integrity block. This module exposes the underlying `Bun.build`
|
|
10
|
+
* plugin so authors with non-standard build flows (monorepo
|
|
11
|
+
* orchestration, custom entrypoints, IDE integration) can produce
|
|
12
|
+
* the SAME artifact bytes.
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { createExtensionBuildConfig } from '@zveltio/sdk/build';
|
|
18
|
+
*
|
|
19
|
+
* const result = await Bun.build({
|
|
20
|
+
* ...createExtensionBuildConfig({
|
|
21
|
+
* entry: './engine/index.ts',
|
|
22
|
+
* outdir: './engine',
|
|
23
|
+
* resolveDir: process.cwd(),
|
|
24
|
+
* }),
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* After build, compute SHA-256 of `engine/index.js` and write it to
|
|
29
|
+
* `manifest.integrity.engineSha256` — the engine refuses to load any
|
|
30
|
+
* bundled extension whose on-disk bytes don't match the declared hash.
|
|
31
|
+
*/
|
|
32
|
+
import type { BunPlugin } from 'bun';
|
|
33
|
+
/**
|
|
34
|
+
* Packages that the engine ships in its compiled binary AND that
|
|
35
|
+
* Bun's bundler resolves to `.d.ts` (not `.js`) due to an exports-
|
|
36
|
+
* condition quirk. The plugin below forces them to resolve to their
|
|
37
|
+
* ESM JavaScript entrypoints so the bundle actually runs.
|
|
38
|
+
*/
|
|
39
|
+
export declare const EXTENSION_BUNDLE_CORE_DEPS: readonly ["hono", "zod", "kysely", "@hono/zod-validator"];
|
|
40
|
+
/**
|
|
41
|
+
* Bun plugin that forces the core extension deps (hono / zod / kysely
|
|
42
|
+
* / @hono/zod-validator) to resolve to their ESM `.js` entrypoints
|
|
43
|
+
* during build. Works around Bun's exports-condition matching picking
|
|
44
|
+
* `.d.ts` for hono-style packages.
|
|
45
|
+
*/
|
|
46
|
+
export declare function createExtensionBundleResolvePlugin(resolveFromDir: string): BunPlugin;
|
|
47
|
+
export interface ExtensionBuildConfigOptions {
|
|
48
|
+
/** Absolute path to the extension's `engine/index.ts`. */
|
|
49
|
+
entry: string;
|
|
50
|
+
/** Directory the build output lands in (typically `<ext>/engine`). */
|
|
51
|
+
outdir: string;
|
|
52
|
+
/** Extension root — used to walk node_modules for peer-dep resolution. */
|
|
53
|
+
resolveDir: string;
|
|
54
|
+
/** External packages to leave as bare imports. Use sparingly — Bun's
|
|
55
|
+
* compiled binary cannot resolve bare specifiers from dynamically-
|
|
56
|
+
* imported disk files. Default: []. */
|
|
57
|
+
external?: string[];
|
|
58
|
+
/** Emit a `.map` next to the bundle. Default: false. */
|
|
59
|
+
sourcemap?: boolean;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Build a `Bun.build` config object the SAME way `zveltio extension
|
|
63
|
+
* pack` does. Returns the full options object including the resolve
|
|
64
|
+
* plugin and bundle conditions — spread it into your own `Bun.build`
|
|
65
|
+
* call.
|
|
66
|
+
*/
|
|
67
|
+
export declare function createExtensionBuildConfig(opts: ExtensionBuildConfigOptions): {
|
|
68
|
+
entrypoints: string[];
|
|
69
|
+
outdir: string;
|
|
70
|
+
target: "bun";
|
|
71
|
+
format: "esm";
|
|
72
|
+
sourcemap: "linked" | "none";
|
|
73
|
+
external: string[];
|
|
74
|
+
conditions: ("default" | "import" | "bun" | "node")[];
|
|
75
|
+
plugins: BunPlugin[];
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/build/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAIrC;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,2DAK7B,CAAC;AAiFX;;;;;GAKG;AACH,wBAAgB,kCAAkC,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,CAYpF;AAED,MAAM,WAAW,2BAA2B;IAC1C,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,MAAM,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,UAAU,EAAE,MAAM,CAAC;IACnB;;4CAEwC;IACxC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,wDAAwD;IACxD,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,2BAA2B;;;;;eAMrB,QAAQ,GAAG,MAAM;;;;EAKvE"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @zveltio/sdk/build
|
|
3
|
+
*
|
|
4
|
+
* Public API for authors who want to compile their extension bundle
|
|
5
|
+
* from a custom build script (not via `zveltio extension pack`).
|
|
6
|
+
*
|
|
7
|
+
* The canonical pipeline is still `zveltio extension pack` — it
|
|
8
|
+
* understands the manifest, computes the hash, and patches the
|
|
9
|
+
* integrity block. This module exposes the underlying `Bun.build`
|
|
10
|
+
* plugin so authors with non-standard build flows (monorepo
|
|
11
|
+
* orchestration, custom entrypoints, IDE integration) can produce
|
|
12
|
+
* the SAME artifact bytes.
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { createExtensionBuildConfig } from '@zveltio/sdk/build';
|
|
18
|
+
*
|
|
19
|
+
* const result = await Bun.build({
|
|
20
|
+
* ...createExtensionBuildConfig({
|
|
21
|
+
* entry: './engine/index.ts',
|
|
22
|
+
* outdir: './engine',
|
|
23
|
+
* resolveDir: process.cwd(),
|
|
24
|
+
* }),
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* After build, compute SHA-256 of `engine/index.js` and write it to
|
|
29
|
+
* `manifest.integrity.engineSha256` — the engine refuses to load any
|
|
30
|
+
* bundled extension whose on-disk bytes don't match the declared hash.
|
|
31
|
+
*/
|
|
32
|
+
import { createRequire } from 'node:module';
|
|
33
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
34
|
+
import { dirname, join } from 'node:path';
|
|
35
|
+
const require = createRequire(import.meta.url);
|
|
36
|
+
/**
|
|
37
|
+
* Packages that the engine ships in its compiled binary AND that
|
|
38
|
+
* Bun's bundler resolves to `.d.ts` (not `.js`) due to an exports-
|
|
39
|
+
* condition quirk. The plugin below forces them to resolve to their
|
|
40
|
+
* ESM JavaScript entrypoints so the bundle actually runs.
|
|
41
|
+
*/
|
|
42
|
+
export const EXTENSION_BUNDLE_CORE_DEPS = [
|
|
43
|
+
'hono',
|
|
44
|
+
'zod',
|
|
45
|
+
'kysely',
|
|
46
|
+
'@hono/zod-validator',
|
|
47
|
+
];
|
|
48
|
+
const BUNDLE_CONDITIONS = ['import', 'bun', 'node', 'default'];
|
|
49
|
+
function escapeRegExp(s) {
|
|
50
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
51
|
+
}
|
|
52
|
+
function pickExportTarget(target) {
|
|
53
|
+
if (typeof target === 'string')
|
|
54
|
+
return target;
|
|
55
|
+
if (target && typeof target === 'object') {
|
|
56
|
+
const o = target;
|
|
57
|
+
if (typeof o.import === 'string')
|
|
58
|
+
return o.import;
|
|
59
|
+
if (typeof o.default === 'string')
|
|
60
|
+
return o.default;
|
|
61
|
+
if (o.import)
|
|
62
|
+
return pickExportTarget(o.import);
|
|
63
|
+
}
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
function resolveSearchPaths(resolveFromDir) {
|
|
67
|
+
const paths = [resolveFromDir];
|
|
68
|
+
let cur = resolveFromDir;
|
|
69
|
+
for (let i = 0; i < 6; i++) {
|
|
70
|
+
cur = dirname(cur);
|
|
71
|
+
paths.push(cur);
|
|
72
|
+
if (existsSync(join(cur, 'node_modules')))
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
return [...new Set(paths)];
|
|
76
|
+
}
|
|
77
|
+
function resolvePackageRoot(pkg, searchPaths) {
|
|
78
|
+
let candidate;
|
|
79
|
+
try {
|
|
80
|
+
candidate = dirname(require.resolve(pkg, { paths: searchPaths }));
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
throw new Error(`Cannot find package "${pkg}" from ${searchPaths[0]}. ` +
|
|
84
|
+
`Run \`bun install\` in the extension directory or monorepo root.`);
|
|
85
|
+
}
|
|
86
|
+
for (;;) {
|
|
87
|
+
const pkgJsonPath = join(candidate, 'package.json');
|
|
88
|
+
if (existsSync(pkgJsonPath)) {
|
|
89
|
+
const manifest = JSON.parse(readFileSync(pkgJsonPath, 'utf8'));
|
|
90
|
+
if (manifest.name === pkg)
|
|
91
|
+
return candidate;
|
|
92
|
+
}
|
|
93
|
+
const parent = dirname(candidate);
|
|
94
|
+
if (parent === candidate)
|
|
95
|
+
break;
|
|
96
|
+
candidate = parent;
|
|
97
|
+
}
|
|
98
|
+
throw new Error(`Cannot find package root for "${pkg}"`);
|
|
99
|
+
}
|
|
100
|
+
function resolvePackageEsmEntry(pkg, resolveFromDir) {
|
|
101
|
+
const searchPaths = resolveSearchPaths(resolveFromDir);
|
|
102
|
+
const root = resolvePackageRoot(pkg, searchPaths);
|
|
103
|
+
const pkgJsonPath = join(root, 'package.json');
|
|
104
|
+
const manifest = JSON.parse(readFileSync(pkgJsonPath, 'utf8'));
|
|
105
|
+
const dot = manifest.exports?.['.'];
|
|
106
|
+
let rel = pickExportTarget(dot);
|
|
107
|
+
rel ??= manifest.module ?? manifest.main;
|
|
108
|
+
if (!rel || typeof rel !== 'string') {
|
|
109
|
+
throw new Error(`Cannot determine ESM entry for package "${pkg}"`);
|
|
110
|
+
}
|
|
111
|
+
const abs = join(root, rel.replace(/^\.\//, ''));
|
|
112
|
+
if (!existsSync(abs)) {
|
|
113
|
+
throw new Error(`ESM entry missing for "${pkg}": ${abs}`);
|
|
114
|
+
}
|
|
115
|
+
if (abs.endsWith('.d.ts')) {
|
|
116
|
+
throw new Error(`Package "${pkg}" resolved to a declaration file (${abs}). ` +
|
|
117
|
+
`Expected exports.import or module field to point at JavaScript.`);
|
|
118
|
+
}
|
|
119
|
+
return abs;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Bun plugin that forces the core extension deps (hono / zod / kysely
|
|
123
|
+
* / @hono/zod-validator) to resolve to their ESM `.js` entrypoints
|
|
124
|
+
* during build. Works around Bun's exports-condition matching picking
|
|
125
|
+
* `.d.ts` for hono-style packages.
|
|
126
|
+
*/
|
|
127
|
+
export function createExtensionBundleResolvePlugin(resolveFromDir) {
|
|
128
|
+
return {
|
|
129
|
+
name: 'zveltio-extension-bundle-resolve',
|
|
130
|
+
setup(build) {
|
|
131
|
+
for (const pkg of EXTENSION_BUNDLE_CORE_DEPS) {
|
|
132
|
+
const filter = new RegExp(`^${escapeRegExp(pkg)}$`);
|
|
133
|
+
build.onResolve({ filter }, () => ({
|
|
134
|
+
path: resolvePackageEsmEntry(pkg, resolveFromDir),
|
|
135
|
+
}));
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Build a `Bun.build` config object the SAME way `zveltio extension
|
|
142
|
+
* pack` does. Returns the full options object including the resolve
|
|
143
|
+
* plugin and bundle conditions — spread it into your own `Bun.build`
|
|
144
|
+
* call.
|
|
145
|
+
*/
|
|
146
|
+
export function createExtensionBuildConfig(opts) {
|
|
147
|
+
return {
|
|
148
|
+
entrypoints: [opts.entry],
|
|
149
|
+
outdir: opts.outdir,
|
|
150
|
+
target: 'bun',
|
|
151
|
+
format: 'esm',
|
|
152
|
+
sourcemap: (opts.sourcemap ? 'linked' : 'none'),
|
|
153
|
+
external: opts.external ?? [],
|
|
154
|
+
conditions: [...BUNDLE_CONDITIONS],
|
|
155
|
+
plugins: [createExtensionBundleResolvePlugin(opts.resolveDir)],
|
|
156
|
+
};
|
|
157
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryBuilder.d.ts","sourceRoot":"","sources":["../../src/client/QueryBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEpF,qBAAa,YAAY;IACvB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,QAAQ,CAAoB;gBAExB,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa;IAMrD,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IACtC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAWlD,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"QueryBuilder.d.ts","sourceRoot":"","sources":["../../src/client/QueryBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEpF,qBAAa,YAAY;IACvB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,QAAQ,CAAoB;gBAExB,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa;IAMrD,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IACtC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAWlD,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAIrB,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAMtB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,GAAE,KAAK,GAAG,MAAc,GAAG,IAAI;IAO1D,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAMjB,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,eAAe,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAiCxE,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,cAAc,CAAC,CAAC,EAAE,CAAC;CAY9D"}
|
|
@@ -17,8 +17,14 @@ export class QueryBuilder {
|
|
|
17
17
|
return this;
|
|
18
18
|
}
|
|
19
19
|
// Pagination
|
|
20
|
-
page(n) {
|
|
21
|
-
|
|
20
|
+
page(n) {
|
|
21
|
+
this._options.page = n;
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
limit(n) {
|
|
25
|
+
this._options.limit = n;
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
22
28
|
// Sorting
|
|
23
29
|
sortBy(field, order = 'asc') {
|
|
24
30
|
this._options.sort = field;
|
|
@@ -26,7 +32,10 @@ export class QueryBuilder {
|
|
|
26
32
|
return this;
|
|
27
33
|
}
|
|
28
34
|
// Search
|
|
29
|
-
search(q) {
|
|
35
|
+
search(q) {
|
|
36
|
+
this._options.search = q;
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
30
39
|
// Execute
|
|
31
40
|
async query(overrideOptions) {
|
|
32
41
|
const opts = { ...this._options, ...overrideOptions };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RealtimeClient.d.ts","sourceRoot":"","sources":["../../src/client/RealtimeClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,KAAK,aAAa,GAAG,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;AACxD,KAAK,cAAc,GAAG,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW,GAAG,cAAc,KAAK,IAAI,CAAC;AAEpF,qBAAa,cAAc;IACzB,OAAO,CAAC,EAAE,CAA0B;IACpC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,aAAa,CAAyC;IAC9D,OAAO,CAAC,eAAe,CAA6B;IACpD,OAAO,CAAC,cAAc,CAAQ;IAC9B,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,eAAe,CAAQ;gBAEnB,OAAO,EAAE,MAAM;IAI3B,OAAO,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"RealtimeClient.d.ts","sourceRoot":"","sources":["../../src/client/RealtimeClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,KAAK,aAAa,GAAG,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;AACxD,KAAK,cAAc,GAAG,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW,GAAG,cAAc,KAAK,IAAI,CAAC;AAEpF,qBAAa,cAAc;IACzB,OAAO,CAAC,EAAE,CAA0B;IACpC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,aAAa,CAAyC;IAC9D,OAAO,CAAC,eAAe,CAA6B;IACpD,OAAO,CAAC,cAAc,CAAQ;IAC9B,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,eAAe,CAAQ;gBAEnB,OAAO,EAAE,MAAM;IAI3B,OAAO,IAAI,IAAI;IA8Cf,UAAU,IAAI,IAAI;IAQlB,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,GAAG,EAAE,QAAQ,EAAE,aAAa,GAAG,MAAM,IAAI;IAwBvF,cAAc,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,IAAI;IAKpD,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,YAAY;CAGrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZveltioClient.d.ts","sourceRoot":"","sources":["../../src/client/ZveltioClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"ZveltioClient.d.ts","sourceRoot":"","sources":["../../src/client/ZveltioClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,aAAa,EAGb,cAAc,EACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,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ACZ;AAED,wBAAgB,mBAAmB,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1F,MAAM,EAAE,mBAAmB,GAC1B,aAAa,CAAC,MAAM,CAAC,CAEvB"}
|
package/dist/client.js
CHANGED
|
@@ -80,15 +80,26 @@ export class ZveltioClient {
|
|
|
80
80
|
}
|
|
81
81
|
return res.json();
|
|
82
82
|
}
|
|
83
|
-
get(path) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
get(path) {
|
|
84
|
+
return this.request('GET', path);
|
|
85
|
+
}
|
|
86
|
+
post(path, body) {
|
|
87
|
+
return this.request('POST', path, body);
|
|
88
|
+
}
|
|
89
|
+
patch(path, body) {
|
|
90
|
+
return this.request('PATCH', path, body);
|
|
91
|
+
}
|
|
92
|
+
delete(path) {
|
|
93
|
+
return this.request('DELETE', path);
|
|
94
|
+
}
|
|
87
95
|
async upload(path, formData) {
|
|
88
96
|
const headers = { ...this.headers };
|
|
89
97
|
delete headers['Content-Type'];
|
|
90
98
|
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
91
|
-
method: 'POST',
|
|
99
|
+
method: 'POST',
|
|
100
|
+
headers,
|
|
101
|
+
credentials: 'include',
|
|
102
|
+
body: formData,
|
|
92
103
|
});
|
|
93
104
|
if (!res.ok)
|
|
94
105
|
throw new Error(`Upload ${path} failed: ${res.status}`);
|
package/dist/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAIrD,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CA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AAC,EAAE,MAAM,GACd,OAAO,CAAC,WAAW,CAAC,CAGtB;AAED,wBAAsB,SAAS,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAG9F;AAED,wBAAsB,UAAU,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAErF;AAID,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,eAAe,EACzB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAG,CAAA;CAAE,KAAK,IAAI,GACrD,MAAM,IAAI,CAEZ"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DDL types + DDLManager interface for extension authors (S4-08).
|
|
3
|
+
*
|
|
4
|
+
* Replaces the previous tsconfig path-alias `@zveltio/engine-ddl` that
|
|
5
|
+
* pointed extensions directly at `engine/src/lib/ddl-manager.ts`. That
|
|
6
|
+
* alias broke the SDK ↔ engine boundary: extensions had a hard
|
|
7
|
+
* structural dependency on engine internals, and `bun extension publish`
|
|
8
|
+
* couldn't bundle them cleanly.
|
|
9
|
+
*
|
|
10
|
+
* What lives here:
|
|
11
|
+
* - Pure TYPE definitions for collections, fields, and relations.
|
|
12
|
+
* - The `DDLManager` INTERFACE — the subset of the engine's
|
|
13
|
+
* DDLManager class that extensions actually call via `ctx.DDLManager`.
|
|
14
|
+
*
|
|
15
|
+
* What does NOT live here (intentionally):
|
|
16
|
+
* - The runtime DDLManager class itself. It depends on
|
|
17
|
+
* `fieldTypeRegistry`, lock-timeout transactions, and other
|
|
18
|
+
* engine-internal plumbing. The engine continues to own the
|
|
19
|
+
* implementation and hands an instance into every extension via
|
|
20
|
+
* `ctx.DDLManager`.
|
|
21
|
+
*
|
|
22
|
+
* Usage in an extension:
|
|
23
|
+
* import type { DDLManager, CollectionDefinition } from '@zveltio/sdk/ddl';
|
|
24
|
+
*
|
|
25
|
+
* export const ext: ZveltioExtension = {
|
|
26
|
+
* async register(_app, ctx) {
|
|
27
|
+
* const ddl: DDLManager = ctx.DDLManager;
|
|
28
|
+
* const col = await ddl.getCollection(ctx.db, 'contacts');
|
|
29
|
+
* // ...
|
|
30
|
+
* },
|
|
31
|
+
* };
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* Definition of one field in a collection. Mirrors the Zod schema in the
|
|
35
|
+
* engine's ddl-manager.ts but as a plain TypeScript interface so the SDK
|
|
36
|
+
* has no Zod dependency.
|
|
37
|
+
*/
|
|
38
|
+
export interface FieldDefinition {
|
|
39
|
+
/** Lowercase, snake_case identifier. PostgreSQL column name. */
|
|
40
|
+
name: string;
|
|
41
|
+
/**
|
|
42
|
+
* Field type id. Built-ins: `text`, `number`, `boolean`, `date`,
|
|
43
|
+
* `datetime`, `json`, `uuid`, `email`, `url`, `richtext`, `m2o`,
|
|
44
|
+
* `m2m`, `o2m`, `reference`, `select`, `multi-select`, `relation`,
|
|
45
|
+
* `geolocation`, etc. Extensions can register custom types via
|
|
46
|
+
* `ctx.fieldTypeRegistry`.
|
|
47
|
+
*/
|
|
48
|
+
type: string;
|
|
49
|
+
required?: boolean;
|
|
50
|
+
unique?: boolean;
|
|
51
|
+
indexed?: boolean;
|
|
52
|
+
/** Default value for new rows. Type depends on `type`. */
|
|
53
|
+
defaultValue?: unknown;
|
|
54
|
+
/** Type-specific options. Shape depends on `type` — see field-type docs. */
|
|
55
|
+
options?: Record<string, string | number | boolean | null | unknown[]>;
|
|
56
|
+
label?: string;
|
|
57
|
+
description?: string;
|
|
58
|
+
/** Store the field's value encrypted at rest (AES-256-GCM). */
|
|
59
|
+
encrypted?: boolean;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A collection definition — the unit DDL methods operate on. `name`
|
|
63
|
+
* becomes the suffix of the underlying PG table (`zvd_<name>`).
|
|
64
|
+
*/
|
|
65
|
+
export interface CollectionDefinition {
|
|
66
|
+
/** Lowercase, snake_case. Max 63 chars (PG identifier limit). */
|
|
67
|
+
name: string;
|
|
68
|
+
displayName?: string;
|
|
69
|
+
icon?: string;
|
|
70
|
+
/** Which zone the collection's records belong to. */
|
|
71
|
+
routeGroup?: 'public' | 'partners' | 'private' | 'admin';
|
|
72
|
+
/** When true, RLS policies + row ownership are enforced for this table. */
|
|
73
|
+
isPermissioned?: boolean;
|
|
74
|
+
sort?: number;
|
|
75
|
+
/** At least one field; required by createCollection. */
|
|
76
|
+
fields: FieldDefinition[];
|
|
77
|
+
description?: string;
|
|
78
|
+
singularName?: string;
|
|
79
|
+
aiSearchEnabled?: boolean;
|
|
80
|
+
aiSearchField?: string | null;
|
|
81
|
+
/** True for collections owned by an extension's migrations
|
|
82
|
+
* (i.e. ones Studio should not let users alter). */
|
|
83
|
+
isManaged?: boolean;
|
|
84
|
+
isSystem?: boolean;
|
|
85
|
+
schemaLocked?: boolean;
|
|
86
|
+
}
|
|
87
|
+
/** A row from `zv_collections` / `getCollection` / `getCollections`. The
|
|
88
|
+
* exact shape is engine-internal; this interface only fixes the fields
|
|
89
|
+
* extensions are documented to read. Treat unknown keys as best-effort. */
|
|
90
|
+
export interface CollectionRecord {
|
|
91
|
+
id?: string;
|
|
92
|
+
name: string;
|
|
93
|
+
displayName?: string;
|
|
94
|
+
fields?: FieldDefinition[];
|
|
95
|
+
routeGroup?: string;
|
|
96
|
+
isPermissioned?: boolean;
|
|
97
|
+
isManaged?: boolean;
|
|
98
|
+
isSystem?: boolean;
|
|
99
|
+
schemaLocked?: boolean;
|
|
100
|
+
[k: string]: unknown;
|
|
101
|
+
}
|
|
102
|
+
import type { Kysely } from 'kysely';
|
|
103
|
+
export type DDLManagerDb = Kysely<any>;
|
|
104
|
+
/**
|
|
105
|
+
* Subset of `DDLManager` available to extensions via `ctx.DDLManager`.
|
|
106
|
+
*
|
|
107
|
+
* The engine ships the implementation as a class with `static` methods.
|
|
108
|
+
* From an extension's perspective they're indistinguishable from instance
|
|
109
|
+
* methods, hence this interface uses the call shape (no `this` requirement).
|
|
110
|
+
*
|
|
111
|
+
* Stability note: this is part of the v1.0 extension SDK contract. New
|
|
112
|
+
* methods may be added; existing signatures will not change in a breaking
|
|
113
|
+
* way without a major version bump.
|
|
114
|
+
*/
|
|
115
|
+
export interface DDLManager {
|
|
116
|
+
/** Translate a logical collection name to its PG table (`zvd_<name>`). */
|
|
117
|
+
getTableName(collectionName: string): string;
|
|
118
|
+
/** Invalidate the in-engine collection cache. Pass a name to scope the
|
|
119
|
+
* invalidation, or omit to flush everything. */
|
|
120
|
+
invalidateCache(name?: string): void;
|
|
121
|
+
/** True when `zvd_<collectionName>` exists in the public schema. */
|
|
122
|
+
tableExists(db: DDLManagerDb, collectionName: string): Promise<boolean>;
|
|
123
|
+
/** Create a new collection + its underlying table + indices. Throws if
|
|
124
|
+
* the collection already exists. */
|
|
125
|
+
createCollection(db: DDLManagerDb, definition: CollectionDefinition): Promise<void>;
|
|
126
|
+
/** Drop a collection. Refuses by default if any table references it via
|
|
127
|
+
* FK — set `force: true` to cascade. */
|
|
128
|
+
dropCollection(db: DDLManagerDb, name: string, opts?: {
|
|
129
|
+
force?: boolean;
|
|
130
|
+
}): Promise<void>;
|
|
131
|
+
/** Add a single field to an existing collection. */
|
|
132
|
+
addField(db: DDLManagerDb, collectionName: string, field: FieldDefinition): Promise<void>;
|
|
133
|
+
/** Remove a single field. Fails if any zvd_* row still has a non-null
|
|
134
|
+
* value unless the underlying field type allows DROP COLUMN. */
|
|
135
|
+
removeField(db: DDLManagerDb, collectionName: string, fieldName: string): Promise<void>;
|
|
136
|
+
/** List every collection registered in `zv_collections`. */
|
|
137
|
+
getCollections(db: DDLManagerDb): Promise<CollectionRecord[]>;
|
|
138
|
+
/** Read a single collection by name. Returns `null` when missing. */
|
|
139
|
+
getCollection(db: DDLManagerDb, name: string): Promise<CollectionRecord | null>;
|
|
140
|
+
/** Update display-only metadata (label, description, icon, sort, etc.). */
|
|
141
|
+
updateCollectionMetadata(db: DDLManagerDb, name: string, metadata: Partial<CollectionDefinition>): Promise<void>;
|
|
142
|
+
/** Introspect the live PG table and return its field configs. Useful for
|
|
143
|
+
* extensions that auto-discover schema changes. */
|
|
144
|
+
introspectTable(db: DDLManagerDb, collectionName: string): Promise<FieldDefinition[]>;
|
|
145
|
+
/** Re-read PG and write the result back to `zv_collections.fields`. Returns
|
|
146
|
+
* the number of changes detected. */
|
|
147
|
+
syncFieldsFromDB(db: DDLManagerDb, collectionName: string): Promise<number>;
|
|
148
|
+
/** Render the SQL that `createCollection` would emit, without running it. */
|
|
149
|
+
previewCollection(definition: CollectionDefinition): Promise<{
|
|
150
|
+
sql: string[];
|
|
151
|
+
}>;
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ddl/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAIH;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;OAMG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0DAA0D;IAC1D,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,OAAO,EAAE,CAAC,CAAC;IACvE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+DAA+D;IAC/D,SAAS,CAAC,EAA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AAC,CAAC;IAEjB;wDACoD;IACpD,eAAe,CAAC,EAAE,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAEtF;0CACsC;IACtC,gBAAgB,CAAC,EAAE,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE5E,6EAA6E;IAC7E,iBAAiB,CAAC,UAAU,EAAE,oBAAoB,GAAG,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;CACjF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DDL types + DDLManager interface for extension authors (S4-08).
|
|
3
|
+
*
|
|
4
|
+
* Replaces the previous tsconfig path-alias `@zveltio/engine-ddl` that
|
|
5
|
+
* pointed extensions directly at `engine/src/lib/ddl-manager.ts`. That
|
|
6
|
+
* alias broke the SDK ↔ engine boundary: extensions had a hard
|
|
7
|
+
* structural dependency on engine internals, and `bun extension publish`
|
|
8
|
+
* couldn't bundle them cleanly.
|
|
9
|
+
*
|
|
10
|
+
* What lives here:
|
|
11
|
+
* - Pure TYPE definitions for collections, fields, and relations.
|
|
12
|
+
* - The `DDLManager` INTERFACE — the subset of the engine's
|
|
13
|
+
* DDLManager class that extensions actually call via `ctx.DDLManager`.
|
|
14
|
+
*
|
|
15
|
+
* What does NOT live here (intentionally):
|
|
16
|
+
* - The runtime DDLManager class itself. It depends on
|
|
17
|
+
* `fieldTypeRegistry`, lock-timeout transactions, and other
|
|
18
|
+
* engine-internal plumbing. The engine continues to own the
|
|
19
|
+
* implementation and hands an instance into every extension via
|
|
20
|
+
* `ctx.DDLManager`.
|
|
21
|
+
*
|
|
22
|
+
* Usage in an extension:
|
|
23
|
+
* import type { DDLManager, CollectionDefinition } from '@zveltio/sdk/ddl';
|
|
24
|
+
*
|
|
25
|
+
* export const ext: ZveltioExtension = {
|
|
26
|
+
* async register(_app, ctx) {
|
|
27
|
+
* const ddl: DDLManager = ctx.DDLManager;
|
|
28
|
+
* const col = await ddl.getCollection(ctx.db, 'contacts');
|
|
29
|
+
* // ...
|
|
30
|
+
* },
|
|
31
|
+
* };
|
|
32
|
+
*/
|
|
33
|
+
export {};
|