@vxil/cli 0.1.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/LICENSE +21 -0
- package/README.md +31 -0
- package/dist/_vxil-feature-configs-hooks.d.ts +167 -0
- package/dist/_vxil-feature-configs.d.ts +587 -0
- package/dist/config.d.ts +158 -0
- package/dist/config.js +22 -0
- package/dist/vxil.js +4197 -0
- package/package.json +57 -0
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type { NotificationsConfig, JobsConfig, AuthConfig, RateLimitsConfig, FilesConfig, WebhooksConfig, CommentsConfig, CmsConfig, McpConfig, RealtimeConfig, PresenceConfig, OrgsConfig, ActivityFeedConfig, VectorSearchConfig, AiConfig, RagConfig, PaymentsConfig, FunctionsConfig, CopilotConfig } from './_vxil-feature-configs.js';
|
|
2
|
+
/** The 9 CMS field types (workers/cms-v1 core.ts FIELD_TYPES). */
|
|
3
|
+
export type FieldType = 'string' | 'text' | 'int' | 'float' | 'bool' | 'datetime' | 'json' | 'relation' | 'file';
|
|
4
|
+
/** The 8 fixed CMS index-slot columns (4 string · 2 numeric · 2 datetime). */
|
|
5
|
+
export type IndexSlot = 's1' | 's2' | 's3' | 's4' | 'n1' | 'n2' | 't1' | 't2';
|
|
6
|
+
/** A single CMS field declaration — mirrors the cms-v1 FieldInput wire shape. */
|
|
7
|
+
export interface FieldDef {
|
|
8
|
+
type: FieldType;
|
|
9
|
+
required?: boolean;
|
|
10
|
+
validation?: Record<string, unknown>;
|
|
11
|
+
/** map to an index slot to make the field filterable-by-range / sortable. */
|
|
12
|
+
indexSlot?: IndexSlot;
|
|
13
|
+
/** required when type === 'relation' — the target collection slug. */
|
|
14
|
+
relationTo?: string;
|
|
15
|
+
computed?: boolean;
|
|
16
|
+
compute?: unknown;
|
|
17
|
+
}
|
|
18
|
+
/** A CMS collection-as-code: collection slug → fields. */
|
|
19
|
+
export interface CollectionDef {
|
|
20
|
+
singular?: string;
|
|
21
|
+
fields: Record<string, FieldDef>;
|
|
22
|
+
/** End-user owner-scoping (docs/end-user-principals-design.md §5.1): names an
|
|
23
|
+
* existing `string` field on this collection that holds the owner (end-user)
|
|
24
|
+
* id. When set, the cms worker auto-scopes owned reads/writes to the VERIFIED
|
|
25
|
+
* end-user principal in end-user mode (default-deny) — and is a no-op in
|
|
26
|
+
* server-caller mode. NOT an RLS predicate; a single declarative flag the
|
|
27
|
+
* typed worker consults. Omit for shared/reference collections. */
|
|
28
|
+
ownerField?: string;
|
|
29
|
+
}
|
|
30
|
+
/** A function trigger (the §7.3 crossing). cmsHook fires on a CMS write;
|
|
31
|
+
* authHook is the post-signup hook (fires on `auth.user.created`,
|
|
32
|
+
* at-least-once, ~1min fanout latency). */
|
|
33
|
+
export type FunctionTrigger = {
|
|
34
|
+
kind: 'http';
|
|
35
|
+
path?: string;
|
|
36
|
+
} | {
|
|
37
|
+
kind: 'cron';
|
|
38
|
+
schedule: string;
|
|
39
|
+
} | {
|
|
40
|
+
kind: 'queue';
|
|
41
|
+
source: string;
|
|
42
|
+
} | {
|
|
43
|
+
kind: 'webhook';
|
|
44
|
+
source: string;
|
|
45
|
+
} | {
|
|
46
|
+
kind: 'cmsHook';
|
|
47
|
+
collection: string;
|
|
48
|
+
event: 'beforeCreate' | 'beforeUpdate' | 'beforeWrite';
|
|
49
|
+
} | {
|
|
50
|
+
kind: 'authHook';
|
|
51
|
+
event?: 'user.created';
|
|
52
|
+
};
|
|
53
|
+
/** A deployed tenant function — source in functions/, deployed on `vxil push`. */
|
|
54
|
+
export interface FunctionDef {
|
|
55
|
+
/** path to the ES-module entrypoint, e.g. ./functions/<name>.ts */
|
|
56
|
+
entry: string;
|
|
57
|
+
trigger?: FunctionTrigger;
|
|
58
|
+
/** clamped by DENY_FUNCTION_SCOPES at deploy (admin, wildcard, features:write,
|
|
59
|
+
* functions:write, secrets:write rejected; payments:write / notifications:send /
|
|
60
|
+
* users:* allowed as owner-granted business scopes). */
|
|
61
|
+
scopes?: string[];
|
|
62
|
+
/** tenant_secrets refs injected under KEK_FUNCTIONS (productization). */
|
|
63
|
+
secrets?: string[];
|
|
64
|
+
/** Outbound-Worker host allowlist (deny-by-default egress guard). */
|
|
65
|
+
egressAllow?: string[];
|
|
66
|
+
limits?: {
|
|
67
|
+
cpuMs?: number;
|
|
68
|
+
timeoutMs?: number;
|
|
69
|
+
memoryMb?: number;
|
|
70
|
+
};
|
|
71
|
+
enabled?: boolean;
|
|
72
|
+
/** optional typed contract surfaced by `vxil gen` (Level 1, §4.5). */
|
|
73
|
+
signature?: {
|
|
74
|
+
input?: unknown;
|
|
75
|
+
output?: unknown;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/** A secret REFERENCE (never a value). `vxil secrets set <name>` writes the value. */
|
|
79
|
+
export interface SecretRef {
|
|
80
|
+
/** which feature's KEK the value is envelope-encrypted under. */
|
|
81
|
+
feature: string;
|
|
82
|
+
description?: string;
|
|
83
|
+
}
|
|
84
|
+
/** Optional deterministic seed, applied via the per-feature import bundle. */
|
|
85
|
+
export interface SeedSpec {
|
|
86
|
+
cms?: {
|
|
87
|
+
collection: string;
|
|
88
|
+
items: Record<string, unknown>[];
|
|
89
|
+
}[];
|
|
90
|
+
users?: {
|
|
91
|
+
id: string;
|
|
92
|
+
email?: string;
|
|
93
|
+
}[];
|
|
94
|
+
}
|
|
95
|
+
/** The released API majors (docs/feature-versioning.md §3), a CLOSED union —
|
|
96
|
+
* `'v1'` is the only released major, so `apiVersion: 'v2'` is a COMPILE error
|
|
97
|
+
* until a v2 GAs. `defineConfig` also validates it at runtime against
|
|
98
|
+
* `RELEASED_API_VERSIONS`. */
|
|
99
|
+
export type ApiVersion = 'v1';
|
|
100
|
+
/** The released majors `defineConfig` validates `apiVersion` against. Widened
|
|
101
|
+
* only by a real v2. */
|
|
102
|
+
export declare const RELEASED_API_VERSIONS: readonly ApiVersion[];
|
|
103
|
+
/** The whole vxil backend, declared in one typed, version-controlled file. */
|
|
104
|
+
export interface VxilConfig {
|
|
105
|
+
/** target environment label; resolved to a baseUrl by `vxil link` / `--env`. */
|
|
106
|
+
env?: string;
|
|
107
|
+
/** Pin the API major the CLI targets (default `'v1'`, docs/feature-versioning.md).
|
|
108
|
+
* Path-major, per-platform: a breaking change ships as a new major on a new
|
|
109
|
+
* path with a ≥6-month deprecation window. `VXIL_API_VERSION` overrides this
|
|
110
|
+
* for a one-off invocation. */
|
|
111
|
+
apiVersion?: ApiVersion;
|
|
112
|
+
/** (a) PER-feature CONFIG — the same 15-leaf TypeBox manifests, validated by the
|
|
113
|
+
* same Value.Default/Clean pipeline the server uses. Keys match FEATURE_SCHEMAS
|
|
114
|
+
* exactly (note the hyphenated ids). */
|
|
115
|
+
features?: {
|
|
116
|
+
notifications?: Partial<NotificationsConfig>;
|
|
117
|
+
jobs?: Partial<JobsConfig>;
|
|
118
|
+
auth?: Partial<AuthConfig>;
|
|
119
|
+
'rate-limits'?: Partial<RateLimitsConfig>;
|
|
120
|
+
files?: Partial<FilesConfig>;
|
|
121
|
+
webhooks?: Partial<WebhooksConfig>;
|
|
122
|
+
comments?: Partial<CommentsConfig>;
|
|
123
|
+
cms?: Partial<CmsConfig>;
|
|
124
|
+
mcp?: Partial<McpConfig>;
|
|
125
|
+
realtime?: Partial<RealtimeConfig>;
|
|
126
|
+
presence?: Partial<PresenceConfig>;
|
|
127
|
+
orgs?: Partial<OrgsConfig>;
|
|
128
|
+
'activity-feed'?: Partial<ActivityFeedConfig>;
|
|
129
|
+
'vector-search'?: Partial<VectorSearchConfig>;
|
|
130
|
+
ai?: Partial<AiConfig>;
|
|
131
|
+
rag?: Partial<RagConfig>;
|
|
132
|
+
payments?: Partial<PaymentsConfig>;
|
|
133
|
+
functions?: Partial<FunctionsConfig>;
|
|
134
|
+
copilot?: Partial<CopilotConfig>;
|
|
135
|
+
};
|
|
136
|
+
/** (b) CMS SCHEMA-AS-CODE — collections + fields. `push` reconciles them
|
|
137
|
+
* additively against GET /v1/cms/collections (no destructive drops without
|
|
138
|
+
* --allow-destructive). Lane-A hooks stay in features.cms.hooks (config). */
|
|
139
|
+
cms?: {
|
|
140
|
+
collections?: Record<string, CollectionDef>;
|
|
141
|
+
};
|
|
142
|
+
/** (c) FUNCTIONS — name → trigger/scopes/egress/entry; sources in functions/. */
|
|
143
|
+
functions?: Record<string, FunctionDef>;
|
|
144
|
+
/** (d) SECRETS — REFERENCES ONLY, never values. */
|
|
145
|
+
secrets?: Record<string, SecretRef>;
|
|
146
|
+
/** (e) SEED DATA — optional. */
|
|
147
|
+
seed?: SeedSpec;
|
|
148
|
+
}
|
|
149
|
+
/** A typed identity function: returns its argument so the CLI can compile it.
|
|
150
|
+
* The one runtime check is `apiVersion` — a mistyped/unreleased pin (possible
|
|
151
|
+
* from JS callers with no compile gate, or a stale generated value) fails fast
|
|
152
|
+
* here rather than 404-ing every request against a nonexistent major. */
|
|
153
|
+
export declare function defineConfig(c: VxilConfig): VxilConfig;
|
|
154
|
+
/** Authoring helper for split-out cms/<name>.ts collection modules (§6a).
|
|
155
|
+
* `field('title', 'string', { required: true, indexSlot: 's1' })`. */
|
|
156
|
+
export declare function field(type: FieldType, opts?: Omit<FieldDef, 'type'>): FieldDef;
|
|
157
|
+
/** Authoring helper for a collection module: `export default collection({...})`. */
|
|
158
|
+
export declare function collection(def: CollectionDef): CollectionDef;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// ../config/src/index.ts
|
|
2
|
+
var RELEASED_API_VERSIONS = ["v1"];
|
|
3
|
+
function defineConfig(c) {
|
|
4
|
+
if (c.apiVersion !== void 0 && !RELEASED_API_VERSIONS.includes(c.apiVersion)) {
|
|
5
|
+
throw new Error(
|
|
6
|
+
`vxil.config: apiVersion '${String(c.apiVersion)}' is not a released API major (released: ${RELEASED_API_VERSIONS.map((v) => `'${v}'`).join(", ")}). A new major ships as a new path with its own deprecation window \u2014 see docs/feature-versioning.md.`
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
return c;
|
|
10
|
+
}
|
|
11
|
+
function field(type, opts = {}) {
|
|
12
|
+
return { type, ...opts };
|
|
13
|
+
}
|
|
14
|
+
function collection(def) {
|
|
15
|
+
return def;
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
RELEASED_API_VERSIONS,
|
|
19
|
+
collection,
|
|
20
|
+
defineConfig,
|
|
21
|
+
field
|
|
22
|
+
};
|