@vxil/sdk 0.16.1 → 0.17.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/index.d.ts CHANGED
@@ -2266,6 +2266,11 @@ type DisabledFeatures<S extends VxilSchemaShape> = {
2266
2266
  export type EnabledVxil<S extends VxilSchemaShape> = Omit<Vxil<S>, DisabledFeatures<S>> & {
2267
2267
  [P in DisabledFeatures<S>]: DisabledFeature<FeatureMap[P] & string>;
2268
2268
  };
2269
+ /** A cms collection's END-USER ACCESS mode (guide ch. 9): what a verified end
2270
+ * user (thin-client key + session) may do on it — `'readwrite'` (default),
2271
+ * `'read'` (writes are `403 server_only`) or `'none'` (reads and writes are
2272
+ * `403 server_only`). Server keys are never affected. */
2273
+ export type CmsEndUserAccess = 'readwrite' | 'read' | 'none';
2269
2274
  /** One config-declared per-record ACTION (guide ch. 4): a button on a record row
2270
2275
  * that invokes the deployed tenant function `fn` ONCE with `{ collection,
2271
2276
  * item_id, action, actor, item }`. Exactly one human-initiated step — no
@@ -3281,7 +3286,13 @@ export declare class Vxil<S extends VxilSchemaShape = VxilSchemaShape> {
3281
3286
  };
3282
3287
  /** `progress_fields`: the progress keys (`progress` / `stage` /
3283
3288
  * `message`) a webhook-mode `processing` callback also writes onto the
3284
- * mirrored record — realtime clients of that record see them live */
3289
+ * mirrored record — realtime clients of that record see them live.
3290
+ * In END-USER mode (`asEndUser`, or a function invoked for a signed-in
3291
+ * user) the target must be a cms record that user can read: another
3292
+ * user's row, a server-only collection or a non-cms feature answers
3293
+ * 403 `mirror_target_forbidden` and nothing starts (503
3294
+ * `mirror_check_unavailable` if the check could not run — retry).
3295
+ * Mirror onto a server-only row from server-mode code instead. */
3285
3296
  status_mirror?: {
3286
3297
  feature: string;
3287
3298
  collection: string;
@@ -3933,7 +3944,11 @@ export declare class Vxil<S extends VxilSchemaShape = VxilSchemaShape> {
3933
3944
  };
3934
3945
  readonly cms: {
3935
3946
  collections: {
3936
- /** Define a content type. The model is data — not config. */
3947
+ /** Define a content type. The model is data — not config.
3948
+ * Model management (`create`, `addField` and every fields-route meta-op
3949
+ * in this namespace) is SERVER-ONLY: a client acting as a signed-in end
3950
+ * user (`asEndUser`, a thin-client key) gets `403 server_only`. Call
3951
+ * these with a server key — your backend, `vxil push`, or the dashboard. */
3937
3952
  create: (input: {
3938
3953
  collection: string;
3939
3954
  singular?: string;
@@ -3949,6 +3964,12 @@ export declare class Vxil<S extends VxilSchemaShape = VxilSchemaShape> {
3949
3964
  * and the owner_field are never exposed. Optional; defaults false. Use the
3950
3965
  * top-level `cmsPublicUrl` / `listCmsPublic` helpers for the reader side. */
3951
3966
  public?: boolean;
3967
+ /** What a VERIFIED end user may do here (guide ch. 9, "Read-only and
3968
+ * server-only collections"): `'readwrite'` (default), `'read'` (every
3969
+ * end-user write is `403 server_only`; reads unchanged) or `'none'`
3970
+ * (end-user reads and writes are `403 server_only`, even with an
3971
+ * owner_field). Server keys are never affected. */
3972
+ end_user_access?: CmsEndUserAccess;
3952
3973
  fields?: Array<{
3953
3974
  field: string;
3954
3975
  type: "string" | "text" | "int" | "float" | "bool" | "datetime" | "json" | "relation" | "file";
@@ -3996,12 +4017,16 @@ export declare class Vxil<S extends VxilSchemaShape = VxilSchemaShape> {
3996
4017
  owner_field?: string;
3997
4018
  public?: boolean;
3998
4019
  actions?: CmsActionDef[];
4020
+ /** present when not the default 'readwrite' */
4021
+ end_user_access?: CmsEndUserAccess;
3999
4022
  }>;
4000
4023
  list: () => Promise<Array<{
4001
4024
  collection: string;
4002
4025
  singular: string;
4003
4026
  fields: unknown[];
4004
4027
  owner_field?: string | null;
4028
+ /** the collection's end-user access mode (absent from an older server = 'readwrite') */
4029
+ end_user_access?: CmsEndUserAccess;
4005
4030
  }>>;
4006
4031
  addField: (collection: string, field: Record<string, unknown>) => Promise<void>;
4007
4032
  /** Set (or clear, with `null`/`[]`) a field's READ-ROLE gate (guide ch. 4) —
@@ -4033,6 +4058,17 @@ export declare class Vxil<S extends VxilSchemaShape = VxilSchemaShape> {
4033
4058
  * the owner_field are never exposed. `false` closes the lane (and purges the
4034
4059
  * edge cache). Read the public side with `cmsPublicUrl` / `listCmsPublic`. */
4035
4060
  setPublic: (collection: string, isPublic: boolean) => Promise<void>;
4061
+ /** Set the collection's END-USER ACCESS mode (guide ch. 9, "Read-only and
4062
+ * server-only collections"). `'read'`: a verified end user (thin-client
4063
+ * key + session) may still read — owner-scoped when the collection has an
4064
+ * owner_field — but every end-user write answers `403 server_only`;
4065
+ * `'none'`: end-user reads and writes are both refused; `'readwrite'`
4066
+ * (default) restores today's behaviour. Server keys are never affected.
4067
+ * Audited; takes effect on the next request. */
4068
+ setEndUserAccess: (collection: string, access: CmsEndUserAccess) => Promise<{
4069
+ collection: string;
4070
+ end_user_access: CmsEndUserAccess;
4071
+ }>;
4036
4072
  /** Re-project the collection's index slots after an `index_slot` move
4037
4073
  * (guide ch. 4). Slots are projected on WRITE only, so until this runs,
4038
4074
  * stored rows keep their OLD projection: the new slot is NULL and the
package/dist/index.js CHANGED
@@ -1210,7 +1210,11 @@ export class Vxil {
1210
1210
  };
1211
1211
  cms = {
1212
1212
  collections: {
1213
- /** Define a content type. The model is data — not config. */
1213
+ /** Define a content type. The model is data — not config.
1214
+ * Model management (`create`, `addField` and every fields-route meta-op
1215
+ * in this namespace) is SERVER-ONLY: a client acting as a signed-in end
1216
+ * user (`asEndUser`, a thin-client key) gets `403 server_only`. Call
1217
+ * these with a server key — your backend, `vxil push`, or the dashboard. */
1214
1218
  create: async (input) => (await this.call('POST', '/v1/cms/collections', input)).data,
1215
1219
  list: async () => (await this.call('GET', '/v1/cms/collections')).data.collections,
1216
1220
  addField: async (collection, field) => {
@@ -1262,6 +1266,14 @@ export class Vxil {
1262
1266
  setPublic: async (collection, isPublic) => {
1263
1267
  await this.call('POST', `/v1/cms/collections/${encodeURIComponent(collection)}/fields`, { public: isPublic });
1264
1268
  },
1269
+ /** Set the collection's END-USER ACCESS mode (guide ch. 9, "Read-only and
1270
+ * server-only collections"). `'read'`: a verified end user (thin-client
1271
+ * key + session) may still read — owner-scoped when the collection has an
1272
+ * owner_field — but every end-user write answers `403 server_only`;
1273
+ * `'none'`: end-user reads and writes are both refused; `'readwrite'`
1274
+ * (default) restores today's behaviour. Server keys are never affected.
1275
+ * Audited; takes effect on the next request. */
1276
+ setEndUserAccess: async (collection, access) => (await this.call('POST', `/v1/cms/collections/${encodeURIComponent(collection)}/fields`, { end_user_access: access })).data,
1265
1277
  /** Re-project the collection's index slots after an `index_slot` move
1266
1278
  * (guide ch. 4). Slots are projected on WRITE only, so until this runs,
1267
1279
  * stored rows keep their OLD projection: the new slot is NULL and the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vxil/sdk",
3
- "version": "0.16.1",
3
+ "version": "0.17.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Typed client for the Vxil REST API (notifications, auth, jobs, files, cms, comments, webhooks, realtime, orgs, rate-limits).",