@arcote.tech/arc 0.3.0 → 0.3.2

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.
@@ -115,18 +115,25 @@ export declare class ArcView<const Data extends ArcViewData> extends ArcContextE
115
115
  getElements(): Data["elements"];
116
116
  /**
117
117
  * Add token-based protection to this view
118
- * Defines read/write access conditions based on token params
118
+ * Defines read access conditions based on token params
119
+ * Write protection is handled by event protections, not view protections
119
120
  *
120
121
  * @param token - Token definition to protect with
121
- * @param protectionFn - Function returning read/write conditions
122
+ * @param protectionFn - Function returning read conditions (where clause) or false to deny
122
123
  *
123
124
  * @example
124
125
  * ```typescript
125
126
  * view("tasks", taskId, taskSchema)
126
- * .protectBy(userToken, (params) => ({
127
- * read: { userId: params.userId }, // Can only read own tasks
128
- * write: { userId: params.userId }, // Can only write own tasks
129
- * }));
127
+ * .protectBy(userToken, (params) => ({ userId: params.userId }));
128
+ * // Users can only read their own tasks
129
+ *
130
+ * view("publicPosts", postId, postSchema)
131
+ * .protectBy(userToken, () => ({}));
132
+ * // All authenticated users can read all posts
133
+ *
134
+ * view("adminOnly", id, schema)
135
+ * .protectBy(userToken, (params) => params.isAdmin ? {} : false);
136
+ * // Only admins can read, others get empty results
130
137
  * ```
131
138
  */
132
139
  protectBy<T extends ArcTokenAny>(token: T, protectionFn: ViewProtectionFn<any>): ArcView<Data>;
@@ -142,12 +149,9 @@ export declare class ArcView<const Data extends ArcViewData> extends ArcContextE
142
149
  * Get protection config for a specific token instance
143
150
  *
144
151
  * @param tokenInstance - Token instance to get protection for
145
- * @returns Protection config or null if no matching protection
152
+ * @returns Protection config (where clause) or null if no matching protection
146
153
  */
147
- getProtectionFor(tokenInstance: TokenInstanceAny): {
148
- read: any;
149
- write: any;
150
- } | null;
154
+ getProtectionFor(tokenInstance: TokenInstanceAny): Record<string, any> | false | null;
151
155
  /**
152
156
  * Generate database store schema for this view
153
157
  * Returns the view table with _id as primary key
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export * from "./context-element";
9
9
  export * from "./data-storage";
10
10
  export * from "./elements";
11
11
  export * from "./model";
12
+ export * from "./streaming";
12
13
  export * from "./token";
13
14
  export * from "./utils";
14
15
  //# sourceMappingURL=index.d.ts.map