@bhofstaetter/payloadcms-repository 0.1.0 → 1.0.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # payload-repository
2
2
 
3
- Opinionated repository and query object wrapper around Payload's Local API.
3
+ Opinionated repository and operations object wrapper around Payload's Local API.
4
4
 
5
5
  ## Installation
6
6
 
@@ -12,16 +12,16 @@ npm install @bhofstaetter/payloadcms-repository
12
12
 
13
13
  Pass your generated Payload `Config` type as the first type argument to get full type safety on fields, select, and return types.
14
14
 
15
- ### CollectionQuery
15
+ ### CollectionOperations
16
16
 
17
- Extend `CollectionQuery` to encapsulate domain-specific query logic for a collection:
17
+ Extend `CollectionOperations` to encapsulate domain-specific operations logic for a collection:
18
18
 
19
19
  ```ts
20
20
  import type {BasePayload} from 'payload';
21
21
  import type {Config} from '@/payload-types';
22
- import {CollectionQuery} from '@bhofstaetter/payloadcms-repository';
22
+ import {CollectionOperations} from '@bhofstaetter/payloadcms-repository';
23
23
 
24
- class PostsQuery extends CollectionQuery<Config, 'posts'> {
24
+ class PostsOperations extends CollectionOperations<Config, 'posts'> {
25
25
  constructor(payload: BasePayload) {
26
26
  super(payload, 'posts');
27
27
  }
@@ -52,23 +52,23 @@ class PostsQuery extends CollectionQuery<Config, 'posts'> {
52
52
  }
53
53
 
54
54
  // Usage
55
- const postsQuery = new PostsQuery(payload);
55
+ const postsOperations = new PostsOperations(payload);
56
56
 
57
- const post = await postsQuery.create('Hello World');
58
- const published = await postsQuery.findPublished();
59
- await postsQuery.publish(post.id);
57
+ const post = await postsOperations.create('Hello World');
58
+ const published = await postsOperations.findPublished();
59
+ await postsOperations.publish(post.id);
60
60
  ```
61
61
 
62
- ### GlobalQuery
62
+ ### GlobalOperations
63
63
 
64
- Extend `GlobalQuery` to encapsulate domain-specific query logic for a global:
64
+ Extend `GlobalOperations` to encapsulate domain-specific operations logic for a global:
65
65
 
66
66
  ```ts
67
67
  import type {BasePayload} from 'payload';
68
68
  import type {Config} from '@/payload-types';
69
- import {GlobalQuery} from '@bhofstaetter/payloadcms-repository';
69
+ import {GlobalOperations} from '@bhofstaetter/payloadcms-repository';
70
70
 
71
- class SettingsQuery extends GlobalQuery<Config, 'settings'> {
71
+ class SettingsOperations extends GlobalOperations<Config, 'settings'> {
72
72
  constructor(payload: BasePayload) {
73
73
  super(payload, 'settings');
74
74
  }
@@ -83,10 +83,10 @@ class SettingsQuery extends GlobalQuery<Config, 'settings'> {
83
83
  }
84
84
 
85
85
  // Usage
86
- const settingsQuery = new SettingsQuery(payload);
86
+ const settingsOperations = new SettingsOperations(payload);
87
87
 
88
- const settings = await settingsQuery.get();
89
- await settingsQuery.setSiteTitle('My Site');
88
+ const settings = await settingsOperations.get();
89
+ await settingsOperations.setSiteTitle('My Site');
90
90
  ```
91
91
 
92
92
  ## License
@@ -1,7 +1,7 @@
1
1
  import type { BasePayload, CollectionSlug } from 'payload';
2
- import type { AnyCollectionConfig } from '@/types';
2
+ import type { AnyCollectionConfig } from '../types';
3
3
  import { CollectionRepository } from './CollectionRepository';
