@tanglemedia/svelte-starter-directus-api 2.1.0 → 3.0.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.
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { type AllCollections, type DirectusClient, type RegularCollections, type RestClient } from '@directus/sdk';
|
|
2
|
-
import { ApiAdapterAbstract, type AnyObject, type ApiAdapterRequestConfig, type ApiAggregateQuery, type ApiCreateManyQuery, type ApiDeleteManyQuery, type ApiFindQuery, type ApiId, type ApiResponse, type ApiUpdateManyQuery, type BaseApiMethods } from '@tanglemedia/svelte-starter-core';
|
|
2
|
+
import { ApiAdapterAbstract, type AnyObject, type ApiAdapterHandle, type ApiAdapterRequestConfig, type ApiAggregateQuery, type ApiCreateManyQuery, type ApiDeleteManyQuery, type ApiFindQuery, type ApiId, type ApiResponse, type ApiUpdateManyQuery, type BaseApiMethods, type HandleEvent } from '@tanglemedia/svelte-starter-core';
|
|
3
3
|
import type { DirectusConfig, SchemaShape } from '../types/adapter.types';
|
|
4
4
|
export type AdapterClient<Schema extends SchemaShape = SchemaShape> = DirectusClient<Schema> & RestClient<Schema>;
|
|
5
5
|
/**
|
|
6
6
|
* TODO: Various types fixes. The current adapter doesn't correctly follow the types defined under the ApiAdapterAbstract.
|
|
7
7
|
* See the fetch adapter under the core
|
|
8
8
|
*/
|
|
9
|
-
export declare class DirectusApiAdapter<Schema extends SchemaShape = SchemaShape, Path extends RegularCollections<Schema> = RegularCollections<Schema>> extends ApiAdapterAbstract<DirectusConfig, ApiAdapterRequestConfig, Path, AdapterClient> {
|
|
9
|
+
export declare class DirectusApiAdapter<Schema extends SchemaShape = SchemaShape, Path extends RegularCollections<Schema> = RegularCollections<Schema>> extends ApiAdapterAbstract<DirectusConfig, ApiAdapterRequestConfig, Path, AdapterClient> implements ApiAdapterHandle {
|
|
10
10
|
protected config: DirectusConfig;
|
|
11
11
|
private readonly directus;
|
|
12
12
|
constructor(config: DirectusConfig, directus: AdapterClient<Schema>);
|
|
13
|
+
handle(event: HandleEvent): Promise<void>;
|
|
13
14
|
getAdapterClient(): AdapterClient<Schema> | null;
|
|
14
15
|
normalizeMeta(response: AnyObject): {
|
|
15
16
|
total?: undefined;
|
|
@@ -12,6 +12,10 @@ export class DirectusApiAdapter extends ApiAdapterAbstract {
|
|
|
12
12
|
this.config = config;
|
|
13
13
|
this.directus = directus;
|
|
14
14
|
}
|
|
15
|
+
async handle(event) {
|
|
16
|
+
const f = event.fetch;
|
|
17
|
+
this.directus.globals.fetch = f;
|
|
18
|
+
}
|
|
15
19
|
getAdapterClient() {
|
|
16
20
|
return this.directus;
|
|
17
21
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanglemedia/svelte-starter-directus-api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"main": "src/index.ts",
|
|
5
5
|
"types": "src/index.ts",
|
|
6
6
|
"description": "directus API wrapper for all the directus sdk functionality",
|
|
@@ -22,31 +22,31 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@directus/types": "^12.
|
|
26
|
-
"@sveltejs/adapter-auto": "^3.2.
|
|
27
|
-
"@sveltejs/package": "^2.3.
|
|
25
|
+
"@directus/types": "^12.1.0",
|
|
26
|
+
"@sveltejs/adapter-auto": "^3.2.5",
|
|
27
|
+
"@sveltejs/package": "^2.3.5",
|
|
28
28
|
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
|
29
29
|
"@testing-library/jest-dom": "^6.5.0",
|
|
30
|
-
"@testing-library/svelte": "^5.2.
|
|
31
|
-
"@vitest/coverage-v8": "^2.
|
|
32
|
-
"jsdom": "^25.0.
|
|
33
|
-
"msw": "^2.4.
|
|
30
|
+
"@testing-library/svelte": "^5.2.3",
|
|
31
|
+
"@vitest/coverage-v8": "^2.1.2",
|
|
32
|
+
"jsdom": "^25.0.1",
|
|
33
|
+
"msw": "^2.4.9",
|
|
34
34
|
"svelte": "^4.2.19",
|
|
35
|
-
"svelte-check": "^
|
|
36
|
-
"vite": "^5.4.
|
|
37
|
-
"vitest": "^2.
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
35
|
+
"svelte-check": "^4.0.4",
|
|
36
|
+
"vite": "^5.4.8",
|
|
37
|
+
"vitest": "^2.1.2",
|
|
38
|
+
"@tanglemedia/svelte-starter-core": "0.3.0",
|
|
39
|
+
"@internal/eslint-config": "0.0.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@directus/sdk": "^17.0.
|
|
42
|
+
"@directus/sdk": "^17.0.2",
|
|
43
43
|
"@types/js-cookie": "^3.0.6",
|
|
44
44
|
"esm-env": "^1.0.0",
|
|
45
45
|
"js-cookie": "^3.0.5"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"@sveltejs/kit": ">=2 <3",
|
|
49
|
-
"@tanglemedia/svelte-starter-core": ">=0.
|
|
49
|
+
"@tanglemedia/svelte-starter-core": ">=0.3.0",
|
|
50
50
|
"svelte": ">=4 <5"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
import {
|
|
18
18
|
ApiAdapterAbstract,
|
|
19
19
|
type AnyObject,
|
|
20
|
+
type ApiAdapterHandle,
|
|
20
21
|
type ApiAdapterRequestConfig,
|
|
21
22
|
type ApiAggregateQuery,
|
|
22
23
|
type ApiCreateManyQuery,
|
|
@@ -25,7 +26,8 @@ import {
|
|
|
25
26
|
type ApiId,
|
|
26
27
|
type ApiResponse,
|
|
27
28
|
type ApiUpdateManyQuery,
|
|
28
|
-
type BaseApiMethods
|
|
29
|
+
type BaseApiMethods,
|
|
30
|
+
type HandleEvent
|
|
29
31
|
} from '@tanglemedia/svelte-starter-core';
|
|
30
32
|
import type { DirectusConfig, SchemaShape } from '../types/adapter.types';
|
|
31
33
|
|
|
@@ -39,7 +41,7 @@ export type AdapterClient<Schema extends SchemaShape = SchemaShape> = DirectusCl
|
|
|
39
41
|
export class DirectusApiAdapter<
|
|
40
42
|
Schema extends SchemaShape = SchemaShape,
|
|
41
43
|
Path extends RegularCollections<Schema> = RegularCollections<Schema>
|
|
42
|
-
> extends ApiAdapterAbstract<DirectusConfig, ApiAdapterRequestConfig, Path, AdapterClient> {
|
|
44
|
+
> extends ApiAdapterAbstract<DirectusConfig, ApiAdapterRequestConfig, Path, AdapterClient> implements ApiAdapterHandle {
|
|
43
45
|
constructor(
|
|
44
46
|
protected config: DirectusConfig,
|
|
45
47
|
private readonly directus: AdapterClient<Schema>
|
|
@@ -47,6 +49,11 @@ export class DirectusApiAdapter<
|
|
|
47
49
|
super(config);
|
|
48
50
|
}
|
|
49
51
|
|
|
52
|
+
async handle(event: HandleEvent) {
|
|
53
|
+
const f = event.fetch;
|
|
54
|
+
this.directus.globals.fetch = f;
|
|
55
|
+
}
|
|
56
|
+
|
|
50
57
|
getAdapterClient(): AdapterClient<Schema> | null {
|
|
51
58
|
return this.directus;
|
|
52
59
|
}
|