strapi-rest-lite 0.1.0 → 0.1.3
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/LICENSE +21 -0
- package/README.md +61 -39
- package/dist/index.d.ts +18 -5
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -5
- package/dist/index.js.map +1 -0
- package/dist/models/article.d.ts +21 -0
- package/dist/models/article.d.ts.map +1 -0
- package/dist/models/article.js +2 -0
- package/dist/models/article.js.map +1 -0
- package/dist/models/author.d.ts +13 -0
- package/dist/models/author.d.ts.map +1 -0
- package/dist/models/author.js +2 -0
- package/dist/models/author.js.map +1 -0
- package/dist/models/category.d.ts +11 -0
- package/dist/models/category.d.ts.map +1 -0
- package/dist/models/category.js +2 -0
- package/dist/models/category.js.map +1 -0
- package/dist/models/index.d.ts +6 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +6 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/page.d.ts +13 -0
- package/dist/models/page.d.ts.map +1 -0
- package/dist/models/page.js +2 -0
- package/dist/models/page.js.map +1 -0
- package/dist/models/product.d.ts +14 -0
- package/dist/models/product.d.ts.map +1 -0
- package/dist/models/product.js +2 -0
- package/dist/models/product.js.map +1 -0
- package/dist/repositories/article-repository.d.ts +6 -0
- package/dist/repositories/article-repository.d.ts.map +1 -0
- package/dist/repositories/article-repository.js +4 -0
- package/dist/repositories/article-repository.js.map +1 -0
- package/dist/repositories/category-repository.d.ts +6 -0
- package/dist/repositories/category-repository.d.ts.map +1 -0
- package/dist/repositories/category-repository.js +4 -0
- package/dist/repositories/category-repository.js.map +1 -0
- package/dist/repositories/collection-repository.d.ts +7 -0
- package/dist/repositories/collection-repository.d.ts.map +1 -0
- package/dist/repositories/collection-repository.js +29 -0
- package/dist/repositories/collection-repository.js.map +1 -0
- package/dist/repositories/collections.d.ts +14 -0
- package/dist/repositories/collections.d.ts.map +1 -0
- package/dist/repositories/collections.js +15 -0
- package/dist/repositories/collections.js.map +1 -0
- package/dist/repositories/contracts.d.ts +37 -0
- package/dist/repositories/contracts.d.ts.map +1 -0
- package/dist/repositories/contracts.js +2 -0
- package/dist/repositories/contracts.js.map +1 -0
- package/dist/repositories/index.d.ts +10 -0
- package/dist/repositories/index.d.ts.map +1 -0
- package/dist/repositories/index.js +17 -0
- package/dist/repositories/index.js.map +1 -0
- package/dist/repositories/page-repository.d.ts +6 -0
- package/dist/repositories/page-repository.d.ts.map +1 -0
- package/dist/repositories/page-repository.js +4 -0
- package/dist/repositories/page-repository.js.map +1 -0
- package/dist/repositories/product-repository.d.ts +6 -0
- package/dist/repositories/product-repository.d.ts.map +1 -0
- package/dist/repositories/product-repository.js +4 -0
- package/dist/repositories/product-repository.js.map +1 -0
- package/dist/repositories/strapi-client.d.ts +4 -0
- package/dist/repositories/strapi-client.d.ts.map +1 -0
- package/dist/repositories/strapi-client.js +36 -0
- package/dist/repositories/strapi-client.js.map +1 -0
- package/dist/services/article-service.d.ts +3 -0
- package/dist/services/article-service.d.ts.map +1 -0
- package/dist/services/article-service.js +7 -0
- package/dist/services/article-service.js.map +1 -0
- package/dist/services/category-service.d.ts +3 -0
- package/dist/services/category-service.d.ts.map +1 -0
- package/dist/services/category-service.js +6 -0
- package/dist/services/category-service.js.map +1 -0
- package/dist/services/collection-service.d.ts +5 -0
- package/dist/services/collection-service.d.ts.map +1 -0
- package/dist/services/collection-service.js +15 -0
- package/dist/services/collection-service.js.map +1 -0
- package/dist/services/contracts.d.ts +10 -0
- package/dist/services/contracts.d.ts.map +1 -0
- package/dist/services/contracts.js +2 -0
- package/dist/services/contracts.js.map +1 -0
- package/dist/services/index.d.ts +9 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +11 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/page-service.d.ts +3 -0
- package/dist/services/page-service.d.ts.map +1 -0
- package/dist/services/page-service.js +6 -0
- package/dist/services/page-service.js.map +1 -0
- package/dist/services/product-service.d.ts +3 -0
- package/dist/services/product-service.d.ts.map +1 -0
- package/dist/services/product-service.js +6 -0
- package/dist/services/product-service.js.map +1 -0
- package/dist/strapi-client.d.ts +3 -0
- package/dist/strapi-client.d.ts.map +1 -0
- package/dist/strapi-client.js +2 -0
- package/dist/strapi-client.js.map +1 -0
- package/package.json +31 -7
- package/dist/collection-repository.d.ts +0 -7
- package/dist/collection-repository.js +0 -16
- package/dist/collection-service.d.ts +0 -9
- package/dist/collection-service.js +0 -13
- package/dist/http-client.d.ts +0 -7
- package/dist/http-client.js +0 -33
- package/dist/media.d.ts +0 -4
- package/dist/media.js +0 -12
- package/dist/types.d.ts +0 -32
- package/dist/types.js +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Flexyfront
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,65 +1,87 @@
|
|
|
1
1
|
# strapi-rest-lite
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Leichte TypeScript-SDK für Strapi v4 REST-Collections (ESM-only). Sie liefert fertige Repositories/Services für typische Content-Typen sowie generische Helfer, um eigene Collections anzubinden.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
- Collection-Repository (`createCollectionRepository`) und Service-Fabrik (`createCollectionService`, `withDefaults`)
|
|
7
|
-
- Query-Types für Strapi (filters, populate, sort, pagination)
|
|
8
|
-
- Media-Helper (`resolveMediaUrl`)
|
|
9
|
-
|
|
10
|
-
## Installation (lokal / Git)
|
|
5
|
+
## Installation
|
|
11
6
|
|
|
12
7
|
```bash
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
# oder npm install ./packages/strapi-sdk
|
|
16
|
-
# oder via Git-URL/npm, sobald veröffentlicht: npm i strapi-rest-lite
|
|
8
|
+
npm install strapi-rest-lite
|
|
9
|
+
# ofetch wird als Dependency mitinstalliert, nitropack nur als optionales Peer-Dependency für die Typen.
|
|
17
10
|
```
|
|
18
11
|
|
|
19
|
-
##
|
|
12
|
+
## Schnellstart
|
|
20
13
|
|
|
21
14
|
```ts
|
|
22
|
-
import {
|
|
15
|
+
import { createRepositories, createServices } from 'strapi-rest-lite'
|
|
23
16
|
|
|
24
|
-
const
|
|
25
|
-
baseURL: process.env.NUXT_PUBLIC_API_BASE || 'http://localhost:1337',
|
|
26
|
-
token: process.env.STRAPI_TOKEN, // optional
|
|
27
|
-
})
|
|
17
|
+
const apiBase = 'https://cms.example.com/api'
|
|
28
18
|
|
|
29
|
-
//
|
|
30
|
-
const
|
|
31
|
-
const articleService = createCollectionService(articleRepo)
|
|
19
|
+
// Kombinierte Repositories (Articles, Categories, Pages, Products)
|
|
20
|
+
const repositories = createRepositories(apiBase)
|
|
32
21
|
|
|
33
|
-
//
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
})
|
|
22
|
+
// Optionale Services mit sinnvollen Defaults (populate: '*')
|
|
23
|
+
const services = createServices(repositories)
|
|
24
|
+
|
|
25
|
+
const article = await services.articleService.getBySlug('hello-world', { locale: 'en' })
|
|
26
|
+
console.log(article.data?.title)
|
|
39
27
|
```
|
|
40
28
|
|
|
41
|
-
|
|
29
|
+
Mit eigenen Collection-Slugs (z.B. abweichendes Strapi-Schema):
|
|
42
30
|
|
|
43
31
|
```ts
|
|
44
|
-
import {
|
|
32
|
+
import { createRepositories, CollectionName } from 'strapi-rest-lite'
|
|
45
33
|
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
34
|
+
const repositories = createRepositories(apiBase, {
|
|
35
|
+
product: 'shop-products',
|
|
36
|
+
page: CollectionName.Page, // enum für Defaults
|
|
49
37
|
})
|
|
50
|
-
|
|
51
|
-
const articleService = createArticleService(articleRepo)
|
|
52
38
|
```
|
|
53
39
|
|
|
54
|
-
|
|
40
|
+
## Bausteine
|
|
41
|
+
|
|
42
|
+
- `createStrapiClient(apiBase)`: dünner `ofetch`-Wrapper mit Querystring-Building.
|
|
43
|
+
- `createCollectionRepository(collectionName, httpClient)`: generisches Repository mit `findAll`, `findOneById`, `findOneBySlug` (Slug via Filter).
|
|
44
|
+
- Vorkonfigurierte Repositories: `createArticleRepository`, `createCategoryRepository`, `createPageRepository`, `createProductRepository` (jeweils optionaler `collectionName`-Parameter).
|
|
45
|
+
- `createRepositories(apiBase, collections?)`: bündelt die o.g. Repos; `collections` erlaubt Overrides pro Typ.
|
|
46
|
+
- `CollectionName`-Enum: zentrale Default-Slugs (`articles`, `categories`, `pages`, `products`).
|
|
47
|
+
- `createCollectionService(repository)`: Service mit semantischen Methoden (`list`, `getById`, `getBySlug`).
|
|
48
|
+
- `withDefaults(factory, defaults)`: merged Default-Queries (z.B. `populate: '*'`) in jeden Service-Call.
|
|
49
|
+
- Vorkonfigurierte Services: `createArticleService`, `createCategoryService`, `createPageService`, `createProductService`, plus `createServices(repositories)`.
|
|
50
|
+
- Typen/Models: `RepositoryQuery`, `CollectionRepository`, `CollectionService`, Strapi-Response-Typen und Models (`Article`, `Category`, `Page`, `Product`, `Author`).
|
|
51
|
+
|
|
52
|
+
### Eigene Collection anbinden
|
|
55
53
|
|
|
56
54
|
```ts
|
|
57
|
-
import {
|
|
55
|
+
import { createStrapiClient, createCollectionRepository } from 'strapi-rest-lite'
|
|
56
|
+
|
|
57
|
+
type FAQ = { id: number; question: string; answer: string }
|
|
58
|
+
|
|
59
|
+
const client = createStrapiClient('https://cms.example.com/api')
|
|
60
|
+
const faqRepository = createCollectionRepository<FAQ>('faqs', client)
|
|
58
61
|
|
|
59
|
-
const
|
|
62
|
+
const faqs = await faqRepository.findAll({ locale: 'de' })
|
|
60
63
|
```
|
|
61
64
|
|
|
62
|
-
##
|
|
65
|
+
## Queries (RepositoryQuery)
|
|
66
|
+
|
|
67
|
+
Unterstützt Strapi-Standardparameter:
|
|
68
|
+
|
|
69
|
+
- `populate`: `'*'` oder Feldnamen/Arrays.
|
|
70
|
+
- `filters`: beliebige Filter-Objekte (werden korrekt zu Querystring serialisiert).
|
|
71
|
+
- `sort`, `fields`, `pagination`, `locale`, weitere Schlüssel möglich.
|
|
72
|
+
|
|
73
|
+
`mergeFilters(query, filters)` hilft, zusätzliche Filter mit bestehenden zu kombinieren.
|
|
74
|
+
|
|
75
|
+
## Typen
|
|
76
|
+
|
|
77
|
+
Die Modelle sind in `src/models` definiert und über den Package-Export verfügbar. Sie orientieren sich an den Strapi-Content-Types (Artikel, Kategorie, Seite, Produkt, Author).
|
|
78
|
+
|
|
79
|
+
## Build / Release
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
npm run build # erzeugt dist/ mit ESM + .d.ts
|
|
83
|
+
npm pack # optional zum Prüfen des tarballs
|
|
84
|
+
# vor dem Publish: Repository-Felder im package.json anpassen, npm publish --cache .npm-cache
|
|
85
|
+
```
|
|
63
86
|
|
|
64
|
-
-
|
|
65
|
-
- Für Nuxt/Composables kannst du wie bisher eigene `useXYZ`-Hooks auf Basis des Services schreiben.
|
|
87
|
+
Das Paket ist ESM-only (`"type": "module"`, `moduleResolution: NodeNext`) und exportiert den Root-Eintragspunkt über das `exports`-Feld.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
1
|
+
export * from './models/index.js';
|
|
2
|
+
export * from './repositories/contracts.js';
|
|
3
|
+
export * from './repositories/collections.js';
|
|
4
|
+
export * from './repositories/strapi-client.js';
|
|
5
|
+
export * from './repositories/collection-repository.js';
|
|
6
|
+
export * from './repositories/article-repository.js';
|
|
7
|
+
export * from './repositories/category-repository.js';
|
|
8
|
+
export * from './repositories/page-repository.js';
|
|
9
|
+
export * from './repositories/product-repository.js';
|
|
10
|
+
export * from './repositories/index.js';
|
|
11
|
+
export * from './services/contracts.js';
|
|
12
|
+
export * from './services/collection-service.js';
|
|
13
|
+
export * from './services/article-service.js';
|
|
14
|
+
export * from './services/category-service.js';
|
|
15
|
+
export * from './services/page-service.js';
|
|
16
|
+
export * from './services/product-service.js';
|
|
17
|
+
export * from './services/index.js';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AAEjC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,iCAAiC,CAAA;AAC/C,cAAc,yCAAyC,CAAA;AACvD,cAAc,sCAAsC,CAAA;AACpD,cAAc,uCAAuC,CAAA;AACrD,cAAc,mCAAmC,CAAA;AACjD,cAAc,sCAAsC,CAAA;AACpD,cAAc,yBAAyB,CAAA;AAEvC,cAAc,yBAAyB,CAAA;AACvC,cAAc,kCAAkC,CAAA;AAChD,cAAc,+BAA+B,CAAA;AAC7C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,qBAAqB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
1
|
+
export * from './models/index.js';
|
|
2
|
+
export * from './repositories/contracts.js';
|
|
3
|
+
export * from './repositories/collections.js';
|
|
4
|
+
export * from './repositories/strapi-client.js';
|
|
5
|
+
export * from './repositories/collection-repository.js';
|
|
6
|
+
export * from './repositories/article-repository.js';
|
|
7
|
+
export * from './repositories/category-repository.js';
|
|
8
|
+
export * from './repositories/page-repository.js';
|
|
9
|
+
export * from './repositories/product-repository.js';
|
|
10
|
+
export * from './repositories/index.js';
|
|
11
|
+
export * from './services/contracts.js';
|
|
12
|
+
export * from './services/collection-service.js';
|
|
13
|
+
export * from './services/article-service.js';
|
|
14
|
+
export * from './services/category-service.js';
|
|
15
|
+
export * from './services/page-service.js';
|
|
16
|
+
export * from './services/product-service.js';
|
|
17
|
+
export * from './services/index.js';
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AAEjC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,iCAAiC,CAAA;AAC/C,cAAc,yCAAyC,CAAA;AACvD,cAAc,sCAAsC,CAAA;AACpD,cAAc,uCAAuC,CAAA;AACrD,cAAc,mCAAmC,CAAA;AACjD,cAAc,sCAAsC,CAAA;AACpD,cAAc,yBAAyB,CAAA;AAEvC,cAAc,yBAAyB,CAAA;AACvC,cAAc,kCAAkC,CAAA;AAChD,cAAc,+BAA+B,CAAA;AAC7C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Author } from './author.js';
|
|
2
|
+
import type { Category } from './category.js';
|
|
3
|
+
export interface Article {
|
|
4
|
+
id: number;
|
|
5
|
+
documentId: string;
|
|
6
|
+
title: string;
|
|
7
|
+
description: string;
|
|
8
|
+
slug: string;
|
|
9
|
+
cover?: string | null;
|
|
10
|
+
createdAt: string;
|
|
11
|
+
updatedAt: string;
|
|
12
|
+
publishedAt: string;
|
|
13
|
+
author: Author;
|
|
14
|
+
category: Category;
|
|
15
|
+
blocks?: Array<{
|
|
16
|
+
id?: number;
|
|
17
|
+
body?: string;
|
|
18
|
+
}>;
|
|
19
|
+
seo?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=article.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"article.d.ts","sourceRoot":"","sources":["../../src/models/article.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE7C,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,QAAQ,CAAA;IAClB,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAC9C,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"article.js","sourceRoot":"","sources":["../../src/models/article.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface Author {
|
|
2
|
+
id: number;
|
|
3
|
+
documentId: string;
|
|
4
|
+
name: string;
|
|
5
|
+
email?: string | null;
|
|
6
|
+
avatar?: string | {
|
|
7
|
+
url?: string | null;
|
|
8
|
+
} | null;
|
|
9
|
+
createdAt: string;
|
|
10
|
+
updatedAt: string;
|
|
11
|
+
publishedAt: string;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=author.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"author.d.ts","sourceRoot":"","sources":["../../src/models/author.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,GAAG;QAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAA;IAChD,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"author.js","sourceRoot":"","sources":["../../src/models/author.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"category.d.ts","sourceRoot":"","sources":["../../src/models/category.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"category.js","sourceRoot":"","sources":["../../src/models/category.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface Page {
|
|
2
|
+
id: number;
|
|
3
|
+
documentId: string;
|
|
4
|
+
title: string;
|
|
5
|
+
slug: string;
|
|
6
|
+
description?: string | null;
|
|
7
|
+
content?: unknown;
|
|
8
|
+
seo?: Record<string, unknown>;
|
|
9
|
+
createdAt: string;
|
|
10
|
+
updatedAt: string;
|
|
11
|
+
publishedAt: string;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../src/models/page.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page.js","sourceRoot":"","sources":["../../src/models/page.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface Product {
|
|
2
|
+
id: number;
|
|
3
|
+
documentId: string;
|
|
4
|
+
title: string;
|
|
5
|
+
slug: string;
|
|
6
|
+
description?: string | null;
|
|
7
|
+
price?: number | null;
|
|
8
|
+
sku?: string | null;
|
|
9
|
+
cover?: string | null;
|
|
10
|
+
createdAt: string;
|
|
11
|
+
updatedAt: string;
|
|
12
|
+
publishedAt: string;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=product.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product.d.ts","sourceRoot":"","sources":["../../src/models/product.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product.js","sourceRoot":"","sources":["../../src/models/product.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Article } from '../models/article.js';
|
|
2
|
+
import type { CollectionRepository, HttpClient } from './contracts.js';
|
|
3
|
+
import { CollectionName } from './collections.js';
|
|
4
|
+
export type ArticleRepository = CollectionRepository<Article>;
|
|
5
|
+
export declare const createArticleRepository: (client: HttpClient, collectionName?: CollectionName | string) => ArticleRepository;
|
|
6
|
+
//# sourceMappingURL=article-repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"article-repository.d.ts","sourceRoot":"","sources":["../../src/repositories/article-repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEtE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,MAAM,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAA;AAE7D,eAAO,MAAM,uBAAuB,GAClC,QAAQ,UAAU,EAClB,iBAAgB,cAAc,GAAG,MAA+B,KAC/D,iBAAgF,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createCollectionRepository } from './collection-repository.js';
|
|
2
|
+
import { CollectionName } from './collections.js';
|
|
3
|
+
export const createArticleRepository = (client, collectionName = CollectionName.Article) => createCollectionRepository(collectionName, client);
|
|
4
|
+
//# sourceMappingURL=article-repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"article-repository.js","sourceRoot":"","sources":["../../src/repositories/article-repository.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAA;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAIjD,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,MAAkB,EAClB,iBAA0C,cAAc,CAAC,OAAO,EAC7C,EAAE,CAAC,0BAA0B,CAAU,cAAc,EAAE,MAAM,CAAC,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Category } from '../models/category.js';
|
|
2
|
+
import type { CollectionRepository, HttpClient } from './contracts.js';
|
|
3
|
+
import { CollectionName } from './collections.js';
|
|
4
|
+
export type CategoryRepository = CollectionRepository<Category>;
|
|
5
|
+
export declare const createCategoryRepository: (client: HttpClient, collectionName?: CollectionName | string) => CategoryRepository;
|
|
6
|
+
//# sourceMappingURL=category-repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"category-repository.d.ts","sourceRoot":"","sources":["../../src/repositories/category-repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEtE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,MAAM,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAA;AAE/D,eAAO,MAAM,wBAAwB,GACnC,QAAQ,UAAU,EAClB,iBAAgB,cAAc,GAAG,MAAgC,KAChE,kBAAkF,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createCollectionRepository } from './collection-repository.js';
|
|
2
|
+
import { CollectionName } from './collections.js';
|
|
3
|
+
export const createCategoryRepository = (client, collectionName = CollectionName.Category) => createCollectionRepository(collectionName, client);
|
|
4
|
+
//# sourceMappingURL=category-repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"category-repository.js","sourceRoot":"","sources":["../../src/repositories/category-repository.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAA;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAIjD,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,MAAkB,EAClB,iBAA0C,cAAc,CAAC,QAAQ,EAC7C,EAAE,CAAC,0BAA0B,CAAW,cAAc,EAAE,MAAM,CAAC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CollectionRepository, HttpClient } from './contracts.js';
|
|
2
|
+
/**
|
|
3
|
+
* Erstellt ein Repository für eine Strapi-Collection.
|
|
4
|
+
* Dieses Repository kapselt alle API-Aufrufe für eine bestimmte Daten-Collection.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createCollectionRepository<T>(collectionName: string, http: HttpClient): CollectionRepository<T>;
|
|
7
|
+
//# sourceMappingURL=collection-repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection-repository.d.ts","sourceRoot":"","sources":["../../src/repositories/collection-repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,UAAU,EAIX,MAAM,gBAAgB,CAAA;AAGvB;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,EAC1C,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,UAAU,GACf,oBAAoB,CAAC,CAAC,CAAC,CA2BzB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { mergeFilters } from './strapi-client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Erstellt ein Repository für eine Strapi-Collection.
|
|
4
|
+
* Dieses Repository kapselt alle API-Aufrufe für eine bestimmte Daten-Collection.
|
|
5
|
+
*/
|
|
6
|
+
export function createCollectionRepository(collectionName, http) {
|
|
7
|
+
const baseUrl = `/${collectionName}`;
|
|
8
|
+
return {
|
|
9
|
+
async findAll(query) {
|
|
10
|
+
return http.get(baseUrl, query);
|
|
11
|
+
},
|
|
12
|
+
async findOneById(id, query) {
|
|
13
|
+
const url = `${baseUrl}/${id}`;
|
|
14
|
+
return http.get(url, query);
|
|
15
|
+
},
|
|
16
|
+
async findOneBySlug(slug, query) {
|
|
17
|
+
const finalQuery = mergeFilters(query, {
|
|
18
|
+
slug: { $eq: slug },
|
|
19
|
+
});
|
|
20
|
+
const result = await http.get(baseUrl, finalQuery);
|
|
21
|
+
// Strapi gibt ein Array zurück
|
|
22
|
+
return {
|
|
23
|
+
data: result.data[0] ?? null,
|
|
24
|
+
meta: result.meta,
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=collection-repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection-repository.js","sourceRoot":"","sources":["../../src/repositories/collection-repository.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CACxC,cAAsB,EACtB,IAAgB;IAEhB,MAAM,OAAO,GAAG,IAAI,cAAc,EAAE,CAAA;IAEpC,OAAO;QACL,KAAK,CAAC,OAAO,CAAC,KAAuB;YACnC,OAAO,IAAI,CAAC,GAAG,CAA8B,OAAO,EAAE,KAAK,CAAC,CAAA;QAC9D,CAAC;QAED,KAAK,CAAC,WAAW,CAAC,EAAmB,EAAE,KAAuB;YAC5D,MAAM,GAAG,GAAG,GAAG,OAAO,IAAI,EAAE,EAAE,CAAA;YAC9B,OAAO,IAAI,CAAC,GAAG,CAA0B,GAAG,EAAE,KAAK,CAAC,CAAA;QACtD,CAAC;QAED,KAAK,CAAC,aAAa,CAAC,IAAY,EAAE,KAAuB;YACvD,MAAM,UAAU,GAAG,YAAY,CAAC,KAAK,EAAE;gBACrC,IAAI,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;aACpB,CAAC,CAAA;YAEF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAA8B,OAAO,EAAE,UAAU,CAAC,CAAA;YAE/E,+BAA+B;YAC/B,OAAO;gBACL,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI;gBAC5B,IAAI,EAAE,MAAM,CAAC,IAAI;aAClB,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare enum CollectionName {
|
|
2
|
+
Article = "articles",
|
|
3
|
+
Category = "categories",
|
|
4
|
+
Page = "pages",
|
|
5
|
+
Product = "products"
|
|
6
|
+
}
|
|
7
|
+
export declare const defaultCollections: {
|
|
8
|
+
readonly article: CollectionName.Article;
|
|
9
|
+
readonly category: CollectionName.Category;
|
|
10
|
+
readonly page: CollectionName.Page;
|
|
11
|
+
readonly product: CollectionName.Product;
|
|
12
|
+
};
|
|
13
|
+
export type CollectionKey = keyof typeof defaultCollections;
|
|
14
|
+
//# sourceMappingURL=collections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../src/repositories/collections.ts"],"names":[],"mappings":"AACA,oBAAY,cAAc;IACxB,OAAO,aAAa;IACpB,QAAQ,eAAe;IACvB,IAAI,UAAU;IACd,OAAO,aAAa;CACrB;AAED,eAAO,MAAM,kBAAkB;;;;;CAKrB,CAAA;AAEV,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Central place for default Strapi collection slugs.
|
|
2
|
+
export var CollectionName;
|
|
3
|
+
(function (CollectionName) {
|
|
4
|
+
CollectionName["Article"] = "articles";
|
|
5
|
+
CollectionName["Category"] = "categories";
|
|
6
|
+
CollectionName["Page"] = "pages";
|
|
7
|
+
CollectionName["Product"] = "products";
|
|
8
|
+
})(CollectionName || (CollectionName = {}));
|
|
9
|
+
export const defaultCollections = {
|
|
10
|
+
article: CollectionName.Article,
|
|
11
|
+
category: CollectionName.Category,
|
|
12
|
+
page: CollectionName.Page,
|
|
13
|
+
product: CollectionName.Product,
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=collections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections.js","sourceRoot":"","sources":["../../src/repositories/collections.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,MAAM,CAAN,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,sCAAoB,CAAA;IACpB,yCAAuB,CAAA;IACvB,gCAAc,CAAA;IACd,sCAAoB,CAAA;AACtB,CAAC,EALW,cAAc,KAAd,cAAc,QAKzB;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,OAAO,EAAE,cAAc,CAAC,OAAO;IAC/B,QAAQ,EAAE,cAAc,CAAC,QAAQ;IACjC,IAAI,EAAE,cAAc,CAAC,IAAI;IACzB,OAAO,EAAE,cAAc,CAAC,OAAO;CACvB,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { NitroFetchRequest } from 'nitropack';
|
|
2
|
+
export interface StrapiPagination {
|
|
3
|
+
page?: number;
|
|
4
|
+
pageSize?: number;
|
|
5
|
+
pageCount?: number;
|
|
6
|
+
total?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface StrapiMeta {
|
|
9
|
+
pagination?: StrapiPagination;
|
|
10
|
+
}
|
|
11
|
+
export interface StrapiCollectionResponse<T> {
|
|
12
|
+
data: T[];
|
|
13
|
+
meta: StrapiMeta;
|
|
14
|
+
}
|
|
15
|
+
export interface StrapiSingleResponse<T> {
|
|
16
|
+
data: T | null;
|
|
17
|
+
meta?: StrapiMeta;
|
|
18
|
+
}
|
|
19
|
+
export type StrapiPopulate = '*' | string | string[];
|
|
20
|
+
export interface RepositoryQuery {
|
|
21
|
+
populate?: StrapiPopulate;
|
|
22
|
+
sort?: string | string[];
|
|
23
|
+
fields?: string[];
|
|
24
|
+
filters?: Record<string, unknown>;
|
|
25
|
+
pagination?: StrapiPagination;
|
|
26
|
+
locale?: string;
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
}
|
|
29
|
+
export interface HttpClient {
|
|
30
|
+
get<T>(path: NitroFetchRequest, params?: RepositoryQuery): Promise<T>;
|
|
31
|
+
}
|
|
32
|
+
export interface CollectionRepository<T> {
|
|
33
|
+
findAll(query?: RepositoryQuery): Promise<StrapiCollectionResponse<T>>;
|
|
34
|
+
findOneById(id: string | number, query?: RepositoryQuery): Promise<StrapiSingleResponse<T>>;
|
|
35
|
+
findOneBySlug(slug: string, query?: RepositoryQuery): Promise<StrapiSingleResponse<T>>;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../src/repositories/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAElD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,UAAU;IACzB,UAAU,CAAC,EAAE,gBAAgB,CAAA;CAC9B;AAED,MAAM,WAAW,wBAAwB,CAAC,CAAC;IACzC,IAAI,EAAE,CAAC,EAAE,CAAA;IACT,IAAI,EAAE,UAAU,CAAA;CACjB;AAED,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,IAAI,EAAE,CAAC,GAAG,IAAI,CAAA;IACd,IAAI,CAAC,EAAE,UAAU,CAAA;CAClB;AAED,MAAM,MAAM,cAAc,GAAG,GAAG,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;AAEpD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,cAAc,CAAA;IACzB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IACxB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjC,UAAU,CAAC,EAAE,gBAAgB,CAAA;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;CACtE;AAED,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,OAAO,CAAC,KAAK,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAA;IACtE,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAA;IAC3F,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAA;CACvF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../src/repositories/contracts.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CollectionName, type CollectionKey } from './collections.js';
|
|
2
|
+
export type CollectionConfig = Partial<Record<CollectionKey, CollectionName | string>>;
|
|
3
|
+
export declare const createRepositories: (apiBase: string, collections?: CollectionConfig) => {
|
|
4
|
+
articleRepository: import("./article-repository.js").ArticleRepository;
|
|
5
|
+
categoryRepository: import("./category-repository.js").CategoryRepository;
|
|
6
|
+
pageRepository: import("./page-repository.js").PageRepository;
|
|
7
|
+
productRepository: import("./product-repository.js").ProductRepository;
|
|
8
|
+
};
|
|
9
|
+
export type Repositories = ReturnType<typeof createRepositories>;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/repositories/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAsB,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAEzF,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,cAAc,GAAG,MAAM,CAAC,CAAC,CAAA;AAEtF,eAAO,MAAM,kBAAkB,GAAI,SAAS,MAAM,EAAE,cAAa,gBAAqB;;;;;CAUrF,CAAA;AACD,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createArticleRepository } from './article-repository.js';
|
|
2
|
+
import { createCategoryRepository } from './category-repository.js';
|
|
3
|
+
import { createPageRepository } from './page-repository.js';
|
|
4
|
+
import { createProductRepository } from './product-repository.js';
|
|
5
|
+
import { createStrapiClient } from './strapi-client.js';
|
|
6
|
+
import { defaultCollections } from './collections.js';
|
|
7
|
+
export const createRepositories = (apiBase, collections = {}) => {
|
|
8
|
+
const client = createStrapiClient(apiBase);
|
|
9
|
+
const names = { ...defaultCollections, ...collections };
|
|
10
|
+
return {
|
|
11
|
+
articleRepository: createArticleRepository(client, names.article),
|
|
12
|
+
categoryRepository: createCategoryRepository(client, names.category),
|
|
13
|
+
pageRepository: createPageRepository(client, names.page),
|
|
14
|
+
productRepository: createProductRepository(client, names.product),
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/repositories/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAkB,kBAAkB,EAAsB,MAAM,kBAAkB,CAAA;AAIzF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAe,EAAE,cAAgC,EAAE,EAAE,EAAE;IACxF,MAAM,MAAM,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAA;IAC1C,MAAM,KAAK,GAAG,EAAE,GAAG,kBAAkB,EAAE,GAAG,WAAW,EAAE,CAAA;IAEvD,OAAO;QACL,iBAAiB,EAAE,uBAAuB,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC;QACjE,kBAAkB,EAAE,wBAAwB,CAAC,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC;QACpE,cAAc,EAAE,oBAAoB,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC;QACxD,iBAAiB,EAAE,uBAAuB,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC;KAClE,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Page } from '../models/page.js';
|
|
2
|
+
import type { CollectionRepository, HttpClient } from './contracts.js';
|
|
3
|
+
import { CollectionName } from './collections.js';
|
|
4
|
+
export type PageRepository = CollectionRepository<Page>;
|
|
5
|
+
export declare const createPageRepository: (client: HttpClient, collectionName?: CollectionName | string) => PageRepository;
|
|
6
|
+
//# sourceMappingURL=page-repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-repository.d.ts","sourceRoot":"","sources":["../../src/repositories/page-repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEtE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,MAAM,MAAM,cAAc,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAA;AAEvD,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,UAAU,EAClB,iBAAgB,cAAc,GAAG,MAA4B,KAC5D,cAA0E,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createCollectionRepository } from './collection-repository.js';
|
|
2
|
+
import { CollectionName } from './collections.js';
|
|
3
|
+
export const createPageRepository = (client, collectionName = CollectionName.Page) => createCollectionRepository(collectionName, client);
|
|
4
|
+
//# sourceMappingURL=page-repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-repository.js","sourceRoot":"","sources":["../../src/repositories/page-repository.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAA;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAIjD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,MAAkB,EAClB,iBAA0C,cAAc,CAAC,IAAI,EAC7C,EAAE,CAAC,0BAA0B,CAAO,cAAc,EAAE,MAAM,CAAC,CAAA"}
|