4
- export declare abstract class CollectionQuery<TConfig extends AnyCollectionConfig, TSlug extends CollectionSlug> {
4
+ export declare abstract class CollectionOperations<TConfig extends AnyCollectionConfig, TSlug extends CollectionSlug> {
5
5
  protected readonly repository: CollectionRepository<TConfig, TSlug>;
6
6
  protected constructor(payload: BasePayload, collectionSlug: TSlug);
7
7
  }
@@ -1,5 +1,5 @@
1
1
  import { CollectionRepository } from './CollectionRepository';
2
- export class CollectionQuery {
2
+ export class CollectionOperations {
3
3
  repository;
4
4
  constructor(payload, collectionSlug) {
5
5
  this.repository = new CollectionRepository(payload, collectionSlug);
@@ -1,6 +1,6 @@
1
1
  import type { BasePayload, BulkOperationResult, CollectionSlug, DataFromCollectionSlug, PaginatedDistinctDocs, PaginatedDocs, RequiredDataFromCollectionSlug, SelectType, TransformCollectionWithSelect, TypeWithVersion, Where } from 'payload';
2
2
  import type { DeepPartial } from 'ts-essentials';
3
- import type { AnyCollectionConfig, DbId } from '@/types';
3
+ import type { AnyCollectionConfig, DbId } from '../types';
4
4
  export declare class CollectionRepository<TConfig extends AnyCollectionConfig, TSlug extends CollectionSlug> {
5
5
  protected readonly payload: BasePayload;
6
6
  protected readonly collectionSlug: TSlug;
@@ -1,7 +1,7 @@
1
1
  import type { BasePayload, GlobalSlug } from 'payload';
2
- import type { AnyGlobalConfig } from '@/types';
2
+ import type { AnyGlobalConfig } from '../types';
3
3
  import { GlobalRepository } from './GlobalRepository';
4
- export declare abstract class GlobalQuery<TConfig extends AnyGlobalConfig, TSlug extends GlobalSlug> {
4
+ export declare abstract class GlobalOperations<TConfig extends AnyGlobalConfig, TSlug extends GlobalSlug> {
5
5
  protected readonly repository: GlobalRepository<TConfig, TSlug>;
6
6
  protected constructor(payload: BasePayload, globalSlug: TSlug);
7
7
  }
@@ -1,5 +1,5 @@
1
1
  import { GlobalRepository } from './GlobalRepository';
2
- export class GlobalQuery {
2
+ export class GlobalOperations {
3
3
  repository;
4
4
  constructor(payload, globalSlug) {
5
5
  this.repository = new GlobalRepository(payload, globalSlug);
@@ -1,6 +1,6 @@
1
1
  import type { BasePayload, DataFromGlobalSlug, GlobalSlug, PaginatedDocs, SelectType, TransformGlobalWithSelect, TypeWithVersion } from 'payload';
2
2
  import type { DeepPartial } from 'ts-essentials';
3
- import type { AnyGlobalConfig, DbId } from '@/types';
3
+ import type { AnyGlobalConfig, DbId } from '../types';
4
4
  export declare class GlobalRepository<TConfig extends AnyGlobalConfig, TSlug extends GlobalSlug> {
5
5
  protected readonly payload: BasePayload;
6
6
  protected readonly globalSlug: TSlug;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { CollectionQuery } from './collection/CollectionQuery';
1
+ export { CollectionOperations } from './collection/CollectionOperations';
2
2
  export { CollectionRepository } from './collection/CollectionRepository';
3
- export { GlobalQuery } from './global/GlobalQuery';
3
+ export { GlobalOperations } from './global/GlobalOperations';
4
4
  export { GlobalRepository } from './global/GlobalRepository';
5
5
  export type { AnyCollectionConfig, AnyGlobalConfig, DbId } from './types.js';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { CollectionQuery } from './collection/CollectionQuery';
1
+ export { CollectionOperations } from './collection/CollectionOperations';
2
2
  export { CollectionRepository } from './collection/CollectionRepository';
3
- export { GlobalQuery } from './global/GlobalQuery';
3
+ export { GlobalOperations } from './global/GlobalOperations';
4
4
  export { GlobalRepository } from './global/GlobalRepository';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bhofstaetter/payloadcms-repository",
3
- "version": "0.1.0",
4
- "description": "Opinionated repository and query object wrapper around Payload's local API.",
3
+ "version": "1.0.1",
4
+ "description": "Opinionated repository and operations object wrapper around Payload's Local API.",
5
5
  "license": "MIT",
6
6
  "author": "Benedikt Hofstätter",
7
7
  "homepage": "https://github.com/bhofstaetter/payloadcms-repository",
@@ -29,23 +29,26 @@
29
29
  }
30
30
  },
31
31
  "scripts": {
32
- "build": "tsc -p tsconfig.build.json",
32
+ "build": "rm -rf dist && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
33
33
  "typecheck": "tsc",
34
34
  "lint": "biome check",
35
35
  "lint:fix": "biome check --fix",
36
- "prepublishOnly": "npm run lint && npm run typecheck && npm run build"
36
+ "test": "vitest run",
37
+ "prepublishOnly": "npm run lint && npm run typecheck && npm run test && npm run build"
37
38
  },
38
39
  "peerDependencies": {
39
40
  "payload": ">=3",
40
41
  "ts-essentials": ">=10"
41
42
  },
42
43
  "devDependencies": {
43
- "payload": "^3.78.0",
44
+ "@bhofstaetter/payloadcms-it-helper": "^1.0.0",
45
+ "@biomejs/biome": "2.4.4",
44
46
  "@payloadcms/db-postgres": "^3.78.0",
47
+ "@testcontainers/postgresql": "^11.11.0",
48
+ "payload": "^3.78.0",
45
49
  "ts-essentials": "^10.0.0",
50
+ "tsc-alias": "^1.8.16",
46
51
  "typescript": "^5",
47
- "@biomejs/biome": "2.4.4",
48
- "@testcontainers/postgresql": "^11.11.0",
49
52
  "vite-tsconfig-paths": "^6.1.1",
50
53
  "vitest": "^4.0.18"
51
54
  },