@arcote.tech/arc-files 0.7.25 → 0.7.27

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arcote.tech/arc-files",
3
3
  "type": "module",
4
- "version": "0.7.25",
4
+ "version": "0.7.27",
5
5
  "private": false,
6
6
  "description": "Generic file upload fragment for Arc framework — S3 presigned upload + provider file_id binding",
7
7
  "main": "./src/index.ts",
@@ -10,9 +10,9 @@
10
10
  "type-check": "tsc --noEmit"
11
11
  },
12
12
  "peerDependencies": {
13
- "@arcote.tech/arc": "^0.7.25",
14
- "@arcote.tech/arc-ds": "^0.7.25",
15
- "@arcote.tech/platform": "^0.7.25",
13
+ "@arcote.tech/arc": "^0.7.27",
14
+ "@arcote.tech/arc-ds": "^0.7.27",
15
+ "@arcote.tech/platform": "^0.7.27",
16
16
  "@aws-sdk/client-s3": "^3.658.0",
17
17
  "@aws-sdk/s3-request-presigner": "^3.658.0",
18
18
  "lucide-react": ">=0.400.0",
@@ -2,8 +2,10 @@
2
2
  import type {
3
3
  ArcId,
4
4
  ArcRawShape,
5
+ ArcRawShapeType,
5
6
  ArcTokenAny,
6
7
  Merge,
8
+ ViewProtectionFn,
7
9
  } from "@arcote.tech/arc";
8
10
  import { createFileTypeAggregate } from "./aggregates/file";
9
11
  import type { S3Bridge } from "./s3/s3-client";
@@ -17,9 +19,24 @@ export interface FileTypeProtection {
17
19
  token: ArcTokenAny;
18
20
  // `params` is the decoded token payload; user-provided check returns
19
21
  // a where-clause restriction (`{field: value}`) or `false` to deny.
20
- check: (params: any) => Record<string, unknown> | false;
22
+ // Typowane tym samym `ViewProtectionFn` co `aggregate.protectBy` — payload
23
+ // tokena inferowany z `token` (zero `any` po stronie konsumenta).
24
+ check: ViewProtectionFn;
21
25
  }
22
26
 
27
+ /**
28
+ * Ctx handlera custom mutation (`.withMutation()`). Auto-generowany emitter
29
+ * `<name>Performed` jest TYPOWANY (łapie literówkę w nazwie eventu). Reszta
30
+ * ctx (`modify`/`$query`/`set`/`findOne`) pozostaje permisywna — pełne
31
+ * otypowanie blokuje limit instancjacji TS na rosnących tuple
32
+ * Events/MutateMethods (ten sam powód co `aggAny: any` w `aggregates/file.ts`).
33
+ */
34
+ export type FileMutationContext<N extends string> = {
35
+ [K in `${N}Performed`]: {
36
+ emit: (payload: Record<string, unknown>) => Promise<void>;
37
+ };
38
+ } & Record<string, any>;
39
+
23
40
  /**
24
41
  * Custom mutation rejestrowana przez `.withMutation()`. Builder generuje
25
42
  * dedicated event `<name>Performed` + mutation method z params. Handler
@@ -95,10 +112,7 @@ export class ArcFileTypeBuilder<
95
112
  * tokena. Każdy `.protectedBy()` dodaje jeden entry do listy; przy
96
113
  * `.build()` builder iteruje i woła `aggregate.protectBy()` per entry.
97
114
  */
98
- protectedBy<T extends ArcTokenAny>(
99
- token: T,
100
- check: (params: any) => Record<string, unknown> | false,
101
- ) {
115
+ protectedBy<T extends ArcTokenAny>(token: T, check: ViewProtectionFn<T>) {
102
116
  type NewProtections = [
103
117
  ...Data["protections"],
104
118
  { token: T; check: typeof check },
@@ -126,7 +140,10 @@ export class ArcFileTypeBuilder<
126
140
  withMutation<const N extends string, const P extends ArcRawShape>(
127
141
  name: N,
128
142
  params: P,
129
- handler: (ctx: any, params: any) => Promise<void>,
143
+ handler: (
144
+ ctx: FileMutationContext<N>,
145
+ params: { _id: string } & ArcRawShapeType<P>,
146
+ ) => Promise<void>,
130
147
  ) {
131
148
  type NewMutations = [
132
149
  ...Data["mutations"],