@webamoki/web-svelte 2.2.0 → 2.2.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.
@@ -24,5 +24,5 @@ export declare function guardedCommand<Schema extends StandardSchemaV1, Output>(
24
24
  export declare function guardedCommandVoid<Output>(check: CheckFunction, fn: () => Promise<ResponseResult<Output>>): RemoteCommand<void, Promise<ResponseResult<Output>>>;
25
25
  export declare function guardedForm<Schema extends StandardSchemaV1<RemoteFormInput, Record<string, unknown>>, Output>(schema: Schema, check: CheckFunction, fn: (output: StandardSchemaV1.InferOutput<Schema>, issue: InvalidField<StandardSchemaV1.InferInput<Schema>>) => Promise<Output>): RemoteForm<StandardSchemaV1.InferInput<Schema>, Output>;
26
26
  export declare function guardedFormVoid<Output>(check: CheckFunction, fn: () => Promise<Output>): RemoteForm<void, Output>;
27
- export declare function guardedQuery<Schema extends StandardSchemaV1, Output>(check: CheckFunction, schema: Schema, fn: (output: StandardSchemaV1.InferOutput<Schema>) => Promise<ResponseResult<Output>>): RemoteQueryFunction<StandardSchemaV1.InferInput<Schema>, ResponseResult<Output>>;
28
- export declare function guardedQueryVoid<Output>(check: CheckFunction, fn: () => Promise<ResponseResult<Output>>): RemoteQueryFunction<void, ResponseResult<Output>>;
27
+ export declare function guardedQuery<Schema extends StandardSchemaV1, Output>(check: CheckFunction, schema: Schema, fn: (output: StandardSchemaV1.InferOutput<Schema>) => Promise<Output>): RemoteQueryFunction<StandardSchemaV1.InferInput<Schema>, Output>;
28
+ export declare function guardedQueryVoid<Output>(check: CheckFunction, fn: () => Promise<Output>): RemoteQueryFunction<void, Output>;
@@ -38,37 +38,32 @@ export function guardedCommandVoid(check, fn) {
38
38
  /* Guards form remote function with a check function. */
39
39
  export function guardedForm(schema, check, fn) {
40
40
  return form(schema, async (output, issue) => {
41
- const outcome = await check();
42
- // Use sveltekit error to play nicer form errors
43
- if (!outcome.ok)
44
- error(outcome.error.code, outcome.error.message);
41
+ // Enforce auth check or throw sveltekit error
42
+ ResponseResult.unwrap(await check());
45
43
  return await fn(output, issue);
46
44
  });
47
45
  }
48
46
  /* Guards input-less form remote function with a check function. */
49
47
  export function guardedFormVoid(check, fn) {
50
48
  return form(async () => {
51
- const outcome = await check();
52
- if (!outcome.ok)
53
- error(outcome.error.code, outcome.error.message);
49
+ // Enforce auth check or throw sveltekit error
50
+ ResponseResult.unwrap(await check());
54
51
  return await fn();
55
52
  });
56
53
  }
57
54
  /* Guards query remote function with a check function. */
58
55
  export function guardedQuery(check, schema, fn) {
59
56
  return query(schema, async (output) => {
60
- const outcome = await check();
61
- if (!outcome.ok)
62
- return Result.err(outcome.error);
57
+ // Enforce auth check or throw sveltekit error
58
+ ResponseResult.unwrap(await check());
63
59
  return await fn(output);
64
60
  });
65
61
  }
66
62
  /* Guards input-less query remote function with a check function. */
67
63
  export function guardedQueryVoid(check, fn) {
68
64
  return query(async () => {
69
- const outcome = await check();
70
- if (!outcome.ok)
71
- return Result.err(outcome.error);
65
+ // Enforce auth check or throw sveltekit error
66
+ ResponseResult.unwrap(await check());
72
67
  return await fn();
73
68
  });
74
69
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public",
5
5
  "provenance": true
6
6
  },
7
- "version": "2.2.0",
7
+ "version": "2.2.1",
8
8
  "license": "MIT",
9
9
  "repository": {
10
10
  "type": "git",