@azure-net/kit 0.2.4 → 0.2.5

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.
@@ -1,7 +1,13 @@
1
1
  import { RequestContext } from '../../edges/context/index.js';
2
- export declare const createActionsProvider: <T, I extends Record<string, unknown> = Record<string, unknown>>(name: string, factory: (args: I & {
3
- context: Required<typeof RequestContext>;
4
- }) => T, inject?: I) => (() => T);
5
- export declare const createActionsProviderFactory: <I extends Record<string, unknown>>(inject: I) => <T>(name: string, factory: (args: I & {
6
- context: Required<typeof RequestContext>;
7
- }) => T) => () => T;
2
+ import { error, fail, redirect } from '@sveltejs/kit';
3
+ type Deps = {
4
+ context: Required<ReturnType<typeof RequestContext.current>>;
5
+ utils: {
6
+ fail: typeof fail;
7
+ redirect: typeof redirect;
8
+ error: typeof error;
9
+ };
10
+ };
11
+ export declare const createActionsProvider: <T, I extends Record<string, unknown> = Record<string, unknown>>(name: string, factory: (args: I & Deps) => T, inject?: I) => (() => T);
12
+ export declare const createActionsProviderFactory: <I extends Record<string, unknown>>(inject: I) => <T>(name: string, factory: (args: I & Deps) => T) => () => T;
13
+ export {};
@@ -1,5 +1,6 @@
1
1
  import { RequestContext } from '../../edges/context/index.js';
2
2
  import { browser } from '$app/environment';
3
+ import { error, fail, redirect } from '@sveltejs/kit';
3
4
  export const createActionsProvider = (name, factory, inject) => {
4
5
  const cacheKey = name;
5
6
  return () => {
@@ -14,7 +15,7 @@ export const createActionsProvider = (name, factory, inject) => {
14
15
  if (cacheKey && contextMap.has(cacheKey)) {
15
16
  return contextMap.get(cacheKey);
16
17
  }
17
- const instance = factory({ ...inject, context: RequestContext });
18
+ const instance = factory({ ...inject, context, utils: { fail, redirect, error } });
18
19
  if (cacheKey) {
19
20
  contextMap.set(cacheKey, instance);
20
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-net/kit",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "files": [
5
5
  "dist",
6
6
  "!dist/**/*.test.*",